当前位置: 首页>>代码示例>>C++>>正文


C++ Value::isDouble方法代码示例

本文整理汇总了C++中json::Value::isDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::isDouble方法的具体用法?C++ Value::isDouble怎么用?C++ Value::isDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在json::Value的用法示例。


在下文中一共展示了Value::isDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: add

 static void add(
     MetadataNode&      parent,
     const std::string& name,
     const Json::Value& node
 )
 {
     if      (node.isNull())   { parent.add(name, ""); }
     else if (node.isBool())   { parent.add(name, node.asBool()); }
     else if (node.isInt())    { parent.add(name, node.asInt64()); }
     else if (node.isUInt())   { parent.add(name, node.asUInt64()); }
     else if (node.isDouble()) { parent.add(name, node.asDouble()); }
     else if (node.isString()) { parent.add(name, node.asString()); }
     else if (node.isObject())
     {
         MetadataNode object = parent.add(name);
         for (const std::string& name: node.getMemberNames())
         {
             add(object, name, node[name]);
         }
     }
     else if (node.isArray())
     {
         for (const Json::Value& item: node)
         {
             add(parent, name, item);
         }
     }
 }
开发者ID:chambbj,项目名称:PDAL,代码行数:28,代码来源:RdbReader.cpp

示例2: ToBool

 bool JsonHelper::ToBool( const Json::Value& value, bool defaultResult )
 {
     if ( value.isBool() )
     {
         return value.asBool();
     }
     if ( value.isInt() )
     {
         return (bool)value.asInt();
     }
     if ( value.isDouble() )
     {
         return (bool)value.asDouble();
     }
     if ( value.isUInt() )
     {
         return (bool)value.asUInt();
     }
     if ( value.isString() )
     {
         const std::string& str = value.asString();
         return ( str == "true" || str == "1" );
     }
     return defaultResult;
 }
开发者ID:Nelar,项目名称:ice_cream_adventure_mobile,代码行数:25,代码来源:JsonHelper.cpp

示例3: jsonToValues

Values Factory::jsonToValues(const Json::Value& values)
{
    Values outValues;

    if (values.isInt())
        outValues.emplace_back(values.asInt());
    else if (values.isDouble())
        outValues.emplace_back(values.asFloat());
    else if (values.isArray())
        for (const auto& v : values)
        {
            if (v.isInt())
                outValues.emplace_back(v.asInt());
            else if (v.isDouble())
                outValues.emplace_back(v.asFloat());
            else if (v.isArray())
                outValues.emplace_back(jsonToValues(v));
            else
                outValues.emplace_back(v.asString());
        }
    else
        outValues.emplace_back(values.asString());

    return outValues;
}
开发者ID:paperManu,项目名称:splash,代码行数:25,代码来源:factory.cpp

示例4: jsonValueToVariant

FB::variant jsonValueToVariant( Json::Value root )
{
    Json::Value def;
    if (root.isString())
        return root.asString();
    else if (root.isBool())
        return root.asBool();
    else if (root.isDouble())
        return root.asDouble();
    else if (root.isInt())
        return root.asInt();
    else if (root.isUInt())
        return root.asUInt();
    else if (root.isNull())
        return FB::FBNull();
    else if (root.isArray()) {
        FB::VariantList outList;
        for (size_t i = 0; i < root.size(); ++i) {
            outList.push_back(jsonValueToVariant(root.get(i, def)));
        }
        return outList;
    } else if (root.isObject()) {
        Json::Value::Members members = root.getMemberNames();
        FB::VariantMap outMap;
        for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
        {
            outMap[*it] = jsonValueToVariant(root.get(*it, def));
        }
        return outMap;
    } else {
        return FB::FBVoid();
    }
}
开发者ID:GarysRefererence2014,项目名称:FireBreath,代码行数:33,代码来源:fbjson.cpp

示例5: toBullet

btVector3 toBullet(Json::Value& jValue) {
    if(jValue.isArray()) {
        btVector3 retVal(0, 0, 0);

        Json::Value& jx = jValue[0];
        Json::Value& jy = jValue[1];
        Json::Value& jz = jValue[2];

        if(jx.isDouble()) {
            retVal.setX(jx.asDouble());
        }
        if(jy.isDouble()) {
            retVal.setY(jy.asDouble());
        }
        if(jz.isDouble()) {
            retVal.setZ(jz.asDouble());
        }

        return retVal;
    }
    if(jValue.isDouble()) {
        btDouble n = jValue.asDouble();
        return btVector3(n, n, n);
    } else {
        return btVector3(0, 0, 0);
    }
}
开发者ID:Naftoreiclag,项目名称:VS7C,代码行数:27,代码来源:ProjectCompiler.cpp

示例6: readDouble

		double readDouble(std::string key, double def)
		{
			Json::Value val = root.get(key, def);
			if (val.isDouble())
				return val.asDouble();
			else
				return def;
		}
开发者ID:Sahkopaja,项目名称:Sahkopaja,代码行数:8,代码来源:preferences.hpp

示例7: parseFromJsonToDictionary

/// 从 Json 解析数据到 dictNode 中
static void parseFromJsonToDictionary(const Json::Value & jsonNode, CCDictionary * dictNode)
{
	Json::Value::Members members = jsonNode.getMemberNames();
	for (Json::Value::Members::iterator beg = members.begin(); beg != members.end(); ++beg)
	{
        std::string name = *beg;
		Json::Value child = jsonNode[name];
		
		if (child.isArray())
		{
			CCArray * arr = CCArray::create();
			parseFromJsonToArray(child, arr);
			dictNode->setObject(arr, name);
		}
		else if (child.isObject())
		{
			CCDictionary * dict = CCDictionary::create();
			parseFromJsonToDictionary(child, dict);
			dictNode->setObject(dict, name);
		}
		else if (child.isString())
		{
			CCString * str = CCString::createWithFormat("%s", child.asCString());
			dictNode->setObject(str, name);
		}
		else if (child.isInt())
		{
			CCString * str = CCString::createWithFormat("%d", child.asInt());
			dictNode->setObject(str, name);
		}
		else if (child.isUInt())
		{
			CCString * str = CCString::createWithFormat("%u", child.asUInt());
			dictNode->setObject(str, name);
		}
		else if (child.isInt64())
		{
			CCString * str = CCString::createWithFormat("%lld", child.asInt64());
			dictNode->setObject(str, name);
			
		}
		else if (child.isUInt64())
		{
			CCString * str = CCString::createWithFormat("%llu", child.asUInt64());
			dictNode->setObject(str, name);
		}
		else if (child.isDouble())
		{
			CCString * str = CCString::createWithFormat("%f", child.asDouble());
			dictNode->setObject(str, name);
		}
		else if (child.isBool())
		{
			CCString * str = CCString::createWithFormat("%d", child.asInt());
			dictNode->setObject(str, name);
		}
	}
}
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:59,代码来源:YHJsonHelper.cpp

示例8: init

void JsonTree::init( const string &key, const Json::Value &value, bool setType, NodeType nodeType, ValueType valueType )
{
    mKey = key;
	mNodeType = nodeType;
	mParent = 0;
	mValue = "";
	mValueType = valueType;

	if( ! value.isNull() && ( value.isArray() || value.isObject() ) ) {
        if( value.isArray() ) {
            mNodeType = NODE_ARRAY;
            for ( uint32_t i = 0; i < value.size(); i++ ) {
                pushBack( JsonTree( "", value[ i ] ) );
            }
        }
		else if( value.isObject() ) {
            mNodeType = NODE_OBJECT;
            Json::Value::Members members = value.getMemberNames();
            for( Json::Value::Members::const_iterator memberIt = members.begin(); memberIt != members.end(); ++memberIt ) {
				string key = *memberIt;
                pushBack( JsonTree( key, value[ key ] ) );
            }
        }
    }
	else {
		if( value.isBool() ) {
			mValue = toString( value.asBool() );
			if( setType ) {
				mValueType = VALUE_BOOL;
			}
		}
		else if ( value.isDouble() ) { 
			mValue = toString( value.asDouble() );
			if ( setType ) {
				mValueType = VALUE_DOUBLE;
			}
		}
		else if ( value.isInt() ) { 
			mValue = toString( value.asInt() );
			if ( setType ) {
				mValueType = VALUE_INT;
			}
		}
		else if ( value.isString() ) { 
			mValue = toString( value.asString() );
			if ( setType ) {
				mValueType = VALUE_STRING;
			}
		}
		else if ( value.isUInt() ) { 
			mValue = toString( value.asUInt() );
			if ( setType ) {
				mValueType = VALUE_UINT;
			}
		}
	}
}
开发者ID:RudyOddity,项目名称:Cinder,代码行数:57,代码来源:Json.cpp

示例9: Deserialize

 bool Deserialize ( const Json::Value& json_val, float & obj_val )
 {
     if ( json_val.isDouble () )
     {
         obj_val = json_val.asFloat ();
         return true;
     }
     return false;
 }
开发者ID:2014-andy,项目名称:huststore,代码行数:9,代码来源:json_serialization.cpp

示例10: if

bool QSanProtocol::Utils::tryParse(const Json::Value &arg, double &result) {
    if (arg.isDouble())
        result = arg.asDouble();
    else if (arg.isInt())
        result = arg.asInt();
    else
        return false;
    return true;
}
开发者ID:Jia731,项目名称:QSanguosha-For-Hegemony,代码行数:9,代码来源:jsonutils.cpp

示例11: GetFloat64

bool GetFloat64(const Json::Value& value, float64_t* out) {
  if (value.isNull()) {
    return false;
  }
  if (!value.isDouble()) {
    return false;
  }
  *out = value.asDouble();
  return true;
}
开发者ID:bmteam,项目名称:blowmorph,代码行数:10,代码来源:json.cpp

示例12: GetDoubleFromJsonValue

double Utils::GetDoubleFromJsonValue(Json::Value &value, double defaultValue) {
    double res = defaultValue;

    /* some json responses have doubles formated as strings,
    or an expected double is formated as an int */
    if (value.isString())
        res = StringToDouble(value.asString());
    else if (value.isInt() || value.isDouble())
        res = value.asDouble();

    return res;
}
开发者ID:AlwinEsch,项目名称:pvr.stalker,代码行数:12,代码来源:Utils.cpp

示例13: to_uint

/***************以下函数用于读取json静态数据***************/
unsigned int to_uint(const Json::Value& val)
{
    if ( val.isIntegral() )
        return val.asUInt();

    if ( val.isDouble() )
        return (unsigned int)val.asDouble();

    if ( val.isString() )
        return strtoul(val.asCString(), NULL, 0 );

    return 0;
}
开发者ID:quinsmpang,项目名称:phone-code,代码行数:14,代码来源:jsonconfig.cpp

示例14:

void 
ValueTest::checkIs( const Json::Value &value, const IsCheck &check )
{
   JSONTEST_ASSERT_EQUAL( check.isObject_, value.isObject() );
   JSONTEST_ASSERT_EQUAL( check.isArray_, value.isArray() );
   JSONTEST_ASSERT_EQUAL( check.isBool_, value.isBool() );
   JSONTEST_ASSERT_EQUAL( check.isDouble_, value.isDouble() );
   JSONTEST_ASSERT_EQUAL( check.isInt_, value.isInt() );
   JSONTEST_ASSERT_EQUAL( check.isUInt_, value.isUInt() );
   JSONTEST_ASSERT_EQUAL( check.isIntegral_, value.isIntegral() );
   JSONTEST_ASSERT_EQUAL( check.isNumeric_, value.isNumeric() );
   JSONTEST_ASSERT_EQUAL( check.isString_, value.isString() );
   JSONTEST_ASSERT_EQUAL( check.isNull_, value.isNull() );
}
开发者ID:xylsxyls,项目名称:xueyelingshuang,代码行数:14,代码来源:main.cpp

示例15: PrintJSONValue

void util::PrintJSONValue( Json::Value val ){
	if( val.isString() ) {
		printf( "string(%s)", val.asString().c_str() ); 
	} else if( val.isBool() ) {
		printf( "bool(%d)", val.asBool() ); 
	} else if( val.isInt() ) {
		printf( "int(%d)", val.asInt() ); 
	} else if( val.isUInt() ) {
		printf( "uint(%u)", val.asUInt() ); 
	} else if( val.isDouble() ) {
		printf( "double(%f)", val.asDouble() ); 
	} else {
		printf( "unknown type=[%d]", val.type() ); 
	}
}
开发者ID:TimZaman,项目名称:toolkit,代码行数:15,代码来源:utils_jsoncpp.cpp


注:本文中的json::Value::isDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。