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

Method InsertToTree

src/NppJsonViewer/RapidJsonHandler.cpp:187–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void RapidJsonHandler::InsertToTree(TreeNode* node, const char* const str, bool bQuote)
188{
189 if (!node || !str)
190 return;
191
192 if (node->node.type != JsonNodeType::ARRAY)
193 {
194 node->node.key = m_jsonLastKey;
195 node->node.value = str;
196 m_jsonLastKey.clear();
197 }
198 else
199 {
200 node->node.key.strKey = "[" + std::to_string(node->counter) + "]";
201 node->node.value = str;
202
203 size_t valueLen = node->node.value.size();
204 node->node.key.pos.nLine = m_pTS->getLine();
205 node->node.key.pos.nColumn = m_pTS->getColumn() - valueLen - (bQuote ? 1 : 0); // -1 to deal with double quote in string
206 node->node.key.pos.nKeyLength = valueLen;
207
208 node->counter++;
209 }
210
211 // Insert item to tree
212 if (bQuote)
213 m_pTreeHandler->InsertToTree(node->subRoot, node->node.key.strKey + " : \"" + node->node.value + "\"", node->node.key.pos);
214 else
215 m_pTreeHandler->InsertToTree(node->subRoot, node->node.key.strKey + " : " + node->node.value, node->node.key.pos);
216}
217
218void RapidJsonHandler::AppendNodeCount(unsigned elementCount, bool bArray)
219{

Callers 3

StringMethod · 0.45
StartObjectMethod · 0.45
StartArrayMethod · 0.45

Calls 3

getLineMethod · 0.80
getColumnMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected