20 #include <znc/zncconfig.h>
38 CConfig() : m_ConfigEntries(), m_SubConfigs(), m_SubConfigNameSets() {}
52 return m_SubConfigs.begin();
57 if (sName.empty() || sValue.empty()) {
61 m_ConfigEntries[sName].push_back(sValue);
66 auto& nameset = m_SubConfigNameSets[sTag];
68 if (nameset.find(sName) != nameset.end())
return false;
70 nameset.insert(sName);
71 m_SubConfigs[sTag].emplace_back(sName, Config);
78 EntryMap::iterator it = m_ConfigEntries.find(sName);
80 if (it == m_ConfigEntries.end())
return false;
84 m_ConfigEntries.erase(it);
92 EntryMap::iterator it = m_ConfigEntries.find(sName);
94 if (it == m_ConfigEntries.end() || it->second.empty())
return false;
95 sRes = it->second.front();
96 it->second.erase(it->second.begin());
97 if (it->second.empty()) m_ConfigEntries.erase(it);
102 bool bDefault =
false) {
113 unsigned int uDefault = 0) {
124 unsigned short uDefault = 0) {
135 double fDefault = 0) {
146 bool bErase =
true) {
147 auto it = m_SubConfigs.find(sTag);
148 if (it == m_SubConfigs.end()) {
155 m_SubConfigs.erase(it);
156 m_SubConfigNameSets.erase(sTag);
163 return m_ConfigEntries.empty() && m_SubConfigs.empty();
171 typedef std::map<CString, SubConfigNameSet> SubConfigNameSetMap;
175 SubConfigNameSetMap m_SubConfigNameSets;
std::set< CString > SCString
Definition: ZNCString.h:35
std::vector< CString > VCString
Definition: ZNCString.h:38
bool FindStringVector(const CString &sName, VCString &vsList, bool bErase=true)
Definition: Config.h:76
std::map< CString, VCString > EntryMap
Definition: Config.h:40
void AddKeyValuePair(const CString &sName, const CString &sValue)
Definition: Config.h:56
std::vector< SubConfigEntry > SubConfig
Definition: Config.h:42
SubConfigMapIterator BeginSubConfigs() const
Definition: Config.h:51
bool FindBoolEntry(const CString &sName, bool &bRes, bool bDefault=false)
Definition: Config.h:101
bool AddSubConfig(const CString &sTag, const CString &sName, CConfig Config)
Definition: Config.h:64
bool FindUShortEntry(const CString &sName, unsigned short &uRes, unsigned short uDefault=0)
Definition: Config.h:123
bool FindStringEntry(const CString &sName, CString &sRes, const CString &sDefault="")
Definition: Config.h:90
bool Parse(CFile &file, CString &sErrorMsg)
EntryMapIterator EndEntries() const
Definition: Config.h:49
void Write(CFile &file, unsigned int iIndentation=0)
bool FindUIntEntry(const CString &sName, unsigned int &uRes, unsigned int uDefault=0)
Definition: Config.h:112
std::pair< CString, CConfigEntry > SubConfigEntry
Definition: Config.h:41
bool empty() const
Definition: Config.h:162
bool FindSubConfig(const CString &sTag, SubConfig &Config, bool bErase=true)
Definition: Config.h:145
CConfig()
Definition: Config.h:38
std::map< CString, SubConfig > SubConfigMap
Definition: Config.h:43
EntryMapIterator BeginEntries() const
Definition: Config.h:48
SubConfigMapIterator EndSubConfigs() const
Definition: Config.h:54
bool FindDoubleEntry(const CString &sName, double &fRes, double fDefault=0)
Definition: Config.h:134
EntryMap::const_iterator EntryMapIterator
Definition: Config.h:45
SubConfigMap::const_iterator SubConfigMapIterator
Definition: Config.h:46
Definition: FileUtils.h:30
String class that is used inside ZNC.
Definition: ZNCString.h:68
unsigned short ToUShort() const
unsigned int ToUInt() const
CConfigEntry(const CConfigEntry &other)
CConfig * m_pSubConfig
Definition: Config.h:33
CConfigEntry(const CConfig &Config)
CConfigEntry & operator=(const CConfigEntry &other)