99#include " hfile.h"
1010#include " hbase.h"
1111
12+ using namespace hv ;
13+
1214/* *********************************
1315# div
1416
@@ -29,8 +31,8 @@ class IniNode {
2931 INI_NODE_TYPE_DIV,
3032 INI_NODE_TYPE_SPAN,
3133 } type;
32- string label; // section|key|comment
33- string value;
34+ std:: string label; // section|key|comment
35+ std:: string value;
3436 std::list<IniNode*> children;
3537
3638 virtual ~IniNode () {
@@ -56,7 +58,7 @@ class IniNode {
5658 }
5759 }
5860
59- IniNode* Get (const string& label, Type type = INI_NODE_TYPE_KEY_VALUE) {
61+ IniNode* Get (const std:: string& label, Type type = INI_NODE_TYPE_KEY_VALUE) {
6062 for (auto pNode : children) {
6163 if (pNode->type == type && pNode->label == label) {
6264 return pNode;
@@ -71,22 +73,22 @@ class IniSection : public IniNode {
7173 IniSection () : IniNode(), section(label) {
7274 type = INI_NODE_TYPE_SECTION;
7375 }
74- string §ion;
76+ std:: string §ion;
7577};
7678
7779class IniKeyValue : public IniNode {
7880public:
7981 IniKeyValue () : IniNode(), key(label) {
8082 type = INI_NODE_TYPE_KEY_VALUE;
8183 }
82- string &key;
84+ std:: string &key;
8385};
8486
8587class IniComment : public IniNode {
8688public:
8789 IniComment () : IniNode(), comment(label) {
8890 }
89- string &comment;
91+ std:: string &comment;
9092};
9193
9294IniParser::IniParser () {
@@ -131,11 +133,9 @@ int IniParser::LoadFromMem(const char* data) {
131133 ss << data;
132134 std::string strLine;
133135 int line = 0 ;
134- string::size_type pos;
136+ std:: string::size_type pos;
135137
136- string content;
137- string comment;
138- string strDiv;
138+ std::string content, comment, strDiv;
139139 IniNode* pScopeNode = root_;
140140 IniNode* pNewNode = NULL ;
141141 while (std::getline (ss, strLine)) {
@@ -151,7 +151,7 @@ int IniParser::LoadFromMem(const char* data) {
151151 // trim_comment
152152 comment = " " ;
153153 pos = content.find_first_of (_comment);
154- if (pos != string::npos) {
154+ if (pos != std:: string::npos) {
155155 comment = content.substr (pos);
156156 content = content.substr (0 , pos);
157157 }
@@ -184,7 +184,7 @@ int IniParser::LoadFromMem(const char* data) {
184184 }
185185 } else {
186186 pos = content.find_first_of (_delim);
187- if (pos != string::npos) {
187+ if (pos != std:: string::npos) {
188188 // key-value
189189 pNewNode = new IniNode;
190190 pNewNode->type = IniNode::INI_NODE_TYPE_KEY_VALUE;
@@ -218,7 +218,7 @@ int IniParser::LoadFromMem(const char* data) {
218218 return 0 ;
219219}
220220
221- void IniParser::DumpString (IniNode* pNode, string& str) {
221+ void IniParser::DumpString (IniNode* pNode, std:: string& str) {
222222 if (pNode == NULL ) return ;
223223
224224 if (pNode->type != IniNode::INI_NODE_TYPE_SPAN) {
@@ -256,8 +256,8 @@ void IniParser::DumpString(IniNode* pNode, string& str) {
256256 }
257257}
258258
259- string IniParser::DumpString () {
260- string str;
259+ std:: string IniParser::DumpString () {
260+ std:: string str;
261261 DumpString (root_, str);
262262 return str;
263263}
@@ -267,7 +267,7 @@ int IniParser::Save() {
267267}
268268
269269int IniParser::SaveAs (const char * filepath) {
270- string str = DumpString ();
270+ std:: string str = DumpString ();
271271 if (str.length () == 0 ) {
272272 return 0 ;
273273 }
@@ -281,7 +281,7 @@ int IniParser::SaveAs(const char* filepath) {
281281 return 0 ;
282282}
283283
284- string IniParser::GetValue (const string& key, const string& section) {
284+ std:: string IniParser::GetValue (const std:: string& key, const std:: string& section) {
285285 if (root_ == NULL ) return " " ;
286286
287287 IniNode* pSection = root_;
@@ -296,7 +296,7 @@ string IniParser::GetValue(const string& key, const string& section) {
296296 return pKV->value ;
297297}
298298
299- void IniParser::SetValue (const string& key, const string& value, const string& section) {
299+ void IniParser::SetValue (const std:: string& key, const std:: string& value, const std:: string& section) {
300300 if (root_ == NULL ) {
301301 root_ = new IniNode;
302302 }
@@ -323,35 +323,34 @@ void IniParser::SetValue(const string& key, const string& value, const string& s
323323}
324324
325325template <>
326- HV_EXPORT bool IniParser::Get (const string& key, const string& section, bool defvalue) {
327- string str = GetValue (key, section);
326+ HV_EXPORT bool IniParser::Get (const std:: string& key, const std:: string& section, bool defvalue) {
327+ std:: string str = GetValue (key, section);
328328 return str.empty () ? defvalue : getboolean (str.c_str ());
329329}
330330
331331template <>
332- HV_EXPORT int IniParser::Get (const string& key, const string& section, int defvalue) {
333- string str = GetValue (key, section);
332+ HV_EXPORT int IniParser::Get (const std:: string& key, const std:: string& section, int defvalue) {
333+ std:: string str = GetValue (key, section);
334334 return str.empty () ? defvalue : atoi (str.c_str ());
335335}
336336
337337template <>
338- HV_EXPORT float IniParser::Get (const string& key, const string& section, float defvalue) {
339- string str = GetValue (key, section);
338+ HV_EXPORT float IniParser::Get (const std:: string& key, const std:: string& section, float defvalue) {
339+ std:: string str = GetValue (key, section);
340340 return str.empty () ? defvalue : atof (str.c_str ());
341341}
342342
343343template <>
344- HV_EXPORT void IniParser::Set (const string& key, const bool & value, const string& section) {
344+ HV_EXPORT void IniParser::Set (const std:: string& key, const bool & value, const std:: string& section) {
345345 SetValue (key, value ? " true" : " false" , section);
346346}
347347
348348template <>
349- HV_EXPORT void IniParser::Set (const string& key, const int & value, const string& section) {
349+ HV_EXPORT void IniParser::Set (const std:: string& key, const int & value, const std:: string& section) {
350350 SetValue (key, asprintf (" %d" , value), section);
351351}
352352
353353template <>
354- HV_EXPORT void IniParser::Set (const string& key, const float & value, const string& section) {
354+ HV_EXPORT void IniParser::Set (const std:: string& key, const float & value, const std:: string& section) {
355355 SetValue (key, asprintf (" %f" , value), section);
356356}
357-
0 commit comments