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


C++ parseArray函数代码示例

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


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


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