class Value
{
std::string value;
int type;
int block;
public:
Value* next;
Value();
void set(std::string str, int bl, int key = TYPE_VARIABLE);
std::string& get();
const TCHAR* sget();
int is_keyword();
int is_block();
int get_block_id();
int get_type();
};
class Config
{
std::ifstream file;
TCHAR delimiter;
int vcol;
Value* svalue, *vstart;
int open_config_file(const TCHAR* name);
int close_config_file();
int read_config_file();
void S_trunc(std::string& str);
int search_block(const TCHAR* block);
const TCHAR* search_value(int col);
public:
Config();
Config(const TCHAR* name, int col = 1);
Config(TCHAR delim, int col = 1);
Config(const TCHAR* name, TCHAR delim, int col = 1);
int init(const TCHAR* name, TCHAR delim, int col);
~Config();
const TCHAR* value(const TCHAR* name, int col = 1);
const TCHAR* value(const TCHAR* block, const TCHAR* name, int col = 1);
const TCHAR* operator()(const TCHAR* name, int col = 1);
const TCHAR* operator()(const TCHAR* block, const TCHAR* name, int col = 1);
const TCHAR* _ivalue(const TCHAR* block, const TCHAR* name, int index, int col);
const TCHAR* ivalue(int index, int col = 1);
const TCHAR* ivalue(const TCHAR* block, int index, int col = 1);
const TCHAR* ivalue(const TCHAR* block, const TCHAR* name, int index, int col = 1);
const TCHAR* keyword(int index);
};
cpp文件
//////////////////////////////////////////////////////////////////////////
//Config System
//////////////////////////////////////////////////////////////////////////
int S_count(const std::string& s, TCHAR c);
Value::Value(void)
{
next = 0;
type = TYPE_EMPTY;
}
void Value::set(std::string str, int bl, int key /* = TYPE_VARIABLE */)
{
value = str;
type = key;
block = bl;
}