diff --git a/uppsrc/Core/HeapImp.h b/uppsrc/Core/HeapImp.h index ffa1880e8..c2b1043bb 100644 --- a/uppsrc/Core/HeapImp.h +++ b/uppsrc/Core/HeapImp.h @@ -26,6 +26,7 @@ struct Heap { 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 448, 576, 672, 800, 992, 8, 16, 24, 40, 48, 56 // 12 13 14 15 16 17 18 19 20 21 22 + // 8 - 56 sizes are only available with TinyAlloc }; static_assert(__countof(sz) == 23, "NKLASS mismatch"); return sz[k]; diff --git a/uppsrc/Core/Util.cpp b/uppsrc/Core/Util.cpp index 8fe6de889..5e1f33b55 100644 --- a/uppsrc/Core/Util.cpp +++ b/uppsrc/Core/Util.cpp @@ -682,6 +682,19 @@ void SetGlobalConfigData(const char *name, const String& data) sGCfg().GetAdd(name) = data; } +bool LoadFromGlobal(Event x, const char *name) +{ + StringStream ss(GetGlobalConfigData(name)); + return ss.IsEof() || Load(x, ss); +} + +void StoreToGlobal(Event x, const char *name) +{ + StringStream ss; + Store(x, ss); + SetGlobalConfigData(name, ss); +} + void SerializeGlobalConfigs(Stream& s) { Mutex::Lock __(sGCfgLock); diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index 3808b9f6d..edc76e146 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -472,6 +472,9 @@ void StoreToGlobal(T& x, const char *name) SetGlobalConfigData(name, ss); } +bool LoadFromGlobal(Event serialize, const char *name); +void StoreToGlobal(Event serialize, const char *name); + void SerializeGlobalConfigs(Stream& s); #ifdef PLATFORM_WINCE diff --git a/uppsrc/Core/src.tpp/SerializationUtils$en-us.tpp b/uppsrc/Core/src.tpp/SerializationUtils$en-us.tpp index a7e748443..c6a19b03b 100644 --- a/uppsrc/Core/src.tpp/SerializationUtils$en-us.tpp +++ b/uppsrc/Core/src.tpp/SerializationUtils$en-us.tpp @@ -189,13 +189,29 @@ has to be explicitly triggered before storing configuration.&] [s5;:LoadFromGlobal`(T`&`,const char`*`):%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 T ][@(0.0.255) >]_[@(0.0.255) bool]_[* LoadFromGlobal]([*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 name])&] -[s2; Loads [%-*@3 x] from global configuration key [%-*@3 name].&] +[s2; Loads [%-*@3 x] from global configuration key [%-*@3 name], using +Serialize method of T.&] [s3; &] [s4;%- &] [s5;:StoreToGlobal`(T`&`,const char`*`):%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 T ][@(0.0.255) >]_[@(0.0.255) void]_[* StoreToGlobal]([*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 name])&] -[s2; Stores [@3 x] to global configuration key [%-*C@3 name].&] +[s2; Stores [@3 x] to global configuration key [%-*@3 name], using Serialize +method of T.&] +[s3; &] +[s4;%- &] +[s5;:Upp`:`:LoadFromGlobal`(Upp`:`:Event``,const char`*`):%- [@(0.0.255) b +ool]_[* LoadFromGlobal]([_^Upp`:`:Event^ Event]_[*@3 serialize], +[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 name])&] +[s2; Loads [%-*@3 x] from global configuration key [%-*@3 name], using +[%-*@3 serialize] as serialization function.&] +[s3; &] +[s4;%- &] +[s5;:Upp`:`:StoreToGlobal`(Upp`:`:Event``,const char`*`):%- [@(0.0.255) v +oid]_[* StoreToGlobal]([_^Upp`:`:Event^ Event]_[*@3 x], +[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 name])&] +[s2; Stores [@3 x] to global configuration key [%-*@3 name], using [%-*@3 serialize] +as serialization function.&] [s3; &] [s4;%- &] [s5;:SerializeGlobalConfigs`(Stream`&`):%- [@(0.0.255) void]_[* SerializeGlobalConfigs]([_^Stream^ S diff --git a/uppsrc/Core/src.tpp/Util$en-us.tpp b/uppsrc/Core/src.tpp/Util$en-us.tpp index 470b9e318..13554f789 100644 --- a/uppsrc/Core/src.tpp/Util$en-us.tpp +++ b/uppsrc/Core/src.tpp/Util$en-us.tpp @@ -45,7 +45,7 @@ _[*@3 fr])&] [s2;%% Replaces multiple patterns with replace texts. When patterns and replaces are specified by VectorMap, keys are patterns. Text replaced is not searched for more instances of patterns. Longest -pattern is always used (if patterns:replases are `"hell`":`"hello`" +pattern is always used (if patterns:replaces are `"hell`":`"hello`" and `"hello`":`"hell`", then replacing within `"hell hello`" produces `"hello hell`").&] [s3;%% &]