File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,9 @@ namespace REX::JSON
3030 {
3131 public:
3232 Setting (path_t a_path, T a_default) :
33- TSetting<T, Store>(a_default)
34- {
35- if (a_path[0 ] != ' /' ) {
36- m_path = std::format (" /{}" sv, a_path);
37- } else {
38- m_path = std::move (a_path);
39- }
40- }
33+ TSetting<T, Store>(a_default),
34+ m_path (a_path)
35+ {}
4136
4237 public:
4338 virtual void Load (void * a_data, bool a_isBase) override
Original file line number Diff line number Diff line change @@ -17,7 +17,12 @@ namespace REX::JSON
1717 T& a_valueDefault)
1818 {
1919 const auto & json = *static_cast <glz::json_t *>(a_data);
20- a_value = glz::get<T>(json, a_path).value_or (a_valueDefault);
20+ if (a_path[0 ] != ' /' ) {
21+ const auto path = std::format (" /{}sv" , a_path);
22+ a_value = glz::get<T>(json, path).value_or (a_valueDefault);
23+ } else {
24+ a_value = glz::get<T>(json, a_path).value_or (a_valueDefault);
25+ }
2126 }
2227
2328 template void SettingLoad<bool >(void *, path_t , bool &, bool &);
@@ -38,7 +43,12 @@ namespace REX::JSON
3843 T& a_value)
3944 {
4045 auto & json = *static_cast <glz::json_t *>(a_data);
41- glz::set (json, a_path, a_value);
46+ if (a_path[0 ] != ' /' ) {
47+ const auto path = std::format (" /{}" sv, a_path);
48+ glz::set (json, path, a_value);
49+ } else {
50+ glz::set (json, a_path, a_value);
51+ }
4252 }
4353
4454 template void SettingSave<bool >(void *, path_t , bool &);
You can’t perform that action at this time.
0 commit comments