Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

mconfig.h

Go to the documentation of this file.
00001 
00025 #ifndef __MAGIC_MCONFIG_H__
00026 #define __MAGIC_MCONFIG_H__
00027 
00028 #include <magic/mpararr.h>
00029 
00030 BEGIN_NAMESPACE (MagiC);
00031 
00033 //                                                                          //
00034 //                        ___                 o                             //
00035 //                       /   \        _    __                               //
00036 //                       |      __  |/ \  /   |  ___                        //
00037 //                       |     /  \ |   | +-- | (   \                       //
00038 //                       \___/ \__/ |   | |   |  ---/                       //
00039 //                                        |      __/                        //
00041 
00044 class Config : public Object {
00045   public:
00046 
00047     struct KeyValuePair {
00048         String  key;
00049         String  value;
00050     };
00051 
00052     class Section : public Object {
00053       public:
00054         Section (const String& name);
00055         Section ();
00056         virtual ~Section    ();
00057         
00058       private:
00059         Array<StringKeyValue> mFields;
00060     };
00061 
00062   public:
00063 
00064                     Config (const String& filename);
00065                     Config ();
00066     virtual         ~Config ();
00067     virtual int     load    (const String& filename);
00068     virtual int     save    (const String& filename="");
00069 
00070     int             newSection  (const String& name);
00071     int             set         (const String& section, const String& key, const String& value);
00072 
00073     const Section&  operator[]  (uint pos) const;
00074     Section&        operator[]  (uint pos);
00075     const Section&  operator[]  (const String& key) const;
00076     Section&        operator[]  (const String& key);
00077     
00078   private:
00079     String          mFilename;
00080     Array<Section>  mSections;
00081     
00082   private:
00083     Config (const Config& other) {}
00084     operator= (const Config& other) {}
00085 };
00086 
00087 END_NAMESPACE;
00088 
00089 #endif
00090 

Generated on Thu Feb 10 20:06:41 2005 for LibMagiC by doxygen1.2.18