65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
#ifndef _CONFIG_H_
|
|
#define _CONFIG_H_
|
|
|
|
#include "list.h"
|
|
|
|
class Config {
|
|
public:
|
|
~Config();
|
|
|
|
bool parseFile(const char* name);
|
|
void show() const;
|
|
|
|
const char* getParameter(const char* section, const char* name) const;
|
|
const char* getString(const char* section, const char* name, char* def) const;
|
|
int getInteger(const char* section, const char* name, int def) const;
|
|
|
|
Iterator<char>* createIterator(const char* section, const char* name);
|
|
|
|
private:
|
|
class Tupel {
|
|
public:
|
|
Tupel(const char* name, const char* value);
|
|
~Tupel();
|
|
|
|
const char* name;
|
|
const char* value;
|
|
};
|
|
|
|
class Section {
|
|
public:
|
|
class SectionIterator : public Iterator<char> {
|
|
public:
|
|
SectionIterator(Section* section, const char* name);
|
|
~SectionIterator();
|
|
bool hasNext();
|
|
char* next();
|
|
void reset();
|
|
|
|
private:
|
|
Iterator<Tupel>* it;
|
|
Tupel* nexttup;
|
|
const char* name;
|
|
};
|
|
|
|
Section(const char* name);
|
|
~Section();
|
|
|
|
bool addTupel(const char* name, const char* option);
|
|
const char* getTupelValue(const char* name) const;
|
|
void show() const;
|
|
|
|
const char* name;
|
|
|
|
private:
|
|
List<Tupel> tupelList;
|
|
};
|
|
|
|
Section* addSection(const char* name);
|
|
Section* getSection(const char* name) const;
|
|
|
|
List<Section> sectionList;
|
|
};
|
|
|
|
#endif // _CONFIG_H_
|