MCPcopy Create free account
hub / github.com/NPP-JSONViewer/JSON-Viewer / StartObject

Method StartObject

src/NppJsonViewer/RapidJsonHandler.cpp:91–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91bool RapidJsonHandler::StartObject()
92{
93 TreeNode* parent = nullptr;
94 if (m_NodeStack.empty())
95 {
96 parent = new TreeNode;
97 parent->node.type = JsonNodeType::OBJECT;
98 parent->subRoot = m_treeRoot;
99 parent->counter = 0;
100 m_NodeStack.push(parent);
101 }
102 else
103 {
104 parent = m_NodeStack.top();
105 }
106
107 if (!m_jsonLastKey.strKey.empty() || parent->node.type == JsonNodeType::ARRAY)
108 {
109 HTREEITEM newNode = nullptr;
110 if (parent->node.type != JsonNodeType::ARRAY)
111 {
112 newNode = m_pTreeHandler->InsertToTree(parent->subRoot, m_jsonLastKey.strKey, m_jsonLastKey.pos);
113 m_jsonLastKey.clear();
114 }
115 else
116 {
117 // It is an array
118 std::string arr = "[" + std::to_string(parent->counter) + "]";
119 newNode = m_pTreeHandler->InsertToTree(parent->subRoot, arr);
120 }
121
122 parent->counter++;
123 TreeNode* newTreeNode = new TreeNode;
124 newTreeNode->node.type = JsonNodeType::OBJECT;
125 newTreeNode->subRoot = newNode;
126 newTreeNode->counter = 0;
127 m_NodeStack.push(newTreeNode);
128 }
129
130 return true;
131}
132
133bool RapidJsonHandler::EndObject(unsigned memberCount)
134{

Callers

nothing calls this directly

Calls 2

InsertToTreeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected