Initial commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef INIParserH
|
||||
#define INIParserH
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
using namespace std;
|
||||
|
||||
//INI文件结点存储结构
|
||||
class ININode
|
||||
{
|
||||
public:
|
||||
ININode(string root, string key, string value)
|
||||
{
|
||||
this->root = root;
|
||||
this->key = key;
|
||||
this->value = value;
|
||||
}
|
||||
string root;
|
||||
string key;
|
||||
string value;
|
||||
};
|
||||
|
||||
//键值对结构体
|
||||
class SubNode
|
||||
{
|
||||
public:
|
||||
void InsertElement(string key, string value)
|
||||
{
|
||||
sub_node.insert(pair<string, string>(key, value));
|
||||
}
|
||||
map<string, string> sub_node;
|
||||
};
|
||||
|
||||
//主要的INIParser类
|
||||
class INIParser
|
||||
{
|
||||
public:
|
||||
int ReadINI(string path);
|
||||
string GetValue(string root, string key);
|
||||
vector<ININode>::size_type GetSize(){return map_ini.size();}
|
||||
vector<ININode>::size_type SetValue(string root, string key, string value);
|
||||
int WriteINI(string path);
|
||||
void Clear(){map_ini.clear();}
|
||||
private:
|
||||
map<string, SubNode> map_ini;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user