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


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

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


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

示例1: parseObject

/**
 * This parses a javascript objet from the content
 */
void JSONNode::parseObject(){

	if(m_debug)
		cout<<"[parseObject] "<<m_start<<" "<<m_end<<endl;

	int start=m_start;
	int end=m_end;

	while(m_content[start]!='{')
		start++;

	while(m_content[end]!='}')
		end--;

	start++;
	end--;

	while(start<=end){

// find the opening " for the key

		int findNextKey=start;

		while(m_content[findNextKey]!='"' && findNextKey<=end){
			findNextKey++;
		}

// no more keys
		if(m_content[findNextKey]!='"'){

			if(m_debug)
				cout<<"[parseObject] no more keys"<<endl;

			break;
		}

		if(m_debug){
			cout<<"[parseObject] findNextKey -> "<<findNextKey<<" "<<m_content[findNextKey]<<endl;
			cout<<"[parseObject] find key"<<endl;
		}

		JSONNode key;

		pullString(&key,start);


// find the first non-white-space character

		int firstNextSymbol=key.getEnd();

		firstNextSymbol++;

// TODO: this code will work with "key"::: "Value" but should not
		while(m_content[firstNextSymbol]==' '||m_content[firstNextSymbol]=='\t'||m_content[firstNextSymbol]=='\n'
			|| m_content[firstNextSymbol]==':'){
			firstNextSymbol++;
		}

		if(m_debug)
			cout<<"[parseObject] find value"<<endl;

		JSONNode value;
		
		pullContent(&value,firstNextSymbol);

		start=value.getEnd();

		start++;

// Skip the ','
// TODO: this code will work with "key",,,, but should not
		while(m_content[start]==' '||m_content[start]=='\t'||m_content[start]=='\n'
			|| m_content[start]==','){
			start++;
		}
	
		m_associativeKeyContent.push_back(key);
		m_associativeValueContent.push_back(value);
	}
}
开发者ID:Djeef,项目名称:Ray-Cloud-Browser,代码行数:83,代码来源:JSONNode.cpp

示例2: parseArray

void JSONNode::parseArray(){

	if(m_debug)
		cout<<"[parseArray] "<<m_start<<" "<<m_end<<endl;

	int start=m_start;
	int end=m_end;

	while(m_content[start]!='[')
		start++;

	while(m_content[end]!=']')
		end--;

	start++;
	end--;

	while(start<=end){

// find the opening " for the key

		int findNextKey=start;

		while(!isDigitSymbol(m_content[findNextKey])
			&& m_content[findNextKey]!='{' && m_content[findNextKey]!='[' 
			&& m_content[findNextKey]!='"' && findNextKey<=end){

			findNextKey++;
		}

// no more keys
		if(!isDigitSymbol(m_content[findNextKey])
			&& m_content[findNextKey]!='{' && m_content[findNextKey]!='[' 
			&& m_content[findNextKey]!='"' ){

			if(m_debug)
				cout<<"[parseObject] no more values"<<endl;

			break;
		}

		if(m_debug)
			cout<<"[parseArray] findNextKey -> "<<findNextKey<<" "<<m_content[findNextKey]<<endl;


// find the first non-white-space character

		int firstNextSymbol=start;

		while(m_content[firstNextSymbol]==' '||m_content[firstNextSymbol]=='\t'
			||m_content[firstNextSymbol]=='\n'){

			firstNextSymbol++;
		}

		if(m_debug)
			cout<<"[parseArray] find value"<<endl;

		JSONNode value;
		
		pullContent(&value,firstNextSymbol);

		start=value.getEnd();

		start++;

// Skip the ','
// TODO: this code will work with "key",,,, but should not
		while(m_content[start]==' '||m_content[start]=='\t'||m_content[start]=='\n'
			|| m_content[start]==','){
			start++;
		}
	
		m_arrayContent.push_back(value);
	}
}
开发者ID:Djeef,项目名称:Ray-Cloud-Browser,代码行数:76,代码来源:JSONNode.cpp


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