#include <swconfig.h>
Public Methods | |
| SWConfig (const char *ifilename) | |
| Constructor of SWConfig. More... | |
| virtual | ~SWConfig () |
| virtual void | Load () |
| Load from disk Load the contzent from disk. | |
| virtual void | Save () |
| Save to disk Save the content of this config object to disk. | |
| virtual SWConfig & | operator+= (SWConfig &addFrom) |
| Merges the values of addFrom. More... | |
| virtual ConfigEntMap & | operator[] (const char *section) |
| Get a section This is an easy way to get and store config values. More... | |
Public Attributes | |
| string | filename |
| The filename used by this SWConfig object. | |
| SectionMap | Sections |
| Map of available sections The map of available sections. | |
Private Methods | |
| char | getline (FILE *fp, string &line) |
Definition at line 44 of file swconfig.h.
|
|
Constructor of SWConfig.
Definition at line 27 of file swconfig.cpp. References filename, and Load().
|
|
|
Merges the values of addFrom.
Definition at line 134 of file swconfig.cpp. References Sections.
00135 {
00136
00137 SectionMap::iterator section;
00138 ConfigEntMap::iterator entry, start, end;
00139
00140 for (section = addFrom.Sections.begin(); section != addFrom.Sections.end(); section++) {
00141 for (entry = (*section).second.begin(); entry != (*section).second.end(); entry++) {
00142 start = Sections[section->first].lower_bound(entry->first);
00143 end = Sections[section->first].upper_bound(entry->first);
00144 if (start != end) {
00145 if (((++start) != end)
00146 || ((++(addFrom.Sections[section->first].lower_bound(entry->first))) != addFrom.Sections[section->first].upper_bound(entry->first))) {
00147 for (--start; start != end; start++) {
00148 if (!strcmp(start->second.c_str(), entry->second.c_str()))
00149 break;
00150 }
00151 if (start == end)
00152 Sections[(*section).first].insert(ConfigEntMap::value_type((*entry).first, (*entry).second));
00153 }
00154 else Sections[section->first][entry->first.c_str()] = entry->second.c_str();
00155 }
00156 else Sections[section->first][entry->first.c_str()] = entry->second.c_str();
00157 }
00158 }
00159 return *this;
00160 }
|
|
|
Get a section This is an easy way to get and store config values.
The following will work:
SWConfig config("/home/user/.setttings"); config["Colors"]["Background"] = "red"; Definition at line 163 of file swconfig.cpp. References Sections.
00163 {
00164 return Sections[section];
00165 }
|
1.2.15