• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parseArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parseArray函数的典型用法代码示例。如果您正苦于以下问题:C++ parseArray函数的具体用法?C++ parseArray怎么用?C++ parseArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: appendToJson

string TgTypeParser::parseMessage(const Message::Ptr& object) const {
	if (!object) {
		return "";
	}
	string result;
	result += '{';
	appendToJson(result, "message_id", object->messageId);
	appendToJson(result, "from", parseUser(object->from));
	appendToJson(result, "date", object->date);
	appendToJson(result, "chat", parseChat(object->chat));
	appendToJson(result, "forward_from", parseUser(object->forwardFrom));
	appendToJson(result, "forward_date", object->forwardDate);
	appendToJson(result, "reply_to_message", parseMessage(object->replyToMessage));
	appendToJson(result, "text", object->text);
	appendToJson(result, "audio", parseAudio(object->audio));
	appendToJson(result, "document", parseDocument(object->document));
	appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo));
	appendToJson(result, "sticker", parseSticker(object->sticker));
	appendToJson(result, "video", parseVideo(object->video));
	appendToJson(result, "contact", parseContact(object->contact));
	appendToJson(result, "location", parseLocation(object->location));
	appendToJson(result, "new_chat_participant", parseUser(object->newChatParticipant));
	appendToJson(result, "left_chat_participant", parseUser(object->leftChatParticipant));
	appendToJson(result, "new_chat_title", object->newChatTitle);
	appendToJson(result, "new_chat_photo", parseArray(&TgTypeParser::parsePhotoSize, object->newChatPhoto));
	appendToJson(result, "delete_chat_photo", object->deleteChatPhoto);
	appendToJson(result, "group_chat_created", object->groupChatCreated);
	appendToJson(result, "caption", object->caption);
	result.erase(result.length() - 1);
	result += '}';
	return result;
}
开发者ID:flode,项目名称:tgbot-cpp,代码行数:32,代码来源:TgTypeParser.cpp


示例2: switch

//-------------------------------------------------------
void coTParser::parseValue()
{
	switch (m_currentToken.m_type)
	{
	case coTLexer::EToken_RAW_IDENTIFIER:
	case coTLexer::EToken_NUMERIC_LITERAL:
	case coTLexer::EToken_STRING_LITERAL:
	case coTLexer::EToken_TRUE:
	case coTLexer::EToken_FALSE:
		{
			coTSemanticAnalyzer::Value val;
			val.m_value = m_currentToken;
			m_semanticAnalyzer->onValue(val);
			consumeToken();
		}
		break;
	case coTLexer::EToken_LBRACK:
		{
			parseArray();
		}
		break;
	case coTLexer::EToken_LBRACE:
		{
			parseSet();
		}
		break;
	default:
		{
			coFAIL();
		}
		break;
	}
}
开发者ID:smogpill,项目名称:dataspace,代码行数:34,代码来源:coTParser.cpp


示例3: parse

 QVariant parse()
 {
     LOG_AS("JSONParser");
     if(atEnd()) return QVariant();
     QChar c = peek();
     if(c == '{')
     {
         return parseObject();
     }
     else if(c == '[')
     {
         return parseArray();
     }
     else if(c == '\"')
     {
         return parseString();
     }
     else if(c == '-' || c.isDigit())
     {
         return parseNumber();
     }
     else
     {
         return parseKeyword();
     }
 }
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:26,代码来源:json.cpp


示例4: parseArray

// FREE OPERATORS
JsonEntity* JsonParser::fromString( const std::string& rawJson )
{
    for( int i=0; i < rawJson.length(); i++ )
    {
      if( rawJson[i] == '[' )
      {
        i = parseArray( rawJson, i );
      }
      else if( rawJson[i] == 't' || rawJson[i] == 'f' )
      {
        i = parseBool( rawJson, i );
      }
      else if( rawJson[i] == '{' )
      {
        i = parseObject( rawJson, i );
      }
      else if( rawJson[i] == '-' || ( rawJson[i] >= '0' && rawJson[i] <= '9' ) )
      {
        i = parseNumber( rawJson, i );
      }
      else if( rawJson[i] == '"' )
      {
        i = parseString( rawJson, i );
      }
    }
}
开发者ID:famzim13,项目名称:CS585,代码行数:27,代码来源:json_parser.cpp


示例5: name

void JsonParser::parseArray( JsonScanner & scanner, std::vector<JsonValue *> * values ) {
	static std::string name( "" );
	JsonToken token;
	try {
		token = scanner.getNextToken();
	}
	catch ( const std::exception & e ) {
		throw;
	}

	JsonValue * value;
	try {
		value = parseValue( scanner, token, name );
	} catch( const std::exception & e ) {
		throw;
	}
	values->push_back( value );
	try {
		token = scanner.getNextToken();
	} catch( const std::exception & e ) {
		throw;
	}
	if( token.getType() == JsonTypes::COMMA ) {
		try {
			parseArray( scanner, values );
		} catch( std::exception & e ) {
			throw;
		}
	} else if ( token.getType() == JsonTypes::CLOSE_BRACKET ) {
	} else {
		throw ArrayParsingException();
	}
}
开发者ID:rokthewok,项目名称:Argonaut,代码行数:33,代码来源:JsonParser.cpp


示例6: switch

QString PHPSerializeFormatter::getFormatted()
{
    //todo implement this

    switch (getType(rawValue))
    {
        case Null:
            return "NULL";                

        case Integer:
        case Double:        
            return parseDecimal(rawValue);

        case Boolean:
            return (parseDecimal(rawValue) == "1")? "true" : "false";

        case String:
            return parseString(rawValue);

        case Array:
            return parseArray(rawValue);

        case Object:
            return parseObject(rawValue);

        case Invalid:
        default:
            return "Invalid or corrupted serialize string";
    }    
}
开发者ID:KingLee2015,项目名称:RedisDesktopManager,代码行数:30,代码来源:PHPSerializeFormatter.cpp


示例7: parseImpl

static bool parseImpl(const char* json, int length, tinyjson_token_type type, Impl* impl) {
	impl->type = type;

	if (type == MYJSON_TOKEN_STRING || type == MYJSON_TOKEN_LITERAL) {
		impl->value.str = json;
		impl->value.len = length;
		return true;
	}

	int ntokens = tinyjson_parse_err(json, length, 0, 0);
	if (ntokens == -1)
		return false;
	if (ntokens == 0)
		return true;

	std::vector<tinyjson_token> tokens(ntokens);
	tinyjson_parse(json, length, &tokens[0], ntokens);

	switch (type) {
	case MYJSON_TOKEN_OBJECT:
		return parseObject(json, &tokens[0], ntokens, impl);

	case MYJSON_TOKEN_ARRAY:
		return parseArray(json, &tokens[0], ntokens, impl);

	case MYJSON_TOKEN_STRING:
	case MYJSON_TOKEN_LITERAL:
		break;
	}

	return false;
}
开发者ID:DuncanKeller,项目名称:dufresne,代码行数:32,代码来源:tinyjsonp.cpp


示例8: switch

void DataValue::parse(const ustring &text, DataType type, void *value) {
	switch(type) {
		case data_int:
		case data_combo:
		case data_flags:
		case data_comboEx:
			*(int *)value = atoi(text.c_str());
			break;
		case data_str:
			if(text[0] == '"')
				((ustring*)value)->assign(text, 1, text.length() - 2);
			else if(text[0] == '#')
				parseStrList(text, value);
			else
				*(ustring*)value = text;
			break;
		case data_stock:
		case data_element:
			if(text[0] == '"')
				((ustring*)value)->assign(text, 1, text.length() - 2);
			else
				*(ustring*)value = text;
			break;
		case data_real:
			*(double *)value = atof(text.c_str());
			break;
		case data_data: {
			int i;
			static const int dtypes[] = { data_int, data_str, data_real };

			for(int t = 0; t < 3; t++)
				if(strncmp(text.c_str(), dataNames[dtypes[t]], i = strlen(dataNames[dtypes[t]])) == 0) {
					ustring s = ustring(text, i+1, text.length() - i - 2);
					switch(t) {
						case 0: *(TData*)value = atoi(s.c_str()); break;
						case 1: *(TData*)value = s; break;
						case 2: *(TData*)value = atof(s.c_str()); break;
					}
				}
			break;
		}
		case data_list:
			parseStrList(text, value);
			break;
		case data_pixbuf:
			parsePixbuf(text, value);
			break;
		case data_array:
			parseArray(text, value);
			break;
		case data_color:
			((TypeColor*)value)->set(text);
			break;
		case data_font:
			parseFont(text, value);
			break;
		default:
			;
	}
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:60,代码来源:ElementProperty.cpp


示例9: ArrayVariable

void ScriptHandler::declareDim()
{
    current_script = next_script;
    char *buf = current_script;

    if (current_array_variable){
        current_array_variable->next = new ArrayVariable();
        current_array_variable = current_array_variable->next;
    }
    else{
        root_array_variable = new ArrayVariable();
        current_array_variable = root_array_variable;
    }

    ArrayVariable array;
    current_array_variable->no = parseArray( &buf, array );

    int dim = 1;
    current_array_variable->num_dim = array.num_dim;
    for ( int i=0 ; i<array.num_dim ; i++ ){
        current_array_variable->dim[i] = array.dim[i]+1;
        dim *= (array.dim[i]+1);
    }
    current_array_variable->data = new int[dim];
    memset( current_array_variable->data, 0, sizeof(int) * dim );

    next_script = buf;
}
开发者ID:ljkgpxs,项目名称:onscripter-GBK-2015,代码行数:28,代码来源:ScriptHandler.cpp


示例10: skipWhitespace

 Base *Reader::parseExpression()
 {
     skipWhitespace();
     
     auto c = current();
     if(c == kObjectBegin) {
         return parseObject();
     } else if(c == kArrayBegin) {
         return parseArray();
     } else if(c == kStringBegin) {
         return parseString();
     } else if(is_number(c, true)) {
         return parseNumber();
     } else if(borrow(gTrueString->length())->isEqual(gTrueString)) {
         fastForward(gTrueString->length() - 1);
         return Number::True();
     } else if(borrow(gFalseString->length())->isEqual(gFalseString)) {
         fastForward(gFalseString->length() - 1);
         return Number::False();
     } else if(borrow(gNullString->length())->isEqual(gNullString)) {
         fastForward(gNullString->length() - 1);
         return Null::shared();
     } else {
         fail(String::Builder() << "unexpected '" << c << "'.");
     }
     
     return nullptr;
 }
开发者ID:decarbonization,项目名称:gfx,代码行数:28,代码来源:json.cpp


示例11: switch

CCObject *CCJson::parseValue(Json *pJsonValue) {
    if (!pJsonValue) {return NULL;}
    CCObject *object = NULL;
    switch (pJsonValue->type) {
        case Json_False:
            object = CCBool::create(false);
            break;
        case Json_True:
            object = CCBool::create(true);
            break;
        case Json_NULL:
            object = NULL;
            break;
        case Json_Number:
            object = CCFloat::create(pJsonValue->valueFloat);
            break;
        case Json_String:
            if (pJsonValue->valueString) {
                object = CCString::create(pJsonValue->valueString);
            }
            break;
        case Json_Array:
            object = parseArray(pJsonValue);
            break;
        case Json_Object:
            object = parseObject(pJsonValue->child);
            break;
        default:
            object = NULL;
            break;
    }
    return object;
}
开发者ID:ourgames,项目名称:dc208,代码行数:33,代码来源:CCJson.cpp


示例12: parseArray

void ScriptHandler::declareDim()
{
    current_script = next_script;
    const char* buf = current_script;
    array_ref arr = parseArray(&buf);
    arrays.insert(std::make_pair(arr.first, ArrayVariable(this, arr.second)));
    next_script = buf;
}
开发者ID:dsp2003,项目名称:ponscripter-fork-wh,代码行数:8,代码来源:ScriptHandler.cpp


示例13: parseArray

inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseArrayTo(
    JsonVariant *destination) {
  JsonArray &array = parseArray();
  if (!array.success()) return false;

  *destination = array;
  return true;
}
开发者ID:RitterRBC,项目名称:Arduino,代码行数:8,代码来源:JsonParserImpl.hpp


示例14: parseAny

    static Result parseAny (String::CharPointerType& t, var& result)
    {
        t = t.findEndOfWhitespace();
        auto t2 = t;

        switch (t2.getAndAdvance())
        {
            case '{':    t = t2; return parseObject (t, result);
            case '[':    t = t2; return parseArray  (t, result);
            case '"':    t = t2; return parseString ('"',  t, result);
            case '\'':   t = t2; return parseString ('\'', t, result);

            case '-':
                t2 = t2.findEndOfWhitespace();
                if (! CharacterFunctions::isDigit (*t2))
                    break;

                t = t2;
                return parseNumber (t, result, true);

            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
                return parseNumber (t, result, false);

            case 't':   // "true"
                if (t2.getAndAdvance() == 'r' && t2.getAndAdvance() == 'u' && t2.getAndAdvance() == 'e')
                {
                    t = t2;
                    result = var (true);
                    return Result::ok();
                }
                break;

            case 'f':   // "false"
                if (t2.getAndAdvance() == 'a' && t2.getAndAdvance() == 'l'
                      && t2.getAndAdvance() == 's' && t2.getAndAdvance() == 'e')
                {
                    t = t2;
                    result = var (false);
                    return Result::ok();
                }
                break;

            case 'n':   // "null"
                if (t2.getAndAdvance() == 'u' && t2.getAndAdvance() == 'l' && t2.getAndAdvance() == 'l')
                {
                    t = t2;
                    result = var();
                    return Result::ok();
                }
                break;

            default:
                break;
        }

        return createFail ("Syntax error", &t);
    }
开发者ID:kmatheussen,项目名称:radium,代码行数:58,代码来源:juce_JSON.cpp


示例15: parseValue

			inline static JSONValue parseValue(const char* string)
			{
				JSONValue value;

				//Parsing Bools
				if (strcmp(string, "true") == 0)
				{
					value = true;
				}
				else if (strcmp(string, "false") == 0)
				{
					value = false;
				}
				//Parsing strings
				else if (string[0] == '\"')
				{
					int valStringLen = strlen(string) - 1;
					char* valueString = new char[valStringLen];
					memcpy(valueString, string + 1, valStringLen);
					valueString[valStringLen - 1] = '\0';

					value = valueString;
				}
				//Parsing Objects
				else if (string[0] == '{')
				{
					value = parseObject(string);
				}
				//Parsing Arrays
				else if(string[0] == '[')
				{
					value = parseArray(string);
				}
				//Parsing null
				else if (strcmp(string, "null") == 0)
				{
					value = 0;
				}
				//Parsing numbers
				else if (strstr(string, "."))
				{
					float *floatVal = new float;
					*floatVal = (float)atof(string);
					value = *floatVal;
				}
				else
				{
					int* intVal = new int;
					*intVal = atoi(string);
					value = *intVal;
				}

				return value;
			}
开发者ID:FlannelViolin,项目名称:Checkers,代码行数:54,代码来源:JSONParser.hpp


示例16: throw

/**
 * Parse a simple value, an array or an object.
 * @param in	Input stream.
 * @param t		Last token.
 */
void Parser::parseValue(io::InStream& in, token_t t) throw(json::Exception) {
		switch(t) {
		case LBRACE:	m.beginObject(); parseObject(in); return;
		case LBRACK:	m.beginArray(); parseArray(in); return;
		case _NULL:		m.onNull(); return;
		case TRUE:		{ m.onValue(true); return; }
		case FALSE:		{ m.onValue(false); return; }
		case INT:		{ int i; text >> i; m.onValue(i); return; }
		case FLOAT:		{ double d; text >> d; m.onValue(d); return; }
		case STRING:	{ m.onValue(text); return; }
		default:		error("unexpected symbol");
		}
}
开发者ID:dllinxi,项目名称:WCET,代码行数:18,代码来源:json_Parser.cpp


示例17: parseValue

dynamic parseValue(Input& in) {
  in.skipWhitespace();
  return *in == '[' ? parseArray(in) :
         *in == '{' ? parseObject(in) :
         *in == '\"' ? parseString(in) :
         (*in == '-' || (*in >= '0' && *in <= '9')) ? parseNumber(in) :
         in.consume("true") ? true :
         in.consume("false") ? false :
         in.consume("null") ? nullptr :
         in.consume("Infinity") ? std::numeric_limits<double>::infinity() :
         in.consume("NaN") ? std::numeric_limits<double>::quiet_NaN() :
         in.error("expected json value");
}
开发者ID:HunterChen,项目名称:folly,代码行数:13,代码来源:json.cpp


示例18: parseObjectOrArray

    static Result parseObjectOrArray (String::CharPointerType t, var& result)
    {
        t = t.findEndOfWhitespace();

        switch (t.getAndAdvance())
        {
            case 0:      result = var::null; return Result::ok();
            case '{':    return parseObject (t, result);
            case '[':    return parseArray  (t, result);
        }

        return createFail ("Expected '{' or '['", &t);
    }
开发者ID:Dysonics,项目名称:Juce-look-and-feel-examples,代码行数:13,代码来源:juce_JSON.cpp


示例19: switch

JsonValue * JsonParser::parseValue( JsonScanner & scanner, 
		const JsonToken & token, const std::string & name ) {
	int iValue;
	double rValue;
	bool bValue;
	std::vector<JsonValue *> * values;
	std::vector<JsonValue *> * members;

	switch( token.getType() ) {
		case JsonTypes::INTEGER:
			iValue = atoi( token.getToken().c_str() );
			return new JsonValue( name, iValue );
			break;
		case JsonTypes::REAL:
			rValue = atof( token.getToken().c_str() );
			return new JsonValue( name, rValue );
			break;
		case JsonTypes::BOOLEAN:
			bValue = token.getToken() == "true" ? true : false;
			return new JsonValue( name, bValue );
			break;
		case JsonTypes::STRING:
			return new JsonValue( name, token.getToken() );
			break;
		case JsonTypes::OPEN_BRACKET:
			values = new std::vector<JsonValue *>();
			try {
				parseArray( scanner, values );
			} catch( const std::exception & e ) {
				delete values;
				throw;
			}
			return new JsonValue( name, values );
			break;
		case JsonTypes::NULLTYPE:
			break;
		case JsonTypes::OPEN_BRACE:
			members = new std::vector<JsonValue *>();
			try {
				parseMembers( scanner, members );
			} catch( const std::exception & e ) {
				delete members;
				throw;
			}
			return new JsonValue( name, new JsonObject( members ) );
			break;
		default:
			throw ValueParsingException();
			break;
	}
}
开发者ID:rokthewok,项目名称:Argonaut,代码行数:51,代码来源:JsonParser.cpp


示例20: parseString

//-----------------------------------------------------------------------------
// Parser core - when encountering text, process appropriately.
const char* JSON::parseValue(const char* buff, const char** perror)
{
    if (perror)
        *perror = 0;

	if (!buff)
        return NULL;	// Fail on null.

	if (!strncmp(buff,"null",4))
    {
        Type = JSON_Null;
        return buff+4;
    }
	if (!strncmp(buff,"false",5))
    { 
        Type   = JSON_Bool;
        Value  = "false";
        dValue = 0.;
        return buff+5;
    }
	if (!strncmp(buff,"true",4))
    {
        Type   = JSON_Bool;
        Value  = "true";
        dValue = 1.;
        return buff + 4;
    }
	if (*buff=='\"')
    {
        return parseString(buff, perror);
    }
	if (*buff=='-' || (*buff>='0' && *buff<='9'))
    { 
        return parseNumber(buff);
    }
	if (*buff=='[')
    { 
        return parseArray(buff, perror);
    }
	if (*buff=='{')
    {
        return parseObject(buff, perror);
    }

    return AssignError(perror, "Syntax Error: Invalid syntax");
}
开发者ID:ArthurTorrente,项目名称:4A_Anim_Numerique_Genetic_Algorithm,代码行数:48,代码来源:OVR_JSON.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parseAttribute函数代码示例发布时间:2022-05-30
下一篇:
C++ parseArgs函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap