UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IniSection.hpp
1 /* IniSection.hpp */
2 /* $Id: IniSection.hpp,v 1.5 2005/10/27 07:00:46 vlad Exp $ */
3 #ifndef __IniSection_hpp
4 #define __IniSection_hpp
5 
6 #include <mix/misc.h>
7 #include <mix/Exceptions.h>
8 
9 
44 {
45 public:
46 
48  IniSection (const char* szSectionType,
49  const char* szSectionName);
50 
54  IniSection (const char* szTextBlock);
55 
57  IniSection (const IniSection& ini_sect);
58 
59 
61  virtual ~IniSection ();
62 
64  const char* get_section_type () const;
65 
67  const char* get_section_name () const;
68 
71  void set_section_name (const char* name);
72 
76  virtual char* make_text () const;
77 
83  virtual void parse_text (const char* text,
84  int** err_lines = NULL);
85 
86  /*
87  * Methods of accessing (NAME, VALUE) pairs
88  */
89 
90  /* Iteration through all pairs */
91 
93  virtual int count () const;
94 
97  virtual const OptionItem* get (int i) const;
98 
101  const OptionItem& operator() (int i) const;
102 
105  virtual OptionItem* fetch (int i);
106 
109  OptionItem& operator[] (int i);
110 
111 
115  virtual int n2i (const char* name,
116  int start_index = 0) const;
117 
120  virtual void remove (int i);
121 
122 
123  /* Associative search by name. The last encountered name is
124  referred! */
125 
128  virtual const char* get_value (const char* name) const;
129 
132  int get_int_value (const char* name,
133  int def_value = 0) const;
134 
135 #ifdef CompilerIs64bitReady
136 
139  long long get_int8_value (const char* name,
140  long long def_value = 0LL) const;
141 #endif /* CompilerIs64bitReady */
142 
146  double get_double_value (const char* name,
147  double def_value = 0.0) const;
148 
150  const char* operator() (const char* name) const;
151 
154  virtual char* fetch_value (const char* name);
155 
157  char* operator[] (const char* name);
158 
159 
160  /* Fetching multiple entries which names started with the same root
161  word (matching word*) */
162 
166  virtual OptionItem** match (const char* word);
167 
168 
169  /*
170  * Adding more pairs (NAME, VALUE)
171  */
172 
174  virtual void add (const char* name, const char* value);
175 
177  void add (const char* name, int v);
178 
179 #ifdef CompilerIs64bitReady
180 
181  void add (const char* name, long long v);
182 #endif /* CompilerIs64bitReady */
183 
185  void add (const char* name, double v);
186 
187 
190  virtual void put (const char* name, const char* value);
191 
193  void put (const char* name, int v);
194 
195 #ifdef CompilerIs64bitReady
196 
197  void put (const char* name, long long v);
198 #endif /* CompilerIs64bitReady */
199 
201  void put (const char* name, double v);
202 
203 
204  enum MergeMode {
209  };
210 
212  void merge (const IniSection& ini_sect,
213  MergeMode mode = AppendAll);
214 
215 protected:
216 
219 
222 
225 
226 };
227 
228 
229 inline const OptionItem&
231 {
232  const OptionItem *oi = get(i);
233  if(NULL == oi)
234  Throw(ERROR__OUT_OF_RANGE);
235  return *oi;
236 }
237 
238 inline const char*
239 IniSection::operator() (const char* name) const
240 {
241  return get_value(name);
242 }
243 
244 inline OptionItem&
246 {
247  OptionItem *oi = fetch(i);
248  if(NULL == oi)
249  Throw(ERROR__OUT_OF_RANGE);
250  return *oi;
251 }
252 
253 inline char*
254 IniSection::operator[] (const char* name)
255 {
256  return fetch_value(name);
257 }
258 
259 
260 #endif /* IniSection.hpp */
OptionBase ob
Definition: IniSection.hpp:218
void set_section_name(const char *name)
Class for operating with one section of ini-file.
Definition: IniSection.hpp:43
virtual int count() const
virtual char * fetch_value(const char *name)
Definition: IniSection.hpp:208
Definition: misc.h:363
MergeMode
Definition: IniSection.hpp:204
virtual const char * get_value(const char *name) const
virtual ~IniSection()
virtual void put(const char *name, const char *value)
virtual int n2i(const char *name, int start_index=0) const
char * section_name
Definition: IniSection.hpp:224
char * section_type
Definition: IniSection.hpp:221
virtual void add(const char *name, const char *value)
const char * get_section_name() const
Definition: IniSection.hpp:205
Definition: IniSection.hpp:207
int get_int_value(const char *name, int def_value=0) const
const char * get_section_type() const
Definition: misc.h:356
virtual OptionItem ** match(const char *word)
OptionItem & operator[](int i)
Definition: IniSection.hpp:245
virtual char * make_text() const
void merge(const IniSection &ini_sect, MergeMode mode=AppendAll)
const OptionItem & operator()(int i) const
Definition: IniSection.hpp:230
Definition: IniSection.hpp:206
virtual OptionItem * fetch(int i)
double get_double_value(const char *name, double def_value=0.0) const
IniSection(const char *szSectionType, const char *szSectionName)
virtual void parse_text(const char *text, int **err_lines=NULL)