MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / IniFile

Class IniFile

Sources/OvTools/include/OvTools/Filesystem/IniFile.h:24–114  ·  view source on GitHub ↗

* The IniFile class represents a file .ini that stores a set of attributes/values that can get read and written */

Source from the content-addressed store, hash-verified

22 * The IniFile class represents a file .ini that stores a set of attributes/values that can get read and written
23 */
24 class IniFile final
25 {
26 public:
27 using AttributePair = std::pair<std::string, std::string>;
28 using AttributeMap = std::unordered_map<std::string, std::string>;
29
30 /**
31 * Create an IniFile by parsing the given file path and extracting key/values pairs for future usage
32 * @param p_filePath
33 */
34 IniFile(const std::string& p_filePath);
35
36 /**
37 * Overwrite the content of the current data by reloading the file
38 */
39 void Reload();
40
41 /**
42 * Rewrite the entiere .ini file with the current values. This operation is destructive and can't be undone.
43 * Any comment or line break in your .ini file will get destroyed
44 */
45 void Rewrite() const;
46
47 /**
48 * Return the value attached to the given key
49 * If the key doesn't exist, a default value is returned
50 * @param p_key
51 */
52 template<SupportedIniType T>
53 T Get(const std::string& p_key) const;
54
55 /**
56 * Return the value attached to the given key
57 * If the key doesn't exist, the specified value is returned
58 * @param p_key
59 * @param p_default
60 */
61 template<SupportedIniType T>
62 T GetOrDefault(const std::string& p_key, T p_default) const;
63
64 /**
65 * Try to get the value attached to the given key
66 * @param p_key
67 * @param p_outValue
68 */
69 template<SupportedIniType T>
70 bool TryGet(const std::string& p_key, T& p_outValue) const;
71
72 /**
73 * Set a new value to the given key (Not applied to the real file untill Rewrite() or Save() is called)
74 * @param p_key
75 * @param p_value
76 */
77 template<SupportedIniType T>
78 bool Set(const std::string& p_key, const T& p_value);
79
80 /**
81 * Add a new key/value to the IniFile object (Not applied to the real file untill Rewrite() or Save() is called)

Callers 2

LoadTextureMetadataFunction · 0.85
GetAssetMetadataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected