summaryrefslogtreecommitdiff
path: root/include/swconfig.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/swconfig.h')
-rw-r--r--include/swconfig.h92
1 files changed, 45 insertions, 47 deletions
diff --git a/include/swconfig.h b/include/swconfig.h
index 8e37d2c..f508a53 100644
--- a/include/swconfig.h
+++ b/include/swconfig.h
@@ -2,7 +2,7 @@
* swconfig.h - definition of Class SWConfig used for saving and retrieval
* of configuration information
*
- * $Id: swconfig.h,v 1.16 2002/03/19 23:59:41 scribe Exp $
+ * $Id: swconfig.h,v 1.22 2003/06/27 01:41:06 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -25,67 +25,65 @@
#include <stdio.h>
-#include <string>
#include <map>
#include <defs.h>
#include <multimapwdef.h>
+#include <swbuf.h>
-using namespace std;
+SWORD_NAMESPACE_START
-
-
-typedef multimapwithdefault < string, string, less < string > >ConfigEntMap;
-typedef map < string, ConfigEntMap, less < string > >SectionMap;
+typedef multimapwithdefault < SWBuf, SWBuf, std::less < SWBuf > >ConfigEntMap;
+typedef std::map < SWBuf, ConfigEntMap, std::less < SWBuf > >SectionMap;
/** The class to read and save settings using a file on disk.
*
*/
-class SWDLLEXPORT SWConfig
-{
+class SWDLLEXPORT SWConfig {
private:
- char getline (FILE * fp, string & line);
+ char getline(FILE * fp, SWBuf & line);
public:
- /** The filename used by this SWConfig object
- *
- */
- string filename;
- /** Map of available sections
- * The map of available sections.
- */
- SectionMap Sections;
-
- /** Constructor of SWConfig
- * @param ifilename The file, which should be used for this config.
- */
- SWConfig (const char *ifilename);
- virtual ~ SWConfig ();
+ /** The filename used by this SWConfig object
+ *
+ */
+ SWBuf filename;
+ /** Map of available sections
+ * The map of available sections.
+ */
+ SectionMap Sections;
- /** Load from disk
- * Load the contzent from disk.
- */
- virtual void Load ();
+ /** Constructor of SWConfig
+ * @param ifilename The file, which should be used for this config.
+ */
+ SWConfig(const char *ifilename);
+ virtual ~SWConfig();
- /** Save to disk
- * Save the content of this config object to disk.
- */
- virtual void Save ();
+ /** Load from disk
+ * Load the contzent from disk.
+ */
+ virtual void Load();
- /** Merges the values of addFrom
- * @param The config which values should be merged to this config object. Already existing values will be overwritten.
- */
- virtual SWConfig & operator += (SWConfig & addFrom);
+ /** Save to disk
+ * Save the content of this config object to disk.
+ */
+ virtual void Save();
- /** Get a section
- * This is an easy way to get and store config values.
- * The following will work:\n
- *
- * @code
- * SWConfig config("/home/user/.setttings");
- * config["Colors"]["Background"] = "red";
- * @endcode
- */
- virtual ConfigEntMap & operator [] (const char *section);
-};
+ /** Merges the values of addFrom
+ * @param addFrom The config which values should be merged to this config object. Already existing values will be overwritten.
+ */
+ virtual void augment(SWConfig &addFrom);
+ virtual SWConfig & operator +=(SWConfig &addFrom) { augment(addFrom); return *this; }
+ /** Get a section
+ * This is an easy way to get and store config values.
+ * The following will work:\n
+ *
+ * @code
+ * SWConfig config("/home/user/.setttings");
+ * config["Colors"]["Background"] = "red";
+ * @endcode
+ */
+ virtual ConfigEntMap & operator [](const char *section);
+ };
+SWORD_NAMESPACE_END
#endif