Add support to bool type

Add the bool support to the get function
This commit is contained in:
pxli168 2013-12-31 12:53:31 +08:00
parent 2d5723ccca
commit 203a9acdbc

View File

@ -41,6 +41,8 @@ static String get_type_name(int type)
{ {
if( type == Param::INT ) if( type == Param::INT )
return "int"; return "int";
if( type == Param::BOOLEAN )
return "bool";
if( type == Param::UNSIGNED_INT ) if( type == Param::UNSIGNED_INT )
return "unsigned"; return "unsigned";
if( type == Param::UINT64 ) if( type == Param::UINT64 )
@ -59,6 +61,13 @@ static void from_str(const String& str, int type, void* dst)
std::stringstream ss(str.c_str()); std::stringstream ss(str.c_str());
if( type == Param::INT ) if( type == Param::INT )
ss >> *(int*)dst; ss >> *(int*)dst;
else if( type == Param::BOOLEAN )
{
std::string temp;
ss >> temp;
if( !temp.compare("true") ) *(bool*)dst = true;
else *(bool*)dst = false;
}
else if( type == Param::UNSIGNED_INT ) else if( type == Param::UNSIGNED_INT )
ss >> *(unsigned*)dst; ss >> *(unsigned*)dst;
else if( type == Param::UINT64 ) else if( type == Param::UINT64 )