Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
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);
}
Пример #5
0
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;
}
Пример #6
0
// 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 );
      }
    }
}
Пример #7
0
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);
}
Пример #8
0
 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();
     }
 }
Пример #9
0
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;
}
Пример #10
0
 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;
 }
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";
    }    
}
Пример #12
0
// 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;
}
Пример #13
0
			/* 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);
			}
Пример #14
0
PyObject* VRPyColorChooser::resolve(VRPyColorChooser* self, PyObject* args) {
    if (self->obj == 0) { PyErr_SetString(err, "VRPyColorChooser::activate - Object is invalid"); return NULL; }
    VRPyDevice* dev = 0;
    parseObject(args, dev);
    if (dev) self->obj->resolve(dev->obj);
    Py_RETURN_TRUE;
}
Пример #15
0
OSG::Vec4d VRPyBase::parseVec4d(PyObject *args) {
    if (pySize(args) == 1) return parseVec4dList( parseObject(args) );

    float x,y,z,w; x=y=z=w=0;
    if (! PyArg_ParseTuple(args, "ffff", &x, &y, &z, &w)) return OSG::Vec4d();
    return OSG::Vec4d(x,y,z,w);
}
Пример #16
0
OSG::Vec2d VRPyBase::parseVec2f(PyObject *args) {
    if (pySize(args) == 1) return parseVec2dList( parseObject(args) );

    float x,y; x=y=0;
    if (! PyArg_ParseTuple(args, "ff", &x, &y)) return OSG::Vec2d();
    return OSG::Vec2d(x,y);
}
Пример #17
0
inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObjectTo(
    JsonVariant *destination) {
  JsonObject &object = parseObject();
  if (!object.success()) return false;

  *destination = object;
  return true;
}
Пример #18
0
    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);
    }
Пример #19
0
Transform *
SceneParser::parseTransform() 
{
    char token[MAX_PARSER_TOKEN_LENGTH];
    Matrix4f matrix = Matrix4f::identity();
    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 (true) {
        if (!strcmp(token,"Scale")) {
            Vector3f s = readVector3f();
            matrix = matrix * Matrix4f::scaling( s[0], s[1], s[2] );
        } else if (!strcmp(token,"UniformScale")) {
            float s = readFloat();
            matrix = matrix * Matrix4f::uniformScaling( s );
        } else if (!strcmp(token,"Translate")) {
            matrix = matrix * Matrix4f::translation( readVector3f() );
        } else if (!strcmp(token,"XRotate")) {
            matrix = matrix * Matrix4f::rotateX((float) DegreesToRadians(readFloat()));
        } else if (!strcmp(token,"YRotate")) {
            matrix = matrix * Matrix4f::rotateY((float) DegreesToRadians(readFloat()));
        } else if (!strcmp(token,"ZRotate")) {
            matrix = matrix * Matrix4f::rotateZ((float) DegreesToRadians(readFloat()));
        } else if (!strcmp(token,"Rotate")) {
            getToken(token); assert(!strcmp(token, "{"));
            Vector3f axis = readVector3f();
            float degrees = readFloat();
            float radians = (float) DegreesToRadians(degrees);
            matrix = matrix * Matrix4f::rotation(axis,radians);
            getToken(token); assert(!strcmp(token, "}"));
        } else if (!strcmp(token,"Matrix4f")) {
            Matrix4f matrix2 = Matrix4f::identity();
            getToken(token); assert(!strcmp(token, "{"));
            for (int j = 0; j < 4; j++) {
                for (int i = 0; i < 4; i++) {
                    float v = readFloat();
                    matrix2( 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);
}
Пример #20
0
bool GwfObjectInfoReader::parseNode(const QDomElement &element)
{
    std::auto_ptr<SCgNodeInfo> nodeInfo(new SCgNodeInfo());

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

    qreal& x = nodeInfo->posRef().rx();
    qreal& y = nodeInfo->posRef().ry();
    if (!getAttributeDouble(element, "x", x) || !getAttributeDouble(element, "y", y))
        return false;

    // get content element
    QDomElement contEl = element.firstChildElement("content");
    if (contEl.isNull())
    {
        errorHaventContent(element.tagName());
        return false;
    }

    // get content type
    int& cType = nodeInfo->contentTypeRef();
    if (!getAttributeInt(contEl, "type", cType))
        return false;

    // get mime type
    if (!getAttributeString(contEl, "mime_type", nodeInfo->contentMimeTypeRef()))
        return false;

    // set content to nodeInfo
    if (cType > 0 && cType < 5)
    {
        if (cType == 1 || cType == 2 || cType == 3)
            nodeInfo->contentDataRef() = QVariant(contEl.firstChild().nodeValue());
        else if (cType == 4)
        {
            // get file name
            getAttributeString(contEl, "file_name", nodeInfo->contentFilenameRef());
            QString cData = contEl.firstChild().nodeValue();
            QByteArray arr = QByteArray::fromBase64(cData.toLocal8Bit());
            nodeInfo->contentDataRef() = QVariant(arr);
        } else
        {
            mLastError = QObject::tr("Content type '%1' doesn't supported for now").arg(cType);
            return false;
        }
    } else if (cType != 0)
    {
        mLastError = QObject::tr("Unknown content type '%1'").arg(cType);
        return false;
    }

    mObjectsInfo[SCgNode::Type].append(nodeInfo.release());
    return true;
}
Пример #21
0
			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;
			}
Пример #22
0
void
Format::parseObject(const UnicodeString& source, 
                    Formattable& result, 
                    UErrorCode& status) const
{
    if (U_FAILURE(status)) return;

    ParsePosition parsePosition(0);
    parseObject(source, result, parsePosition);
    if (parsePosition.getIndex() == 0) {
        status = U_INVALID_FORMAT_ERROR;
    }
}
Пример #23
0
void Scene::parseScene(string sceneText){
        char buffer1[300] = "2 (0 -3.5 -200 1.0) (1 2.5 2 1.0) (180 180 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer2[300] = "1 (0 0 0 1.0) (10 15 1000 1.0) (0 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer3[300] = "1 (0 3.4 0 1.0) (5.2 2.2 2 1.0) (0 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer4[300] = "1 (1.4 0 0 1.0) (2 5.2 2 1.0) (0 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer11[300] = "4 (0 0 .5 1.0) (1 1 1 1.0) (0 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer12[300] = "4 (0 0 -.5 1.0) (1 1 1 1.0) (0 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer13[300] = "4 (.5 0 0 1.0) (100 15 1.0 1.0) (0 80 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer14[300] = "4 (0 0 0 1.0) (1 1 1 1.0) (0 90 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer15[300] = "1 (0 0 0 1.0) (1 1 1 1.0) (0 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer16[300] = "4 (0 -.5 0 1.0) (1 1 1 1.0) (90 0 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";


        char buffer6[300] = "1 (0 -2.25 -60 1.0) (5.2 5.5 100 1.0) (0 0 180 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer7[300] = "2 (-1.7 1.75 -40 1.0) (1 2.5 2 1.0) (180 180 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer8[300] = "2 (1.7 1.75 -80 1.0) (1 2.5 2 1.0) (180 180 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer9[300] = "2 (1.7 1.75 -105 1.0) (1 2.5 2 1.0) (180 180 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";
        char buffer10[300] = "1 (500 0 -500 1.0) (10 15 1000 1.0) (0 90 0 1) (0.5) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0) (1.0 1.0 1.0 1.0)";

        // char buffer5[300] = "c (0 0 20 1) (0 0 -1 1) ( 0 1 0 1)";
        parseObject(buffer2);
      /*  parseObject(buffer2);
        parseObject(buffer3);
        parseObject(buffer4);
        parseObject(buffer6);
        parseObject(buffer7);
        parseObject(buffer8);
        parseObject(buffer9);*/
    //    parseObject(buffer11);
    //    parseObject(buffer12);
        parseObject(buffer13);
     //   parseObject(buffer14);
        parseObject(buffer15);
        parseObject(buffer16);

       // parseObject(buffer10);

      //  parseCamerabuffer5);
    }
    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);
    }
Пример #25
0
/**
 * 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");
		}
}
Пример #26
0
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");
}
Пример #27
0
bool GwfObjectInfoReader::parseContour(const QDomElement &element)
{
    std::auto_ptr<SCgContourInfo> contourInfo(new SCgContourInfo());

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

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

    mObjectsInfo[SCgContour::Type].append(contourInfo.release());
    return true;
}
Пример #28
0
static void parseScene( MeshModel *root ){
	_log( "Scene" );
	enterChunk();
	while( int id=nextChunk() ){
		switch( id ){
		case CHUNK_OBJECT:
			parseObject( root );
			break;
		case CHUNK_MATERIAL:
			if( !animonly ) parseMaterial();
			break;
		}
	}
	leaveChunk();
}
Пример #29
0
Файл: Rjson.cpp Проект: XoDeR/RE
		void parse(const char* json, Map<DynamicString, const char*>& object)
		{
			RIO_ASSERT_NOT_NULL(json);

			json = skipSpaces(json);

			if (*json == '{')
			{
				parseObject(json, object);
			}
			else
			{
				parseRootObject(json, object);
			}
		}
Пример #30
0
Файл: Rjson.cpp Проект: XoDeR/RE
		void parse(const char* json, JsonObject& object)
		{
			RIO_ASSERT_NOT_NULL(json);

			json = skipSpaces(json);

			if (*json == '{')
			{
				parseObject(json, object);
			}
			else
			{
				parseRootObject(json, object);
			}
		}