MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / assemble

Method assemble

opt_utils/src/json.cpp:1024–1209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022 }
1023 }
1024 bool Parser::assemble()
1025 {
1026 std::stack<Pair<std::string, Node*> > nodeStack;
1027
1028 std::string name = "";
1029
1030 Token token;
1031 while (!tokens.empty())
1032 {
1033 token = tokens.front();
1034 tokens.pop();
1035
1036 switch (token)
1037 {
1038 case T_UNKNOWN :
1039 {
1040 const std::string &unknownToken = data.front().second;
1041 error = "Unknown token: "+unknownToken;
1042 data.pop();
1043 return false;
1044 }
1045 case T_OBJ_BEGIN :
1046 {
1047 Node *node = NULL;
1048 if (nodeStack.empty())
1049 {
1050 if (!root->IsObject())
1051 {
1052 error = "The given root node is not an object";
1053 return false;
1054 }
1055
1056 node = root;
1057 }
1058 else
1059 {
1060 node = new Object;
1061 }
1062
1063 nodeStack.push(MakePair(name, node));
1064 name.clear();
1065 break;
1066 }
1067 case T_ARRAY_BEGIN :
1068 {
1069 Node *node = NULL;
1070 if (nodeStack.empty())
1071 {
1072 if (!root->IsArray())
1073 {
1074 error = "The given root node is not an array";
1075 return false;
1076 }
1077
1078 node = root;
1079 }
1080 else
1081 {

Callers

nothing calls this directly

Calls 9

MakePairFunction · 0.85
popMethod · 0.80
IsObjectMethod · 0.80
pushMethod · 0.80
clearMethod · 0.80
IsArrayMethod · 0.80
AddMethod · 0.80
IsValueMethod · 0.80
SetMethod · 0.80

Tested by

no test coverage detected