Etterna 0.74.4
Loading...
Searching...
No Matches
IniFile.h
1
3#ifndef INIFILE_H
4#define INIFILE_H
5
6#include "XmlFile.h"
7
8class RageFileBasic;
10class IniFile : public XNode
11{
12 public:
14 IniFile();
15
19 auto GetPath() const -> std::string { return m_sPath; }
23 auto GetError() const -> const std::string& { return m_sError; }
24
25 auto ReadFile(const std::string& sPath) -> bool;
26 auto ReadFile(RageFileBasic& sFile) -> bool;
27 auto WriteFile(const std::string& sPath) const -> bool;
28 auto WriteFile(RageFileBasic& sFile) const -> bool;
29
30 template<typename T>
31 auto GetValue(const std::string& sKey,
32 const std::string& sValueName,
33 T& value) const -> bool
34 {
35 const XNode* pNode = GetChild(sKey);
36 if (pNode == nullptr)
37 return false;
38 return pNode->GetAttrValue<T>(sValueName, value);
39 }
40 template<typename T>
41 void SetValue(const std::string& sKey,
42 const std::string& sValueName,
43 const T& value)
44 {
45 XNode* pNode = GetChild(sKey);
46 if (pNode == nullptr)
47 pNode = AppendChild(sKey);
48 pNode->AppendAttr<T>(sValueName, value);
49 }
50 template<typename T>
51 void SetKeyValue(XNode* keynode,
52 const std::string& sValueName,
53 const T& value)
54 {
55 keynode->AppendAttr<T>(sValueName, value);
56 }
57
58 auto DeleteKey(const std::string& keyname) -> bool;
59 auto DeleteValue(const std::string& keyname, const std::string& valuename)
60 -> bool;
61
71 auto RenameKey(const std::string& from, const std::string& to) -> bool;
72
73 private:
74 std::string m_sPath;
75
76 mutable std::string m_sError;
77};
78
79#endif
The functions to read and write .INI files.
Definition IniFile.h:11
auto GetPath() const -> std::string
Retrieve the filename of the last file loaded.
Definition IniFile.h:19
auto GetError() const -> const std::string &
Retrieve any errors that have occurred.
Definition IniFile.h:23
auto RenameKey(const std::string &from, const std::string &to) -> bool
Rename a key.
Definition IniFile.cpp:178
IniFile()
Set up an INI file with the defaults.
Definition IniFile.cpp:13
Definition RageFileBasic.h:10
Definition XmlFile.h:95