本文整理汇总了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;
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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() );
}
示例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;
}
示例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() );
}
}
示例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;
}
示例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);
}
}
示例14:
bool QSanProtocol::Utils::tryParse(const Json::Value &arg, bool &result) {
if (!arg.isBool()) return false;
result = arg.asBool();
return true;
}
示例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);
}
}