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

Method WriteString

Engine/source/EtCore/FileSystem/Json/JsonWriter.cpp:201–237  ·  view source on GitHub ↗

--------------------------------- Writer::WriteString Write a string and decode escape sequences

Source from the content-addressed store, hash-verified

199// Write a string and decode escape sequences
200//
201void Writer::WriteString(std::string const& str)
202{
203 m_JsonString += s_StringScope;
204
205 for (char const character : str)
206 {
207 switch (character)
208 {
209 case '\"':
210 m_JsonString += "\\\"";
211 break;
212 case '\\':
213 m_JsonString += "\\\\";
214 break;
215 case '\b':
216 m_JsonString += "\\b";
217 break;
218 case '\f':
219 m_JsonString += "\\f";
220 break;
221 case '\n':
222 m_JsonString += "\\n";
223 break;
224 case '\r':
225 m_JsonString += "\\r";
226 break;
227 case '\t':
228 m_JsonString += "\\t";
229 break;
230 default:
231 m_JsonString += character; // since we only have ascii strings internally we don't have to worry about writing unicode characters
232 break;
233 }
234 }
235
236 m_JsonString += s_StringScope;
237}
238
239//---------------------------------
240// Writer::WriteArray

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected