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


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

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


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

示例1: loadJSON

void Atom::loadJSON(const JSON::Value &value, float scale) {
    if (0 < value.size()) type = value.getString(0);
    else THROWS("Atom expected list of at least length 1");
    if (String::toUpper(type) == "UNKNOWN") type = "?";

    if (1 < value.size()) charge = (float)value.getNumber(1);
    if (2 < value.size()) radius = (float)value.getNumber(2) * scale;
    if (3 < value.size()) mass = (float)value.getNumber(3);
    if (4 < value.size()) number = (unsigned)value.getNumber(4);
    else number = numberFromName(type);

    if (!number) number = numberFromName(type);
    if (!charge) charge = chargeFromNumber(number);
    if (!radius) radius = radiusFromNumber(number);
    if (!mass) mass = massFromNumber(number);
}
开发者ID:jchodera,项目名称:fah-viewer,代码行数:16,代码来源:Atom.cpp

示例2: parseHandN

std::vector<Card> parseHandN(json::Value value) {
    std::vector<Card> hand;
    for (int i = 0; i < value.size(); ++i) {
        hand.push_back(Card{value[size_t(i)]});
    }
    std::sort(hand.begin(), hand.end());
    return hand;
}
开发者ID:r0mai,项目名称:poker-player-rainbow-dash,代码行数:8,代码来源:Hand.cpp

示例3: loadJSON

void Positions::loadJSON(const JSON::Value &value, float scale) {
  clear();

  for (unsigned i = 0; i < value.size(); i++) {
    const JSON::List &coord = value.getList(i);
    if (coord.size() != 3) THROWS("Position expected list of length 3");

    push_back(Vector3D(coord.getNumber(0), coord.getNumber(1),
                       coord.getNumber(2)) * scale);
  }

  LOG_DEBUG(3, "Read " << size() << " JSON positions");

  init();
}
开发者ID:FoldingAtHome,项目名称:fah-viewer,代码行数:15,代码来源:Positions.cpp

示例4: parseServerInfo

bool UpdateInfoFromServer::parseServerInfo(const Json::Value &serverInfo)
{
	if (serverInfo.isNull())
	{
		return false;
	}
	const Json::Value serverSubInfo = serverInfo["server"];
	if (serverInfo.isNull())
	{
		return false;
	}
	if (m_vecServerInfo.size() > 0)
	{
		m_vecServerInfo.clear();
	}
	for (int i=0; i<serverSubInfo.size(); i++) 
	{
		const Json::Value attributeInfo = serverSubInfo[i]["@attributes"];
		if (attributeInfo.isNull())
		{
			m_vecServerInfo.clear();
			return false;
		}
		else
		{
			std::string serverName = attributeInfo["ServerName"].asString();
			std::string serverIp = attributeInfo["ServerIP"].asString();
			std::string serverPort = attributeInfo["ServerPort"].asString();

			ServerInfo oneServerInfo;
			oneServerInfo.tServerName = serverName;
			oneServerInfo.tServerIp = serverIp;
			oneServerInfo.tServerPort = serverPort;

			m_vecServerInfo.push_back(oneServerInfo);
		}		
	}
	return true;
}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:39,代码来源:UpdateInfoFromServer.cpp

示例5: LoadData

void CPaperCreateData::LoadData(void)
{
    CJson jc = CJson::Load( "PaperCreate" );

    theResDataMgr.insert(this);
    resource_clear(id_papercreate_map);
    int32 count = 0;
    const Json::Value aj = jc["Array"];
    for ( uint32 i = 0; i != aj.size(); ++i)
    {
        SData *ppapercreate                  = new SData;
        ppapercreate->item_id                         = to_uint(aj[i]["item_id"]);
        ppapercreate->active_score                    = to_uint(aj[i]["active_score"]);
        ppapercreate->level_limit                     = to_uint(aj[i]["level_limit"]);
        ppapercreate->skill_type                      = to_uint(aj[i]["skill_type"]);

        Add(ppapercreate);
        ++count;
        LOG_DEBUG("item_id:%u,active_score:%u,level_limit:%u,skill_type:%u,", ppapercreate->item_id, ppapercreate->active_score, ppapercreate->level_limit, ppapercreate->skill_type);
    }
    LOG_INFO("PaperCreate.xls:%d", count);
}
开发者ID:quinsmpang,项目名称:phone-code,代码行数:22,代码来源:r_papercreatedata.cpp

示例6: getOnline

std::vector<ServerListSpec> getOnline()
{
    //不要每次都获取
    static std::vector<ServerListSpec> serverlist;
    if (serverlist.size() > 0) {
        return serverlist;
    }
    
    
	Json::Value root = fetchJsonValue((g_settings->get("serverlist_url")+"/list").c_str(),0);

	if (root.isArray()) {
		for (unsigned int i = 0; i < root.size(); i++)
		{
			if (root[i].isObject()) {
				serverlist.push_back(root[i]);
			}
		}
	}

	return serverlist;
}
开发者ID:ChuanonlyGame,项目名称:myisland,代码行数:22,代码来源:serverlist.cpp

示例7: LoadData

void CTombRewardBaseData::LoadData(void)
{
    CJson jc = CJson::Load( "TombRewardBase" );

    theResDataMgr.insert(this);
    resource_clear(id_tombrewardbase_map);
    int32 count = 0;
    const Json::Value aj = jc["Array"];
    for ( uint32 i = 0; i != aj.size(); ++i)
    {
        SData *ptombrewardbase               = new SData;
        ptombrewardbase->id                              = to_uint(aj[i]["id"]);
        ptombrewardbase->reward                          = to_uint(aj[i]["reward"]);
        ptombrewardbase->tomb_coin                       = to_uint(aj[i]["tomb_coin"]);
        ptombrewardbase->desc                            = to_str(aj[i]["desc"]);

        Add(ptombrewardbase);
        ++count;
        LOG_DEBUG("id:%u,reward:%u,tomb_coin:%u,desc:%s,", ptombrewardbase->id, ptombrewardbase->reward, ptombrewardbase->tomb_coin, ptombrewardbase->desc.c_str());
    }
    LOG_INFO("TombRewardBase.xls:%d", count);
}
开发者ID:quinsmpang,项目名称:phone-code,代码行数:22,代码来源:r_tombrewardbasedata.cpp

示例8: apParseArtistAlbums

pAlbumInfo DataManager::apParseArtistAlbums(char *pBuf, unsigned int &size)
{
    Json::Value value;
    bool ret;
    
    size = 0;
    ret = apParseErrCode((const char*)pBuf, value);
    if(ret == false)
        return (pAlbumInfo)NULL;
    
    Json::Value works;
    Json::Value album;
    unsigned int i;

    works = value["works"];
    album = works["album"];
    size = album.size();
    
    pAlbumInfo pAlbum, pHeadAlbum;
    
    pHeadAlbum = new AlbumInfo [size];
    pAlbum = pHeadAlbum;

    int len;
    for(i=0; i < size; i++)
   {
        strncpy(pAlbum->album_id, album[i]["id"].asString().c_str(), 34);
        pAlbum->album_id[35] = '\0';
        
        len = album[i]["name"].asString().size();
        //pAlbum->album_title = new char [len +1];
        if(len > 127) // ignor  the long name
            len = 127;
        strncpy(pAlbum->album_title,  album[i]["name"].asString().c_str(), len);
        pAlbum->album_title[len]='\0';
        pAlbum++;
    }
    return pHeadAlbum;
}
开发者ID:freedombird,项目名称:airp-cli,代码行数:39,代码来源:data_manager.cpp

示例9: ListTransactions

BtcTransactions BtcJsonLegacy::ListTransactions(const std::string &account, const int32_t &count, const int32_t &from, const bool &includeWatchonly)
{
    Json::Value params = Json::Value();
    params.append(account);
    params.append(count);
    params.append(from);

    Json::Value result = Json::Value();
    if(!ProcessRpcString(this->modules->btcRpc->SendRpc(CreateJsonQuery(METHOD_LISTTRANSACTIONS, params)), result))
        return BtcTransactions();     // error

    if(!result.isArray())
        return BtcTransactions();

    BtcTransactions transactions;
    for (Json::Value::ArrayIndex i = 0; i < result.size(); i++)
    {
        transactions.push_back(BtcTransactionPtr(new BtcTransaction(result[i])));
    }

    return transactions;
}
开发者ID:api-dev,项目名称:Moneychanger,代码行数:22,代码来源:btcjsonlegacy.cpp

示例10: scaleNodeActions

array_2D JSONQuadFeedbackControl::scaleNodeActions (Json::Value actions)
{
    std::size_t numControllers = actions.size();
    std::size_t numActions = actions[0].size();
    
    array_2D nodeActions(boost::extents[numControllers][numActions]);
    
    array_2D limits(boost::extents[2][numActions]);
    
    // Check if we need to update limits
    assert(numActions == 5);
    
	limits[0][0] = m_config.lowFreq;
	limits[1][0] = m_config.highFreq;
	limits[0][1] = m_config.lowAmp;
	limits[1][1] = m_config.highAmp;
    limits[0][2] = m_config.freqFeedbackMin;
    limits[1][2] = m_config.freqFeedbackMax;
    limits[0][3] = m_config.ampFeedbackMin;
    limits[1][3] = m_config.ampFeedbackMax;
    limits[0][4] = m_config.phaseFeedbackMin;
    limits[1][4] = m_config.phaseFeedbackMax;
    
    Json::Value::iterator nodeIt = actions.begin();
    
    // This one is square
    for( std::size_t i = 0; i < numControllers; i++)
    {
        Json::Value nodeParam = *nodeIt;
        for( std::size_t j = 0; j < numActions; j++)
        {
            nodeActions[i][j] = ( (nodeParam.get(j, 0.0)).asDouble() *  
                    (limits[1][j] - limits[0][j])) + limits[0][j];
        }
        nodeIt++;
    }
    
    return nodeActions;
}
开发者ID:NASA-Tensegrity-Robotics-Toolkit,项目名称:NTRTsim,代码行数:39,代码来源:JSONQuadFeedbackControl.cpp

示例11: parse_drag_planes

drag_plane_vector parse_drag_planes(const Json::Value& arr)
{
    if (!arr.isArray()) {
        throw std::runtime_error("Expected array of drag planes.");
    }

    drag_plane_vector dps;
    for (unsigned int i = 0; i < arr.size(); i++) {
        Json::Value root = arr[i];
        if (!root.isObject()) {
            throw std::runtime_error("Expected drag plane object.");
        }
        PARSE_VECTOR3(pos);
        PARSE_VECTOR3(normal);
        PARSE_DOUBLE(cD);
        PARSE_DOUBLE(area);
        drag_plane dp { pos, normal, cD, area };
        dps.push_back(dp);
    }

    return dps;
}
开发者ID:sjt85,项目名称:software,代码行数:22,代码来源:vehicle.cpp

示例12: parseInfile

//
// Parse the infile, which is either an ascii list of GTC files, or a JSON format file
// Return an array of filenames and (for a JSON file) a list of sample names
//
void parseInfile(string infile, vector<string> &sampleNames, vector<string> &infiles)
{
	Json::Value root;   // will contains the root value after parsing.
	Json::Reader reader;
	ifstream f;

	f.open(infile.c_str());
	if (infile.find(".json") != string::npos) {
		// Parse JSON file
		bool parsingSuccessful = reader.parse( f, root );
		if ( !parsingSuccessful ) throw("Could not parse json file "+infile);
		for ( unsigned int index = 0; index < root.size(); ++index ) {
			sampleNames.push_back(root[index]["uri"].asString());
			infiles.push_back(root[index]["result"].asString());
		}
	} else {
		// simple ascii text file
		string filename;
		while (f >> filename) infiles.push_back(filename);
	}
	f.close();
}
开发者ID:dkj,项目名称:simtools,代码行数:26,代码来源:simtools.cpp

示例13: UnpackValue

CString 
CConnectionManager::GetStory(Json::Value& msg)
{
	int changed = 0;
	int created = 0;
	int deleted = 0;
	int renamed = 0;
	Json::Value files = msg["files"];
	for (unsigned int i=0; i<files.size(); i++)
	{
		Json::Value file = files[i];
		CString action = UnpackValue(file["action"]);
		if (action==_T("changed")) changed++;
		if (action==_T("created")) created++;
		if (action==_T("deleted")) deleted++;
		if (action==_T("renamed")) renamed++;
	}
	
	CString fs;
	CString s[4];
	int i = 0;
	fs = FileSentence(created, _T("created"));
	if (fs.GetLength()) s[i++] = fs;
	fs = FileSentence(deleted, _T("deleted"));
	if (fs.GetLength()) s[i++] = fs;
	fs = FileSentence(changed, _T("changed"));
	if (fs.GetLength()) s[i++] = fs;
	fs = FileSentence(renamed, _T("renamed"));
	if (fs.GetLength()) s[i++] = fs;
	
	CString story;
	if (i==0) return _T("?");
	if (i==1) story.Format(_T("%s"), s[0]);
	if (i==2) story.Format(_T("%s and %s"), s[0], s[1]);
	if (i==3) story.Format(_T("%s, %s and %s"), s[0], s[1], s[2]);
	if (i==4) story.Format(_T("%s, %s, %s and %s"), s[0], s[1], s[2], s[3], s[4]);
	return story;
}
开发者ID:chzh,项目名称:xrefresh,代码行数:38,代码来源:ConnectionManager.cpp

示例14: ParseJSon

void CTransactionRecordsResultMsg::ParseJSon(const char* json)
{
    USES_CONVERSION;

    Json::Reader reader;
    Json::Value root;

    if (reader.parse(json, root))
    {
        Error = root["errcode"].asInt();
        ErrMsg = A2T(root["errmsg"].asString().c_str());

        Json::Value data = root["data"];
        InitBP = data["init_bp"].asDouble();
        BP = data["bp"].asDouble();
        ClosePL = data["close_pl"].asDouble();
        TradeFee = data["trade_fee"].asDouble();

        Json::Value stocks = data["stocks"];

        for (UINT i = 0; i < stocks.size(); i++)
        {
            Json::Value &current = stocks[i];
            CStokes* SStokes = new CStokes;
            Stokes.push_back(SStokes);

            SStokes->StockID = A2T(current["stock_id"].asString().c_str());
            SStokes->BuyVol = current["buy_vol"].asInt();
            SStokes->BuyAmount = current["buy_amount"].asDouble();
            SStokes->BuyPrice = current["buy_price"].asDouble();
            SStokes->SellVol = current["sell_vol"].asInt();
            SStokes->SellAmount = current["sell_amount"].asDouble();
            SStokes->SellPrice = current["sell_price"].asDouble();
            SStokes->ClosePL = current["close_pl"].asDouble();
            SStokes->TradeFee = current["trade_fee"].asDouble();
        }
    }
}
开发者ID:Randy090807,项目名称:Github,代码行数:38,代码来源:MsgDefine.cpp

示例15: parse_device

//
// parse_device
//   Get the devices that described in a root of json file
//
int parse_device(Json::Value &value)
{
    switch (value.type()) {
    case Json::nullValue:
        break;
    case Json::arrayValue:
    {
        // Travel the elements in array
        int size = value.size();
        for (int index = 0; index < size; ++index)
            parse_device(value[index]);        
    } break;
    case Json::objectValue:
    {
        // Create device instance according device type
        if (value[DEVICE_NAME] == Json::nullValue)
            dbg_print("WARNING: Should to specify the name for device\n");
        // Should specify a device type in json elements
        if (value[DEVICE_TYPE] == Json::nullValue) {
            printf("ERROR: Need to specify the device type for device\n");
            break;
        }

        dbg_print("INFO: Got device [%s]\n",
                  value[DEVICE_NAME].asString().c_str());
        // Create device instance according device type
        if (create_device_map[value[DEVICE_TYPE].asString()] != NULL)
            (*create_device_map[value[DEVICE_TYPE].asString()])(value);
        else
            dbg_print("INFO: Not the function to create a %s instance\n",
                      value[DEVICE_TYPE].asString().data());
    } break;
    default:
        break;
    }

    return 0;
}
开发者ID:Jakebo,项目名称:Test_Project,代码行数:42,代码来源:parse_device.cpp


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