upgraded codes because Map
This commit is contained in:
parent
9f94d5082b
commit
f4d19fc898
@ -16,7 +16,7 @@ namespace hgl
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
using AttrsMap=Map<UTF8String,UTF8String>;
|
using AttrsMap=Map<UTF8String,UTF8String>;
|
||||||
using AttrItem=Pair<UTF8String,UTF8String>;
|
using AttrItem=KeyValue<UTF8String,UTF8String>;
|
||||||
|
|
||||||
AttrsMap attrs_map;
|
AttrsMap attrs_map;
|
||||||
|
|
||||||
@ -24,9 +24,9 @@ namespace hgl
|
|||||||
|
|
||||||
const AttrItem *GetAttrItem(const UTF8String &name);
|
const AttrItem *GetAttrItem(const UTF8String &name);
|
||||||
|
|
||||||
template<typename T> const bool GetInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stoi(ai->right.c_str(),value):false);}
|
template<typename T> const bool GetInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stoi(ai->value.c_str(),value):false);}
|
||||||
template<typename T> const bool GetUInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stou(ai->right.c_str(),value):false);}
|
template<typename T> const bool GetUInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stou(ai->value.c_str(),value):false);}
|
||||||
template<typename T> const bool GetFloat (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stof(ai->right.c_str(),value):false);}
|
template<typename T> const bool GetFloat (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stof(ai->value.c_str(),value):false);}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ namespace hgl
|
|||||||
|
|
||||||
const bool IsExist (const UTF8String &name)const{return attrs_map.KeyExist(name);}
|
const bool IsExist (const UTF8String &name)const{return attrs_map.KeyExist(name);}
|
||||||
|
|
||||||
const u8char * ToCString (const UTF8String &name){const AttrItem *ai=GetAttrItem(name);return(ai?ai->right.c_str():nullptr);}
|
const u8char * ToCString (const UTF8String &name){const AttrItem *ai=GetAttrItem(name);return(ai?ai->value.c_str():nullptr);}
|
||||||
const u8char * operator[] (const UTF8String &name){return ToCString(name);}
|
const u8char * operator[] (const UTF8String &name){return ToCString(name);}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -25,7 +25,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(!ai)return(false);
|
if(!ai)return(false);
|
||||||
|
|
||||||
str=ai->right;
|
str=ai->value;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(!ai)return(false);
|
if(!ai)return(false);
|
||||||
|
|
||||||
str=to_u16(ai->right);
|
str=to_u16(ai->value);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(!ai)return(false);
|
if(!ai)return(false);
|
||||||
|
|
||||||
ch=ai->right.GetFirstChar();
|
ch=ai->value.GetFirstChar();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
const AttrItem *ai=GetAttrItem(name);
|
const AttrItem *ai=GetAttrItem(name);
|
||||||
|
|
||||||
return(ai?stob<char>(ai->right.c_str(),value):false);
|
return(ai?stob<char>(ai->value.c_str(),value):false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool ElementParseKV::GetHexStr(const UTF8String &name,uint8 *data)
|
const bool ElementParseKV::GetHexStr(const UTF8String &name,uint8 *data)
|
||||||
@ -62,7 +62,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(!ai)return(false);
|
if(!ai)return(false);
|
||||||
|
|
||||||
ParseHexStr(data,ai->right.c_str(),ai->right.Length());
|
ParseHexStr(data,ai->value.c_str(),ai->value.Length());
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
}//namespace xml
|
}//namespace xml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user