MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ParseString

Method ParseString

LibLemon/src/json.cpp:52–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 }
51
52 std::string JSONParser::ParseString(){
53 if(!EatOne('"')){
54 return "";
55 }
56
57 std::string str;
58 char c;
59 while(!End()){
60 c = Eat();
61
62 if(c == '"'){
63 return str;
64 }
65
66 if(End()){
67 return str; // Unterminated string
68 }
69
70 if(c == '\\'){ // Control character
71 c = Eat();
72 switch(c){
73 case '"':
74 str += '"';
75 break;
76 case '\\':
77 str += '\\';
78 break;
79 case '/':
80 str += '/';
81 break;
82 case 'b':
83 str += '\b';
84 break;
85 case 'f':
86 str += '\f';
87 break;
88 case 'n':
89 str += '\n';
90 break;
91 case 'r':
92 str += '\r';
93 break;
94 case 't':
95 str += '\t';
96 break;
97 default: // Invalid escape character
98 #ifdef LIBLEMON_DEBUG_JSON
99 printf("Invalid escape sequence '\\%c', line %d.\n", c, line);
100 #endif
101 return "";
102 }
103 } else {
104 str += c;
105 }
106 }
107
108 return "";
109 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected