mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: LoadFromJsonFile, StoreToJsonFile
git-svn-id: svn://ultimatepp.org/upp/trunk@4825 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9e88dfd28e
commit
b49f461ce4
2 changed files with 19 additions and 0 deletions
|
|
@ -304,4 +304,9 @@ template<> void Jsonize(JsonIO& io, Time& var)
|
|||
var.year, var.month, var.day, var.hour, var.minute, var.second));
|
||||
}
|
||||
|
||||
String sJsonFile(const char *file)
|
||||
{
|
||||
return file ? String(file) : ConfigFile(GetExeTitle() + ".json");
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -174,6 +174,20 @@ bool LoadFromJson(T& var, const char *json)
|
|||
return true;
|
||||
}
|
||||
|
||||
String sJsonFile(const char *file);
|
||||
|
||||
template <class T>
|
||||
bool StoreAsJsonFile(const T& var, const char *file, bool pretty = false)
|
||||
{
|
||||
return SaveFile(sJsonFile(file), StoreAsJson(var, pretty));;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool LoadFromJsonFile(T& var, const char *file = NULL)
|
||||
{
|
||||
return LoadFromJson(var, LoadFile(sJsonFile(file)));
|
||||
}
|
||||
|
||||
template<> void Jsonize(JsonIO& io, int& var);
|
||||
template<> void Jsonize(JsonIO& io, int64& var);
|
||||
template<> void Jsonize(JsonIO& io, double& var);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue