MCPcopy Create free account
hub / github.com/Illation/ETEngine / ParseString

Method ParseString

Engine/source/EtCore/FileSystem/Json/JsonParser.cpp:205–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205bool JSON::Parser::ParseString(const std::string & textFile, std::string &parsed)
206{
207 while (!m_Completed)
208 {
209 if (CheckEOF(textFile))return false;
210 char next = textFile[m_ReadIdx++];
211 if (next == '"')
212 {
213 //m_ReadIdx++;
214 return true;
215 }
216 else if (next == '\\')
217 {
218 if (CheckEOF(textFile))return false;
219 next = textFile[m_ReadIdx++];
220 switch (next)
221 {
222 case '\"': parsed += '\"'; break;
223 case '\\': parsed += '\\'; break;
224 case '/': parsed += '/'; break;
225 case 'b': parsed += '\b'; break;
226 case 'f': parsed += '\f'; break;
227 case 'n': parsed += '\n'; break;
228 case 'r': parsed += '\r'; break;
229 case 't': parsed += '\t'; break;
230 case 'u':
231 {
232 if (m_ReadIdx + 4 > (uint32)textFile.size()) return false;
233 std::string hexString = "0x" + textFile.substr(m_ReadIdx, 4);
234 parsed += static_cast<char>(std::stoul(hexString, nullptr, 16));
235 m_ReadIdx += 4;
236 }
237 break;
238 default:
239 LOG("unexpected symbol after escape character while parsing string", Warning);
240 return false;
241 }
242 }
243 else
244 {
245 parsed += next;
246 }
247 }
248 return false;
249}
250
251JSON::Array* JSON::Parser::ParseArray(const std::string & textFile)
252{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected