本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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 );
}
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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";
}
}
示例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;
}
示例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);
}
示例14: parseObject
inline bool ArduinoJson::Internals::JsonParser<TReader, TWriter>::parseObjectTo(
JsonVariant *destination) {
JsonObject &object = parseObject();
if (!object.success()) return false;
*destination = object;
return true;
}
示例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);
}