Mercurial > minori
annotate src/core/json.cc @ 118:39521c47c7a3
*: another huge megacommit, SORRY
The torrents page works a lot better now
Added the edit option to the anime list right click menu
Vectorized currently playing files
Available player and extensions are now loaded at runtime
from files in (dotpath)/players.json and (dotpath)/extensions.json
These paths are not permanent and will likely be moved to
(dotpath)/recognition
...
...
...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 23:40:54 -0500 |
parents | d02fdf1d6708 |
children | f88eda79c60a |
rev | line source |
---|---|
9 | 1 #include "core/json.h" |
2 | 2 |
3 namespace JSON { | |
4 | |
83 | 5 std::string GetString(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, std::string def) { |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
6 if (json.contains(ptr) && json[ptr].is_string()) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
7 return json[ptr].get<std::string>(); |
9 | 8 else |
9 return def; | |
2 | 10 } |
11 | |
83 | 12 int GetInt(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, int def) { |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
13 if (json.contains(ptr) && json[ptr].is_number()) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
14 return json[ptr].get<int>(); |
9 | 15 else |
16 return def; | |
2 | 17 } |
18 | |
83 | 19 bool GetBoolean(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, bool def) { |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
20 if (json.contains(ptr) && json[ptr].is_boolean()) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
21 return json[ptr].get<bool>(); |
9 | 22 else |
23 return def; | |
2 | 24 } |
25 | |
83 | 26 double GetDouble(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, double def) { |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
27 if (json.contains(ptr) && json[ptr].is_number()) |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
2
diff
changeset
|
28 return json[ptr].get<double>(); |
9 | 29 else |
30 return def; | |
2 | 31 } |
32 | |
9 | 33 } // namespace JSON |