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


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

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


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

示例1: interpolateFrame

void AnimationBuilder::interpolateFrame(ParamsFile &pnew, int frameno)
{
	for(auto itP = A.begin(); itP != A.end(); itP ++){
		if((*itP).second.lastSetIndex >= (*itP).second.F.size() - 1){
			continue;
		}

		int nextFrameIndex = (*itP).second.lastSetIndex + 1;
		KeyFrame nextFrame = (*itP).second.F[nextFrameIndex];

		if(nextFrame.frameno == frameno){
			*((*itP).second.jsonPtr) = nextFrame.val;

			(*itP).second.lastSetIndex = nextFrameIndex;
		}else if(nextFrame.interp != "none"){
			int fi = (*itP).second.F[(*itP).second.lastSetIndex].frameno;
			int ff = nextFrame.frameno;
			Json::Value i = (*itP).second.F[(*itP).second.lastSetIndex].val;
			Json::Value f = nextFrame.val;

			if((*itP).second.pType == SVT_INT){
				*((*itP).second.jsonPtr) =
					animationInterpolate(nextFrame.interp, frameno, fi, ff, i.asInt(), f.asInt());
			}else if((*itP).second.pType == SVT_REAL){
				*((*itP).second.jsonPtr) =
					animationInterpolate(nextFrame.interp, frameno, fi, ff, i.asDouble(), f.asDouble());
			}else if((*itP).second.pType == SVT_COLOR){
				Json::Value arr = Json::Value(Json::ValueType::arrayValue);
				arr.resize(3);
				arr[0] = animationInterpolate(nextFrame.interp, frameno, fi, ff,
							i[0].asDouble(), f[0].asDouble());
				arr[1] = animationInterpolate(nextFrame.interp, frameno, fi, ff,
							i[1].asInt(), f[1].asInt());
				arr[2] = animationInterpolate(nextFrame.interp, frameno, fi, ff,
							i[2].asInt(), f[2].asInt());
				*((*itP).second.jsonPtr) = arr;
			}else if((*itP).second.pType == SVT_COMPLEX){
				std::complex<double> zi = getComplexValueFromString(i.asString());
				std::complex<double> zf = getComplexValueFromString(f.asString());
				std::complex<double> z = animationInterpolate(nextFrame.interp, frameno, fi, ff, zi, zf);
				std::string res = concat("", z.real()) + concat("+", z.imag()) + "i";
				*((*itP).second.jsonPtr) = res;
			}
		}
	}
}
开发者ID:jeffreysanti,项目名称:JSFractalEngine,代码行数:46,代码来源:AnimationBuilder.cpp

示例2: readInt

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

示例3: decode_from_json_object

void GetBuyedListRequest::decode_from_json_object(const Json::Value &root)
{
    Json::Value tmp;

    
    if ( root.isObject() && root.isMember("data") ) {
        tmp = root["data"];
        if ( !tmp.isNull() )
        {
            data.decode_from_json_object(tmp);
        }
    }

    
    if ( root.isObject() && root.isMember("status") ) {
        tmp = root["status"];
        if ( !tmp.isNull() )
        {
            status = tmp.asInt();
        }
    }

    
    if ( root.isObject() && root.isMember("total") ) {
        tmp = root["total"];
        if ( !tmp.isNull() )
        {
            total = tmp.asInt();
        }
    }

    
    if ( root.isObject() && root.isMember("errMsg") ) {
        tmp = root["errMsg"];
        if ( !tmp.isNull() )
        {
            errMsg = tmp.asString();
        }
    }

    
    
    
    
}
开发者ID:YouLooksLikeNotDelicious,项目名称:websrv,代码行数:45,代码来源:Request.cpp

示例4: Deserialize

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

示例5: getUserID

int Response::getUserID() const {
    try {
        Json::Value json = root["result"][0U]["value"];
        return json.asInt();
    } catch (...) {
        return ERROR;
    }
    return ERROR;
}
开发者ID:longruiliu,项目名称:ECR,代码行数:9,代码来源:protocol.cpp

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

示例7: leer_datos_iniciales

void leer_datos_iniciales(int &ancho, int &alto, std::string &ip, int &puerto){
  Json::Value datos;
  Json::Value aux;
  Json::Reader reader;
  
  std::string configuracion = CONFIG;
  std::ifstream archivo_datos(configuracion.c_str(), std::ifstream::binary | std::ifstream::in);
  reader.parse(archivo_datos, datos, false);
  
  aux = datos.get("ancho", aux);
  ancho = aux.asInt();
  aux = datos.get("alto", aux);
  alto = aux.asInt();
  aux = datos.get("ip", aux);
  ip = aux.asString();
  aux = datos.get("puerto", aux);
  puerto = aux.asInt();
}
开发者ID:debmartin,项目名称:log-horizon,代码行数:18,代码来源:main.cpp

示例8: getnetworkhashps

		int getnetworkhashps(){
			string command="getnetworkhashps()";
			Json::Value params;
			Json::Value result;
			//params.append(account);
			result=this->sendcommand(command,params);
			int hashps=result.asInt();
			return hashps;
		}
开发者ID:mmgrant73,项目名称:bitcoinapi,代码行数:9,代码来源:litecoin1.cpp

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

示例10: GetInt32

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

示例11: JSON_Type2Type

bool JSON_Type2Type(const Json::Value &subNode, int &value)
{
	if (Json::intValue == subNode.type())
	{
		value = subNode.asInt();
		return true;
	}
	ASSERT_C(false);
	return false;
}
开发者ID:huangjunfeng2000,项目名称:ZeroMQ,代码行数:10,代码来源:jsonAPI.cpp

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

示例13: GetIntFromJsonValue

int Utils::GetIntFromJsonValue(Json::Value &value, int defaultValue) {
    int res = defaultValue;

    // some json responses have ints formated as strings
    if (value.isString())
        res = StringToInt(value.asString());
    else if (value.isInt())
        res = value.asInt();

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

示例14: switch

static void
printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." )
{
   switch ( value.type() )
   {
   case Json::nullValue:
      fprintf( fout, "%s=null\n", path.c_str() );
      break;
   case Json::intValue:
      fprintf( fout, "%s=%ld\n", path.c_str(), value.asInt() );
      break;
   case Json::uintValue:
      fprintf( fout, "%s=%lu\n", path.c_str(), value.asUInt() );
      break;
   case Json::realValue:
      fprintf( fout, "%s=%.16g\n", path.c_str(), value.asDouble() );
      break;
   case Json::stringValue:
      fprintf( fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str() );
      break;
   case Json::booleanValue:
      fprintf( fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" );
      break;
   case Json::arrayValue:
      {
         fprintf( fout, "%s=[]\n", path.c_str() );
         int size = value.size();
         for ( int index =0; index < size; ++index )
         {
            static char buffer[16];
            sprintf( buffer, "[%d]", index );
            printValueTree( fout, value[index], path + buffer );
         }
      }
      break;
   case Json::objectValue:
      {
         fprintf( fout, "%s={}\n", path.c_str() );
         Json::Value::Members members( value.getMemberNames() );
         std::sort( members.begin(), members.end() );
         std::string suffix = *(path.end()-1) == '.' ? "" : ".";
         for ( Json::Value::Members::iterator it = members.begin(); 
               it != members.end(); 
               ++it )
         {
            const std::string &name = *it;
            printValueTree( fout, value[name], path + suffix + name );
         }
      }
      break;
   default:
      break;
   }
}
开发者ID:tuita,项目名称:DOMQ,代码行数:54,代码来源:main.cpp

示例15: getParamVal

int getParamVal(std::string param, Json::Value const& item, int defvalue) {
  Json::Value nnType = item[param];
  if (!nnType.empty())
  {
    int n = nnType.asInt();
    console->info("{0}={1}", param, n);
    return n;
  }
  else  
    return  defvalue;
  }
开发者ID:theSundayProgrammer,项目名称:Camerasp,代码行数:11,代码来源:parseCmd.cpp


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