2
* Copyright (C) 2004-2011 See the AUTHORS file for details.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 2 as published
6
* by the Free Software Foundation.
12
#include "ZNCString.h"
13
#include "FileUtils.h"
19
CConfigEntry(const CConfig& Config);
20
CConfigEntry(const CConfigEntry& other);
22
CConfigEntry& operator=(const CConfigEntry& other);
24
CConfig* m_pSubConfig;
27
typedef map<CString, VCString> EntryMap;
28
typedef map<CString, CConfigEntry> SubConfig;
29
typedef map<CString, SubConfig> SubConfigMap;
31
typedef EntryMap::const_iterator EntryMapIterator;
32
typedef SubConfigMap::const_iterator SubConfigMapIterator;
34
EntryMapIterator BeginEntries() const {
35
return m_ConfigEntries.begin();
37
EntryMapIterator EndEntries() const {
38
return m_ConfigEntries.end();
41
SubConfigMapIterator BeginSubConfigs() const {
42
return m_SubConfigs.begin();
44
SubConfigMapIterator EndSubConfigs() const {
45
return m_SubConfigs.end();
48
bool FindStringVector(const CString& sName, VCString& vsList) {
49
EntryMap::iterator it = m_ConfigEntries.find(sName);
51
if (it == m_ConfigEntries.end())
54
m_ConfigEntries.erase(it);
58
bool FindStringEntry(const CString& sName, CString& sRes) {
59
EntryMap::iterator it = m_ConfigEntries.find(sName);
61
if (it == m_ConfigEntries.end() || it->second.empty())
63
sRes = it->second.front();
64
it->second.erase(it->second.begin());
65
if (it->second.empty())
66
m_ConfigEntries.erase(it);
70
bool FindSubConfig(const CString& sName, SubConfig& Config) {
71
SubConfigMap::iterator it = m_SubConfigs.find(sName);
72
if (it == m_SubConfigs.end()) {
77
m_SubConfigs.erase(it);
82
return m_ConfigEntries.empty() && m_SubConfigs.empty();
85
bool Parse(CFile& file, CString& sErrorMsg);
88
EntryMap m_ConfigEntries;
89
SubConfigMap m_SubConfigs;