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

Method GetNodePath

src/NppJsonViewer/TreeViewCtrl.cpp:239–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239auto TreeViewCtrl::GetNodePath(HTREEITEM hti) const -> std::wstring
240{
241 std::wstring wstrJsonPath;
242 HTREEITEM hitTravel = hti;
243 bool bArray = false;
244
245 while (hitTravel != NULL)
246 {
247 std::wstring nodeKey = GetNodeKey(hitTravel);
248
249 if (!nodeKey.empty())
250 {
251 // remove " from the beginning and end
252 if (nodeKey[0] == TEXT('"'))
253 nodeKey.erase(0, 1);
254 if (nodeKey[nodeKey.size() - 1] == TEXT('"'))
255 nodeKey.pop_back();
256
257 std::wstring separator = TEXT(".");
258 if (nodeKey[0] == TEXT('['))
259 {
260 bArray = true;
261 wstrJsonPath = nodeKey + separator + wstrJsonPath;
262 }
263 else
264 {
265 if (bArray)
266 {
267 bArray = false;
268 separator.clear();
269 }
270 wstrJsonPath = nodeKey + separator + wstrJsonPath;
271 }
272 }
273
274 HTREEITEM htiParent = GetParentItem(hitTravel);
275 hitTravel = htiParent;
276 }
277
278 // remove trailing dot (.)
279 wstrJsonPath.pop_back();
280
281 return wstrJsonPath;
282}
283
284auto TreeViewCtrl::GetNodePosition(HTREEITEM hti) const -> Position*
285{

Callers 2

UpdateNodePathMethod · 0.80
CopyPathMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected