33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
52 #pragma GCC diagnostic pop
69 if (cfile->
getFd() > 0) {
73 while (goodLine && line.
length() &&
74 ((((
unsigned char)line[0]) == 0xEF) ||
75 (((
unsigned char)line[0]) == 0xBB) ||
76 (((
unsigned char)line[0]) == 0xBF))) {
82 if (!line.startsWith(
"#")) {
83 buf =
new char [ line.length() + 1 ];
84 strcpy(buf, line.c_str());
87 getSections().insert(SectionMap::value_type(sectname, cursect));
90 cursect.erase(cursect.begin(), cursect.end());
97 if ((*buf) && (*buf !=
'=')) {
98 if ((data = strtok(
NULL,
"")))
99 cursect.insert(ConfigEntMap::value_type(buf,
strstrip(data)));
100 else cursect.insert(ConfigEntMap::value_type(buf,
""));
108 getSections().insert(SectionMap::value_type(sectname, cursect));
121 SectionMap::const_iterator sit;
122 ConfigEntMap::const_iterator entry;
126 if (cfile->
getFd() > 0) {
130 buf += (*sit).first.
c_str();
133 for (entry = (*sit).second.begin(); entry != (*sit).second.end(); ++entry) {
134 buf = (*entry).first.
c_str();
136 buf += (*entry).second.
c_str();
150 SectionMap::const_iterator section;
151 ConfigEntMap::const_iterator entry, start, end;
154 for (entry = (*section).second.begin(); entry != (*section).second.end(); ++entry) {
155 start =
getSections()[section->first].lower_bound(entry->first);
156 end =
getSections()[section->first].upper_bound(entry->first);
160 ConfigEntMap::const_iterator x = addFrom.
getSections().find(section->first)->second.lower_bound(entry->first);
161 ConfigEntMap::const_iterator y = addFrom.
getSections().find(section->first)->second.upper_bound(entry->first);
163 if (((++start) != end) || (x != y)) {
164 for (--start; start != end; ++start) {
165 if (!strcmp(start->second.c_str(), entry->second.c_str()))
169 getSections()[(*section).first].insert(ConfigEntMap::value_type((*entry).first, (*entry).second));
171 else getSections()[section->first][entry->first.c_str()] = entry->second.c_str();
173 else getSections()[section->first][entry->first.c_str()] = entry->second.c_str();
179 #if defined(__GNUC__)
180 #pragma GCC diagnostic push
181 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
193 #if defined(__GNUC__)
194 #pragma GCC diagnostic pop
#define SWORD_NAMESPACE_START
FileDesc * open(const char *path, int mode, bool tryDowngrade)
unsigned long length() const
virtual SectionMap & getSections()
static unsigned int RDONLY
static unsigned int TRUNC
SWBuf getFileName() const
long write(const void *buf, long count)
SWDEPRECATED SectionMap Sections
void close(FileDesc *file)
virtual void augment(const SWConfig &addFrom)
const char * c_str() const
std::map< SWBuf, ConfigEntMap, std::less< SWBuf > > SectionMap
SWDEPRECATED SWBuf filename
SWORD_NAMESPACE_START typedef multimapwithdefault< SWBuf, SWBuf, std::less< SWBuf > > ConfigEntMap
static unsigned int CREAT
char * strstrip(char *istr)
static char getLine(FileDesc *fDesc, SWBuf &line)
#define SWORD_NAMESPACE_END
virtual void save() const
static FileMgr * getSystemFileMgr()