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

Method WriteObject

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

--------------------------------- Writer::WriteObject Write the pairs of an object

Source from the content-addressed store, hash-verified

32// Write the pairs of an object
33//
34bool Writer::WriteObject(Object const* const jObj)
35{
36 if (jObj == nullptr)
37 {
38 LOG("JSON::Writer::WriteObject > Failed to write Object to string, object was null", LogLevel::Warning);
39 return false;
40 }
41
42 // begin the object
43 m_JsonString += s_BeginObject;
44
45 if (!m_Compact)
46 {
47 m_JsonString += s_NewLine;
48 ++m_IndentationLevel;
49 }
50
51 // write the pairs
52 bool allPairsSucceeded = true;
53 size_t pairIndex = 0;
54 while (true)
55 {
56 // Write the pair
57 if (!WritePair(jObj->value[pairIndex]))
58 {
59 LOG("JSON::Writer::WriteObject > Failed to write pair.", LogLevel::Warning);
60 allPairsSucceeded = false;
61 }
62
63 // check if there will be a successor
64 ++pairIndex;
65 bool isNotLast = pairIndex < jObj->value.size();
66
67 // write delimiter
68 if (isNotLast)
69 {
70 m_JsonString += s_Delimiter;
71 }
72
73 // write newline
74 if (!m_Compact)
75 {
76 m_JsonString += s_NewLine;
77 }
78
79 if (!isNotLast)
80 {
81 break;
82 }
83 }
84
85 // end the object
86 if (!m_Compact)
87 {
88 --m_IndentationLevel;
89 WriteIndentations();
90 }
91

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected