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


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

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


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

示例1: isSyncing

bool BlockChain::isSyncing()
{
    Json::Value result = _provider.request("eth_isSyncing");
    if(result.isBool())
    {
        return result.asBool();
    }
    return true;
}
开发者ID:BitProfile,项目名称:libethrpc,代码行数:9,代码来源:BlockChain.cpp

示例2: 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

示例3: GetBool

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

示例4:

bool ConfigFile::is_data_shared_1(std::string package) {
    const Json::Value sharedata =
            m_root[CONF_PACKAGES][package][CONF_SHARE_DATA];

    if (!sharedata.isNull() && !sharedata.isBool()) {
        return sharedata.asBool();
    }

    return false;
}
开发者ID:Kratos1982,项目名称:DualBootPatcher,代码行数:10,代码来源:configfile.cpp

示例5: GetJsonInt

int GetJsonInt(const Json::Value& _jsValue)
{
	if ( _jsValue.type() == Json::intValue)
		return _jsValue.asInt();
	else if (_jsValue.type() == Json::stringValue)
		return atoi(_jsValue.asCString());
	else if (_jsValue.isBool())
		return (int)_jsValue.asBool();
	return 0;
}
开发者ID:zjjfhqpl,项目名称:SDLib,代码行数:10,代码来源:CJsonParse.cpp

示例6: asBool

    bool JsonUtils::asBool(const Json::Value &value, bool defaultValue)
    {
        bool returned = defaultValue;

        if(value.isString())
            returned = Ogre::StringConverter::parseBool(value.asString(), defaultValue);

        if(value.isBool())
            returned = value.asBool();

        return returned;
    }
开发者ID:onze,项目名称:Steel,代码行数:12,代码来源:JsonUtils.cpp

示例7: isEnabled

//------------------------------------------------------------------------------
bool WidgetHints::isEnabled(const std::string &name) const
{
  Json::Value value = this->Internals->findValue(name + "/enabled");

  if (value.isBool())
    {
    return value.asBool();
    }

  // True by default:
  return true;
}
开发者ID:VruiVTK,项目名称:MooseViewer,代码行数:13,代码来源:WidgetHints.cpp

示例8: onDeserialize

 void SpriteRenderer::onDeserialize( const std::string& property, const Json::Value& root )
 {
     if( property == "Texture" && root.isString() )
         setTexture( Assets::use().getTexture( root.asString() ) );
     else if( property == "Size" && root.isArray() && root.size() == 2 )
     {
         setSize( sf::Vector2f(
             (float)root[ 0u ].asDouble(),
             (float)root[ 1u ].asDouble()
         ) );
     }
     else if( property == "Origin" && root.isArray() && root.size() == 2 )
     {
         setOrigin( sf::Vector2f(
             (float)root[ 0u ].asDouble(),
             (float)root[ 1u ].asDouble()
         ) );
     }
     else if( property == "OriginPercent" && root.isArray() && root.size() == 2 )
     {
         setOriginPercent( sf::Vector2f(
             (float)root[ 0u ].asDouble(),
             (float)root[ 1u ].asDouble()
         ) );
     }
     else if( property == "Color" && root.isArray() && root.size() == 4 )
     {
         setColor( sf::Color(
             root[ 0u ].asUInt(),
             root[ 1u ].asUInt(),
             root[ 2u ].asUInt(),
             root[ 3u ].asUInt()
         ) );
     }
     else if( property == "RenderStates" && root.isObject() )
     {
         Json::Value blendMode = root[ "blendMode" ];
         if( blendMode.isString() )
             m_renderStates.blendMode = Serialized::deserializeCustom< sf::BlendMode >( "BlendMode", blendMode );
         Json::Value shader = root[ "shader" ];
         if( shader.isString() )
             m_renderStates.shader = Assets::use().getShader( shader.asString() );
     }
     else if( property == "Material" && root.isObject() )
         m_material.deserialize( root );
     else if( property == "MaterialValidation" && root.isBool() )
         m_materialValidation = root.asBool();
     else
         Component::onDeserialize( property, root );
 }
开发者ID:PsichiX,项目名称:Ptakopysk,代码行数:50,代码来源:SpriteRenderer.cpp

示例9:

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

示例10: deserialize

bool deserialize(const Json::Value& node, bool& b)
{
	if (node.empty())
	{
		std::cout << "Node is empty." << std::endl;
		return false;
	}
	if (!node.isBool())
	{
		std::cout << "Node data type is not boolean." << std::endl;
		return false;
	}
	b = node.asBool();
	return true;
}
开发者ID:redagito,项目名称:RayTracer,代码行数:15,代码来源:JsonDeserialize.cpp

示例11: 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

示例12: getVehicleData

bool VehicleInfo::getVehicleData(Json::Value &message,Json::Value &result)
{
    Json::Value vehicle;
    Json::Value data;
    Json::Value params;
    bool ret = false;

    params = message["params"];

    vehicle = g_VehicleInfoJson["vehicle"];

    Json::Value::Members mem = params.getMemberNames();
    for (Json::Value::Members::iterator iter = mem.begin(); iter != mem.end(); iter++) {
        std::string infoitem = std::string(*iter);
        if (infoitem != "appID" && infoitem != "request") {
            Json::Value require = params[infoitem];
            if (!require.isBool())
                continue;
            if (!require.asBool())
                continue;

            if (vehicle.isMember(infoitem))
                data[infoitem] = vehicle[infoitem];
            ret = true;
        }
    }

    if (ret) {
        Json::Value::Members mem = data.getMemberNames();
        for (Json::Value::Members::iterator iter = mem.begin(); iter != mem.end(); iter++) {
            std::string infoitem = std::string(*iter);
            result[infoitem] = data[infoitem];
        }

        result["code"] = 0;
        result["method"] = "VehicleInfo.GetVehicleData";
    } else {
        result["message"] = "Params rpc, are not avaliable";
        result["code"] = 9;
        result["method"]="VehicleInfo.GetVehicleData";
    }

    return ret;
}
开发者ID:APCVSRepo,项目名称:hmi_sdk,代码行数:44,代码来源:VehicleInfo.cpp

示例13: pushValue

 void LuaModule::pushValue(const Json::Value &val, lua_State * stack) {
     if (val.isIntegral()) {
         lua_pushinteger(stack, val.asInt());
     } else if (val.isDouble()) {
         lua_pushnumber(stack, val.asDouble());
     } else if (val.isBool()) {
         lua_pushboolean(stack, val.asBool());
     } else if (val.isString()) {
         lua_pushstring(stack, val.asString().c_str());
     } else if (val.isNull()) {
         //lua_pushstring(stack, val.asString().c_str());
         lua_pushnil(stack);
     } else {
         lua_pop(stack, 1);
         std::stringstream ss;
         ss << val.type();
         std::string typeNum;
         ss >> typeNum;
         throw std::runtime_error("Value type error: value of type " + typeNum);
     }
 }
开发者ID:achernakov,项目名称:flugegeheimen,代码行数:21,代码来源:LuaModule.cpp

示例14:

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

示例15: PushJson

  void LuaContext::PushJson(const Json::Value& value)
  {
    if (value.isString())
    {
      const std::string s = value.asString();
      lua_pushlstring(lua_, s.c_str(), s.size());
    }
    else if (value.isDouble())
    {
      lua_pushnumber(lua_, value.asDouble());
    }
    else if (value.isInt())
    {
      lua_pushinteger(lua_, value.asInt());
    }
    else if (value.isUInt())
    {
      lua_pushinteger(lua_, value.asUInt());
    }
    else if (value.isBool())
    {
      lua_pushboolean(lua_, value.asBool());
    }
    else if (value.isNull())
    {
      lua_pushnil(lua_);
    }
    else if (value.isArray())
    {
      lua_newtable(lua_);

      // http://lua-users.org/wiki/SimpleLuaApiExample
      for (Json::Value::ArrayIndex i = 0; i < value.size(); i++)
      {
        // Push the table index (note the "+1" because of Lua conventions)
        lua_pushnumber(lua_, i + 1);

        // Push the value of the cell
        PushJson(value[i]);

        // Stores the pair in the table
        lua_rawset(lua_, -3);
      }
    }
    else if (value.isObject())
    {
      lua_newtable(lua_);

      Json::Value::Members members = value.getMemberNames();

      for (Json::Value::Members::const_iterator 
             it = members.begin(); it != members.end(); ++it)
      {
        // Push the index of the cell
        lua_pushlstring(lua_, it->c_str(), it->size());

        // Push the value of the cell
        PushJson(value[*it]);

        // Stores the pair in the table
        lua_rawset(lua_, -3);
      }
    }
    else
    {
      throw OrthancException(ErrorCode_JsonToLuaTable);
    }
  }
开发者ID:151706061,项目名称:OrthancMirror,代码行数:68,代码来源:LuaContext.cpp


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