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


C++ parseObject函数代码示例

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


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

示例1: 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

示例2: parseStart

bool Parser::parseStart(StartAst **yynode)
{
    *yynode = create<StartAst>();

    (*yynode)->startToken = tokenStream->index() - 1;

    if (yytoken == Token_LBRACE)
    {
        do
        {
            ObjectAst *__node_19 = 0;
            if (!parseObject(&__node_19))
            {
                expectedSymbol(AstNode::ObjectKind, "object");
                return false;
            }
            (*yynode)->objectsSequence = snoc((*yynode)->objectsSequence, __node_19, memoryPool);

        }
        while (yytoken == Token_LBRACE);
        if (Token_EOF != yytoken)
        {
            return false;
        }
    }
    else
    {
        return false;
    }

    (*yynode)->endToken = tokenStream->index() - 2;

    return true;
}
开发者ID:KDE,项目名称:gluon,代码行数:34,代码来源:gdlparser.cpp

示例3: busInfo

bool GwfObjectInfoReader::parseBus(const QDomElement &element)
{
    std::auto_ptr<SCgBusInfo> busInfo(new SCgBusInfo());

    if(!parseObject(element,busInfo.get()))
        return false;

    if (!getAttributeString(element, "owner", busInfo->ownerIdRef()))
        return false;

    double bx, by;
    if (!getAttributeDouble(element, "b_x", bx) || !getAttributeDouble(element, "b_y", by))
        return false;
    double ex, ey;
    if (!getAttributeDouble(element, "e_x", ex) || !getAttributeDouble(element, "e_y", ey))
        return false;

    busInfo->pointsRef().append(QPointF(bx, by));

    if (!getElementPoints(element, busInfo->pointsRef()))
        return false;

    busInfo->pointsRef().append(QPointF(ex, ey));

    mObjectsInfo[SCgBus::Type].append(busInfo.release());
    return true;
}
开发者ID:dark-al,项目名称:kbe,代码行数:27,代码来源:gwfobjectinforeader.cpp

示例4: getToken

Transform* SceneParser::parseTransform() {
	char token[MAX_PARSER_TOKEN_LENGTH];
	Matrix matrix; matrix.SetToIdentity();
	Object3D *object = NULL;
	getToken(token); assert(!strcmp(token, "{"));
	// read in transformations: 
	// apply to the LEFT side of the current matrix (so the first
	// transform in the list is the last applied to the object)
	getToken(token);
	while (1) {
		if (!strcmp(token, "Scale")) {
			matrix *= Matrix::MakeScale(readVec3f());
		}
		else if (!strcmp(token, "UniformScale")) {
			float s = readFloat();
			matrix *= Matrix::MakeScale(Vec3f(s, s, s));
		}
		else if (!strcmp(token, "Translate")) {
			matrix *= Matrix::MakeTranslation(readVec3f());
		}
		else if (!strcmp(token, "XRotate")) {
			matrix *= Matrix::MakeXRotation(DegreesToRadians(readFloat()));
		}
		else if (!strcmp(token, "YRotate")) {
			matrix *= Matrix::MakeYRotation(DegreesToRadians(readFloat()));
		}
		else if (!strcmp(token, "ZRotate")) {
			matrix *= Matrix::MakeZRotation(DegreesToRadians(readFloat()));
		}
		else if (!strcmp(token, "Rotate")) {
			getToken(token); assert(!strcmp(token, "{"));
			Vec3f axis = readVec3f();
			float degrees = readFloat();
			matrix *= Matrix::MakeAxisRotation(axis, DegreesToRadians(degrees));
			getToken(token); assert(!strcmp(token, "}"));
		}
		else if (!strcmp(token, "Matrix")) {
			Matrix matrix2; matrix2.SetToIdentity();
			getToken(token); assert(!strcmp(token, "{"));
			for (int j = 0; j < 4; j++) {
				for (int i = 0; i < 4; i++) {
					float v = readFloat();
					matrix2.Set(i, j, v);
				}
			}
			getToken(token); assert(!strcmp(token, "}"));
			matrix = matrix2 * matrix;
		}
		else {
			// otherwise this must be an object,
			// and there are no more transformations
			object = parseObject(token);
			break;
		}
		getToken(token);
	}
	assert(object != NULL);
	getToken(token); assert(!strcmp(token, "}"));
	return new Transform(matrix, object);
}
开发者ID:ChanganVR,项目名称:ray-tracer,代码行数:60,代码来源:scene_parser.cpp

示例5: parseObject

PyObject* VRPyColorChooser::setGeometry(VRPyColorChooser* self, PyObject* args) {
    if (self->obj == 0) { PyErr_SetString(err, "VRPyColorChooser::activate - Object is invalid"); return NULL; }
    VRPyGeometry* geo = 0;
    parseObject(args, geo);
    if (geo) self->obj->setGeometry(geo->obj);
    Py_RETURN_TRUE;
}
开发者ID:AntonChalakov,项目名称:polyvr,代码行数:7,代码来源:VRPyColorChooser.cpp

示例6: 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

示例7:

OSG::Vec3i VRPyBase::parseVec3i(PyObject *args) {
    if (pySize(args) == 1) return parseVec3iList( parseObject(args) );

    int x,y,z; x=y=z=0;
    if (! PyArg_ParseTuple(args, "iii", &x, &y, &z)) return OSG::Vec3i();
    return OSG::Vec3i(x,y,z);
}
开发者ID:Victor-Haefner,项目名称:polyvr,代码行数:7,代码来源:VRPyBase.cpp

示例8: 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

示例9: 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

示例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

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

示例12: parseObject

// virtual
S32 LLSDJSONParser::doParse(std::istream& istr, LLSD& data) const
{
	// Read into string buffer first
	//
	std::stringstream my_buf;
	my_buf << istr.rdbuf();
	std::string str_buf = my_buf.str();
	std::cout << "GoogleDetectResponder: " << str_buf.c_str() << std::endl;
	//
	S32 object_count = 0;
	//
	try
	{
		variant_t	var = json::parse( str_buf.begin(), str_buf.end() );
		object_t	obj = boost::any_cast<object_t>(*var);
		//
		object_count = parseObject( obj, data );
	}
	catch( const std::exception& x )
	{
		std::cout << "caught exception: " << x.what() << std::endl;
	}

	return object_count;
}
开发者ID:greythane,项目名称:slitechat,代码行数:26,代码来源:llsdserialize.cpp

示例13: DecodeJSONFromString

			/* Decode JSON from a string
			 * @rawString A string in a JSON format that you wnat to decode into a JSONObject
			 *
			 * @returns A pointer to the decoded JSONObject.
			 */
			inline static JSONObject* DecodeJSONFromString(const char* rawString)
			{
				//We want to strip all whitespace from the raw string
				const char* jsonString = StringUtils::trimAllWhitespace(rawString);

				return parseObject(jsonString);
			}
开发者ID:FlannelViolin,项目名称:Checkers,代码行数:12,代码来源:JSONParser.hpp

示例14: parseObject

inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObjectTo(
    JsonVariant *destination) {
  JsonObject &object = parseObject();
  if (!object.success()) return false;

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

示例15: 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


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