Core: LambdaIze

git-svn-id: svn://ultimatepp.org/upp/trunk@15938 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-04-30 08:00:58 +00:00
parent 7efc34dad8
commit 431fc3aa04
2 changed files with 26 additions and 0 deletions

View file

@ -457,3 +457,20 @@ void JsonizeBySerialize(JsonIO& jio, T& x)
throw JsonizeError("jsonize by serialize error");
}
}
template <class IZE>
struct LambdaIzeVar {
IZE& ize;
void Jsonize(JsonIO& io) { ize(io); }
void Xmlize(XmlIO& io) { ize(io); }
LambdaIzeVar(IZE& ize) : ize(ize) {}
};
template <class IO, class IZE>
void LambdaIze(IO& io, const char *id, IZE ize)
{
LambdaIzeVar<IZE> var(ize);
io(id, var);
}

View file

@ -216,4 +216,13 @@ _[@(0.0.255) void]_[* JsonizeBySerialize]([_^JsonIO^ JsonIO][@(0.0.255) `&]_[*@3
[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2;%% This function encodes/retrieves Json by binary serializing
the object and Jsonizing the hexadecimal data string.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:LambdaIze`(IO`&`,const char`*`,IZE`): [@(0.0.255) template]_<[@(0.0.255) clas
s]_[*@4 IO], [@(0.0.255) class]_[*@4 IZE]>_[@(0.0.255) void]_[* LambdaIze]([*@4 IO][@(0.0.255) `&
]_[*@3 io], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 id], [*@4 IZE]_[*@3 ize])&]
[s2;%% This special function uses [%-*@3 ize] to represent the value
of Jsonize or Xmlize node named [%-*@3 id]. Lambda should have
one paramter IO`&.&]
[s3;%% &]
[s3;%% ]]