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

Method StartArray

src/NppJsonViewer/RapidJsonHandler.cpp:139–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139bool RapidJsonHandler::StartArray()
140{
141 TreeNode* parent = nullptr;
142 if (m_NodeStack.empty())
143 {
144 parent = new TreeNode;
145 parent->node.type = JsonNodeType::ARRAY;
146 parent->subRoot = m_treeRoot;
147 parent->counter = 0;
148 m_NodeStack.push(parent);
149 return true;
150 }
151 else
152 {
153 parent = m_NodeStack.top();
154 }
155
156 if (!m_jsonLastKey.strKey.empty() || parent->node.type == JsonNodeType::ARRAY)
157 {
158 HTREEITEM newNode;
159 if (parent->node.type != JsonNodeType::ARRAY)
160 {
161 newNode = m_pTreeHandler->InsertToTree(parent->subRoot, m_jsonLastKey.strKey, m_jsonLastKey.pos);
162 m_jsonLastKey.clear();
163 }
164 else
165 {
166 // It is an array
167 std::string arr = "[" + std::to_string(parent->counter) + "]";
168 newNode = m_pTreeHandler->InsertToTree(parent->subRoot, arr);
169 }
170
171 parent->counter++;
172 TreeNode* newTreeNode = new TreeNode;
173 newTreeNode->node.type = JsonNodeType::ARRAY;
174 newTreeNode->subRoot = newNode;
175 newTreeNode->counter = 0;
176 m_NodeStack.push(newTreeNode);
177 }
178 return true;
179}
180
181bool RapidJsonHandler::EndArray(unsigned elementCount)
182{

Callers

nothing calls this directly

Calls 2

InsertToTreeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected