UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IniFile.hpp
1 /* IniFile.hpp */
2 /* $Id: IniFile.hpp,v 1.4 2007/11/08 11:19:43 vlad Exp $ */
3 #ifndef __IniFile_hpp
4 #define __IniFile_hpp
5 
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <mix/IniSection.hpp>
9 
10 
11 typedef IniSection* IniSectionPtr;
12 #define PtrType IniSectionPtr
13 #define PtrAr IniSectionsAr
14 #include <mix/PtrAr.H>
15 
16 
37 class IniFile
38 {
39 public:/* types */
40 
41  enum LoadMode {
46  };
47 
48 public:/* methods */
49 
51  IniFile ();
52 
55  IniFile (const char* path);
56 
59  virtual ~IniFile ();
60 
61  /*
62  * Operating with file
63  */
64 
66  virtual void set_path (const char* path);
67 
70  virtual void save () const;
71 
73  virtual void save (const char* path) const;
74 
81  virtual void load (const char* path, LoadMode mode = Overwrite,
83 
86  virtual void reload ();
87 
88  /*
89  * Accessing sections
90  */
91 
96  virtual const IniSection& get (const char* type,
97  const char* name = "") const;
98 
99 
101  const IniSection& operator() (const char* type,
102  const char* name = "") const {
103  return get(type, name);
104  };
105 
106 
111  virtual IniSection& fetch (const char* type,
112  const char* name = "");
113 
114 
116  IniSection& operator[] (const char* type) {
117  return fetch(type);
118  };
119 
120 
121  /*
122  * Operating over sections
123  */
124 
127  virtual IniSection* add_section (const char* type,
128  const char* name = "");
129 
133  virtual void remove_section (const char* type,
134  const char* name = "");
135 
138  virtual char** get_list_of_types (int& n) const;
139 
142  virtual char** get_list_of_names (const char* type,
143  int& n) const;
144 
145 protected:/* methods */
146 
150  int tn2i (const char* type,
151  const char* name) const;
152 
153 protected:/* data */
154 
156  char *ini_path;
157 
160  struct stat stat_buf;
161 
163  IniSectionsAr isar;
164 
165 };
166 
167 
168 
169 #endif /* IniFile.hpp */
Definition: IniFile.hpp:45
Class for operating with one section of ini-file.
Definition: IniSection.hpp:43
Definition: IniFile.hpp:44
int tn2i(const char *type, const char *name) const
MergeMode
Definition: IniSection.hpp:204
Definition: IniFile.hpp:43
virtual void remove_section(const char *type, const char *name="")
struct stat stat_buf
Definition: IniFile.hpp:160
LoadMode
Definition: IniFile.hpp:41
virtual void load(const char *path, LoadMode mode=Overwrite, IniSection::MergeMode mmode=IniSection::AppendAll)
IniSectionsAr isar
Definition: IniFile.hpp:163
const IniSection & operator()(const char *type, const char *name="") const
Definition: IniFile.hpp:101
IniSection & operator[](const char *type)
Definition: IniFile.hpp:116
virtual char ** get_list_of_names(const char *type, int &n) const
virtual char ** get_list_of_types(int &n) const
Definition: IniSection.hpp:205
Definition: IniFile.hpp:42
virtual void save() const
virtual IniSection * add_section(const char *type, const char *name="")
virtual ~IniFile()
virtual void reload()
virtual void set_path(const char *path)
virtual IniSection & fetch(const char *type, const char *name="")
char * ini_path
Definition: IniFile.hpp:156
Class for operating with ini-file which contains sections.
Definition: IniFile.hpp:37