Core: Jsonize(byte)

git-svn-id: svn://ultimatepp.org/upp/trunk@12126 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-07-31 13:38:13 +00:00
parent 33220f0d67
commit a1b5057076
4 changed files with 18 additions and 1 deletions

View file

@ -203,6 +203,18 @@ template<> void Jsonize(JsonIO& io, int& var)
}
}
template<> void Jsonize(JsonIO& io, byte& var)
{
double v = var;
Jsonize(io, v);
if(io.IsLoading()) {
if(v >= 0 && v <= 255 && (int)v == v)
var = (byte)v;
else
throw JsonizeError("integer 0-255 expected");
}
}
template<> void Jsonize(JsonIO& io, int16& var)
{
double v = var;

View file

@ -221,6 +221,7 @@ bool LoadFromJsonFile(T& var, const char *file = NULL)
}
template<> void Jsonize(JsonIO& io, int& var);
template<> void Jsonize(JsonIO& io, byte& var);
template<> void Jsonize(JsonIO& io, int16& var);
template<> void Jsonize(JsonIO& io, int64& var);
template<> void Jsonize(JsonIO& io, double& var);

View file

@ -134,6 +134,9 @@ returns false in case of error. If [%-*@3 file] is NULL, ConfigFile(GetExeTitle(
[s3; &]
[s5;:Jsonize`(JsonIO`&`,int`&`): [@(0.0.255) template]_<>_[@(0.0.255) void]_[* Jsonize]([_^JsonIO^ J
sonIO][@(0.0.255) `&]_[*@3 io], [@(0.0.255) int`&]_[*@3 var])&]
[s5;:Upp`:`:Jsonize`(Upp`:`:JsonIO`&`,Upp`:`:byte`&`): [@(0.0.255) template]_<>_[@(0.0.255) v
oid]_[* Jsonize]([_^Upp`:`:JsonIO^ JsonIO][@(0.0.255) `&]_[*@3 io], [_^Upp`:`:byte^ byte][@(0.0.255) `&
]_[*@3 var])&]
[s5;:Jsonize`(JsonIO`&`,int16`&`): [@(0.0.255) template]_<>_[@(0.0.255) void]_[* Jsonize]([_^JsonIO^ J
sonIO][@(0.0.255) `&]_[*@3 io], [_^int16^ int16][@(0.0.255) `&]_[*@3 var])&]
[s5;:Jsonize`(JsonIO`&`,int64`&`): [@(0.0.255) template]_<>_[@(0.0.255) void]_[* Jsonize]([_^JsonIO^ J
@ -167,6 +170,7 @@ which leads to somewhat unnatural results when key [%-*@4 K] is
String or WString. [%-* StringMap ]alternative variant encodes
map as JSON object with keys equal to map keys.&]
[s3;%% &]
[s3;%% &]
[s4;%% &]
[s5;:JsonizeBySerialize`(JsonIO`&`,T`&`): [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 T]>
_[@(0.0.255) void]_[* JsonizeBySerialize]([_^JsonIO^ JsonIO][@(0.0.255) `&]_[*@3 jio],

View file

@ -120,7 +120,7 @@ public:
Column();
// deprecated (due to overloading issues)
Column& Ctrls(Callback1<One<Ctrl>&> factory); // deprecated
Column& Ctrls(Callback1<One<Ctrl>&> factory);
Column& Ctrls(void (*factory)(One<Ctrl>&)) { return Ctrls(Event<int, One<Ctrl>&>([=](int, One<Ctrl>& h) { factory(h); })); }
Column& Ctrls(Event<int, One<Ctrl>&> factory);
Column& Ctrls(void (*factory)(int, One<Ctrl>&)) { return Ctrls(Event<int, One<Ctrl>&>([=](int a, One<Ctrl>& b){ factory(a, b); })); }