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


C++ JSONNode::begin方法代码示例

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


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

示例1: Compile

int Condition::Compile(JSONNode columns)
{
	if (operand1[0] == '\'')
	{
		operand1IsConstant = true;
		operand1 = operand1.substr(1, operand1.length() - 2);
	}
	else
	{
		operand1IsConstant = false;
		bool contains = false;
		for (auto j = columns.begin(); !contains && j != columns.end(); ++j)
			if (j->as_string() == operand1)
				contains = true;
		if (!contains)
			return Errors::ERR_NO_COLUMN;
	}
	if (operand2[0] == '\'')
	{
		operand2IsConstant = true;
		operand2 = operand2.substr(1, operand2.length() - 2);
	}
	else
	{
		operand2IsConstant = false;
		bool contains = false;
		for (auto j = columns.begin(); !contains && j != columns.end(); ++j)
			if (j->as_string() == operand2)
				contains = true;
		if (!contains)
			return Errors::ERR_NO_COLUMN;
	}
	return Errors::ERR_OK;
}
开发者ID:HackerDom,项目名称:ructf-2013-final,代码行数:34,代码来源:Condition.cpp

示例2: processModel

 static void processModel(const JSONNode & nd, MatModel& model) {
     bool nlayset = false;
     bool rangeset = false;
     bool lengthset = false;
     bool heightset = false;
     bool atomsset = false;
     for (auto i = nd.begin(); i != nd.end(); i++) {
         if (i->name() == JsonNames::numlayers) {
             model.mNumLayers = i->as_int();
             nlayset = true;
         } else if (i->name() == JsonNames::range) {
             model.mRadius = i->as_float();
             rangeset = true;
         } else if (i->name() == JsonNames::length) {
             model.mLength = i->as_float();
             lengthset = true;
         } else if (i->name() == JsonNames::height) {
             model.mHeight = i->as_float();
             heightset = true;
         } else if (i->name() == JsonNames::atoms) {
             BNB_ASSERT(nlayset);
             readIntVector(*i, model.mNumLayers, model.mLayersAtoms);
             atomsset = true;
         } else {
             BNB_ERROR_REPORT("Illegal name on parsing model data");
         }
     }
     BNB_ASSERT(nlayset && rangeset && lengthset && heightset && atomsset);
 }
开发者ID:mposypkin,项目名称:LURIE,代码行数:29,代码来源:parsejson.hpp

示例3: ParseJobsResponse

void ResUtils::ParseJobsResponse(std::list<KP_Job>& jobs, JSONNode &n)
{
    std::string jobId;
    JSONNode::const_iterator i = n.begin();
    if (i != n.end() && i -> name() == TAG_JOBS_STR && i -> type() == JSON_NODE)
    {
        JSONNode::const_iterator ijs = (*i).begin();
        if (ijs != n.end() && ijs -> name() == TAG_ITEMS_STR && ijs -> type() == JSON_ARRAY)
        {
            JSONNode::const_iterator ij = (*ijs).begin();
            while (ij != (*ijs).end())
            {
                if(ij -> type() == JSON_ARRAY || ij -> type() == JSON_NODE)
                {
                    JSONNode::const_iterator ia = (*ij).begin();
                    if (ia != (*ij).end() && ia -> name() == TAG_ID_STR && ia -> type() != JSON_ARRAY && ia -> type() != JSON_NODE)
                    {
                        jobId = ia -> as_string();
                        //cout << "Bp: jobId: " << jobId << endl;
                        jobs.push_back(KP_Job (jobId));
                    }
                }
                ij ++;
            }
        }
    }

}
开发者ID:pyotr777,项目名称:kportal,代码行数:28,代码来源:ResUtils.cpp

示例4: ParseJSON

void ParseJSON(const JSONNode & n, std::list<KP_Service > & services){
    
    std::string providerId, serviceId;
	bool isHasServiceId = false, isHasProviderId = false;

	JSONNode::const_iterator i = n.begin();
    while (i != n.end()){
        // recursively call ourselves to dig deeper into the tree
        if (i -> type() == JSON_ARRAY || i -> type() == JSON_NODE){
            ParseJSON(*i, services);
        }
 		
        // get the node name and value as a string
        std::string node_name = i -> name();
 		//std::cout<< "Name: "<< node_name << endl;
        // find out where to store the values
        if (node_name == TAG_SERVICE_STR){
	        isHasServiceId = true;
            serviceId = i -> as_string();
        }
        else if (node_name == TAG_PROVIDER_STR){
        	isHasProviderId = true;
            providerId = i -> as_string();
        }
        
        //increment the iterator
        ++i;
    }
    if(isHasServiceId && isHasProviderId)
	    services.push_back(KP_Service (providerId, serviceId));
}
开发者ID:pyotr777,项目名称:kportal,代码行数:31,代码来源:ResUtils.cpp

示例5: ParseJSON

void ParseJSON(const JSONNode & n){
    JSONNode::const_iterator i = n.begin();
    while (i != n.end()){
        // recursively call ourselves to dig deeper into the tree
        if (i -> type() == JSON_ARRAY || i -> type() == JSON_NODE){
            ParseJSON(*i);
        }

        // get the node name and value as a string
        std::string node_name = i -> name();

        // find out where to store the values
        if (node_name == "RootA"){
            rootA = i -> as_string();
        }
        else if (node_name == "ChildA"){
            childA = i -> as_string();
        }
        else if (node_name == "ChildB")
            childB = i -> as_int();

        //increment the iterator
        ++i;
    }
}
开发者ID:taabodim,项目名称:QpidClient,代码行数:25,代码来源:currencyHandler.cpp

示例6: while

void  baiduparser:: _parserJsonS ( const JSONNode & node_tree )
{
     JSONNode::const_iterator node_iter = node_tree.begin(); 
     while ( node_iter != node_tree.end() )
     {
         
          string  node_name = node_iter->name ();
          if ( node_name == "data" )
          {
               JSONNode::const_iterator arr_first_elem = node_iter->begin();
               JSONNode::const_iterator node_first_elem = arr_first_elem->begin();
               while ( node_first_elem != arr_first_elem->end() )
               {
                    
                    if ( node_first_elem->name() == "dst" )
                    {
                         result_ = node_first_elem->as_string();
                         break;
                    }
                    ++ node_first_elem ;
                     
               }
               break;
                
                              
          }
          
          node_iter ++;
           
     }

}
开发者ID:anzizhao,项目名称:onlinetranslator,代码行数:32,代码来源:baiduparser.cpp

示例7: readDoubleVector

 static void readDoubleVector(const JSONNode& nd, int vecsz, double * x) {
     int k = 0;
     for (auto i = nd.begin(); i != nd.end(); i++) {
         double u = i->as_float();
         BNB_ASSERT(k < vecsz);
         x[k++] = u;
     }
     BNB_ASSERT(k == vecsz);
 }
开发者ID:mposypkin,项目名称:LURIE,代码行数:9,代码来源:parsejson.hpp

示例8: processMessage

bool USB_device::processMessage(ClientConn& client, string& cmd, JSONNode& n){
	if (cmd == "controlTransfer"){
		unsigned id = jsonIntProp(n, "id", 0);
		uint8_t bmRequestType = jsonIntProp(n, "bmRequestType", 0xC0);
		uint8_t bRequest = jsonIntProp(n, "bRequest");
		uint16_t wValue = jsonIntProp(n, "wValue", 0);
		uint16_t wIndex = jsonIntProp(n, "wIndex", 0);
	
		bool isIn = bmRequestType & 0x80;
		
		JSONNode reply(JSON_NODE);
		reply.push_back(JSONNode("_action", "return"));
		reply.push_back(JSONNode("id", id));
		
		int ret = -1000;
		
		if (isIn){
			uint16_t wLength = jsonIntProp(n, "wLength", 64);
			if (wLength > 64) wLength = 64;
			if (wLength < 0) wLength = 0;
		
			uint8_t data[wLength];
			ret = controlTransfer(bmRequestType, bRequest, wValue, wIndex, data, wLength);
			
			if (ret >= 0){
				JSONNode data_arr(JSON_ARRAY);
				for (int i=0; i<ret && i<wLength; i++){
					data_arr.push_back(JSONNode("", data[i]));
				}
				data_arr.set_name("data");
				reply.push_back(data_arr);
			}
		}else{
			string datastr;
			JSONNode data = n.at("data");
			if (data.type() == JSON_ARRAY){
				for(JSONNode::iterator i=data.begin(); i!=data.end(); i++){
					datastr.push_back(i->as_int());
				}
			}else{
				datastr = data.as_string();
			}
			ret = controlTransfer(bmRequestType, bRequest, wValue, wIndex, (uint8_t *)datastr.data(), datastr.size());
		}
		
		reply.push_back(JSONNode("status", ret));
	
		client.sendJSON(reply);
	}else if(cmd == "enterBootloader"){
		std::cout << "enterBootloader: ";
		int r = controlTransfer(0x40|0x80, 0xBB, 0, 0, NULL, 100);
		std::cout << "return " <<  r << std::endl;
	}else{
		return false;
	}
	return true;
}
开发者ID:nonolith,项目名称:connect,代码行数:57,代码来源:usb.cpp

示例9: readIntVector

 static void readIntVector(const JSONNode& nd, int vecsz, int * x) {
     int k = 0;
     for (auto i = nd.begin(); i != nd.end(); i++) {
         int u = i->as_int();
         BNB_ASSERT(k < vecsz);
         x[k++] = u;
     }
     BNB_ASSERT(k == vecsz);
 }
开发者ID:mposypkin,项目名称:LURIE,代码行数:9,代码来源:parsejson.hpp

示例10: init

bool CPPModule::init(const std::string& jsonParams) {
	JSONNode n = libjson::parse(jsonParams);
	std::map<std::string, std::string> tmpParams;
	JSONNode::iterator i = n.begin();
	for(; i!=n.end(); ++i) {
		tmpParams[(*i).name()] = (*i).as_string();
	}
	return onInit(tmpParams);
}
开发者ID:S1M0NE,项目名称:IrcBot,代码行数:9,代码来源:cppmodule.cpp

示例11: findKey

JSONNode JSONNodeHelper::findKey(JSONNode jsonNode, std::string key)
{
    JSONNode returnNode;
    for (JSONNode::const_iterator i = jsonNode.begin(); i != jsonNode.end(); i++){
        if (i->name() == key){
            returnNode = *i;
        }
    }
    // TODO: throw exception if the key is not found
    return returnNode;
}
开发者ID:amareshkumar,项目名称:googletest-learning,代码行数:11,代码来源:JSONNodeHelper.cpp

示例12: processBox

 static void processBox(const JSONNode & nd, Box<double> & box) {
     int n = box.mDim;
     for (auto i = nd.begin(); i != nd.end(); i++) {
         if (i->name() == JsonNames::boxa) {
             readDoubleVector(*i, n, (double*) (box.mA));
         } else if (i->name() == JsonNames::boxb) {
             readDoubleVector(*i, n, (double*) (box.mB));
         } else {
             BNB_ERROR_REPORT("Unknown name while processing box description");
         }
     }
 }
开发者ID:mposypkin,项目名称:LURIE,代码行数:12,代码来源:parsejson.hpp

示例13: Parse

bool GameMapEncounterAreaParser::Parse(std::string json, GameMapEncounterArea *encounterArea) {
    JSONNode assetListNode = libjson::parse(json);

    JSONNode::const_iterator i = assetListNode.begin();

    while (i != assetListNode.end()) {
        if (i->name() == "mobs" && i->type() == JSON_ARRAY) {
            this->logger->debug() << "parsing mobs";
            JSONNode::const_iterator j = i->begin();

            while (j != i->end()) {
                if (j->type() == JSON_NODE) {
                    JSONNode::const_iterator k = j->begin();

                    while (k != j->end()) {
                        if (k->name() == "enemies") {
                            this->logger->debug() << "parsing enemies for mob";
                            JSONNode::const_iterator l = k->begin();

                            std::string r = "";
                            std::vector<std::string> mob;

                            while (l != k->end()) {
                                this->logger->debug() << std::setfill ('0') << std::setw(sizeof(unsigned char)*2)
                                << std::hex << l->type();

                                if (l->type() == JSON_STRING) {
                                    r += l->as_string() + ", ";
                                    mob.push_back(l->as_string());
                                }

                                l++;
                            }


                            this->logger->debug() << "parsed mob [" << r << "]";

                            encounterArea->mobs.push_back(mob);
                        }

                        k++;
                    }
                }

                j++;
            }
        }

        i++;
    }

    return true;
}
开发者ID:seaneshbaugh,项目名称:SDL03,代码行数:53,代码来源:GameMapEncounterAreaParser.cpp

示例14: processLattice

        static void processLattice(const JSONNode & nd, int n, double& v, double* x) {
            for (auto i = nd.begin(); i != nd.end(); i++) {
                if (i->name() == JsonNames::evalue) {
                    v = i->as_float();
                } else if (i->name() == JsonNames::lvector) {
                    readDoubleVector(*i, n, x);
                } else {
                    BNB_ERROR_REPORT("Unknown name while processing lattice description");
                }
            }

        }
开发者ID:mposypkin,项目名称:LURIE,代码行数:12,代码来源:parsejson.hpp

示例15: parseModelData

 /**
  * Extracts JSON model from a string input
  * @param input JSON string
  * @param model model to fill in
  */
 static void parseModelData(const std::string& input, MatModel& model) {
     JSONNode nd = libjson::parse(input);
     bool modelset = false;
     for (auto i = nd.begin(); i != nd.end(); i++) {
         if (i->name() == JsonNames::modelname) {
             processModel(*i, model);
             modelset = true;
             break;
         }
     }
     if (!modelset)
         BNB_ERROR_REPORT("Model data missing\n");
 }
开发者ID:mposypkin,项目名称:LURIE,代码行数:18,代码来源:parsejson.hpp


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