本文整理汇总了C++中parseObject函数的典型用法代码示例。如果您正苦于以下问题:C++ parseObject函数的具体用法?C++ parseObject怎么用?C++ parseObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseObject函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getToken
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);
}
开发者ID:sskirlo,项目名称:Computer-Graphics-,代码行数:58,代码来源:SceneParser.cpp
示例17: nodeInfo
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;
}
开发者ID:SadTigger,项目名称:kbe,代码行数:55,代码来源:gwfobjectinforeader.cpp
示例18: 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
示例19: parsePosition
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;
}
}
开发者ID:mason105,项目名称:red5cpp,代码行数:13,代码来源:format.cpp
示例20: parseObject
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);
}
开发者ID:iph,项目名称:Graphics,代码行数:39,代码来源:Scene.cpp
注:本文中的parseObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论