Node Document, * nodePtr = &Document; nodePtr = nodePtr->AddNode(Node("myApp")); nodePtr = nodePtr->AddNode(Node("mainWindow")); nodePtr->AddPair(Pair("width", WinObj.m_Width)); nodePtr->AddPair(Pair("height", WinObj.m_Height)); nodePtr = nodePtr->Parent(); nodePtr = nodePtr->AddNode(Node("DB")); nodePtr->AddPair(Pair("username", DbObj.username)); nodePtr->AddPair(Pair("password", DbObj.password));
Node Document; SConfigParser::ParseFile(filePath, Document);
std::string width, height; if (Document.Path("myApp.mainWindow.width", width) && Document.Path("myApp.mainWindow.height", height)) std::cout << "Window size: " << width << "x" << height << std::endl;
int width, height; if (Document.TPath("myApp.mainWindow.width", width) && Document.Path("myApp.mainWindow.height", height)) std::cout << "Window size: " << width << "x" << height << std::endl;
Handler nHandle(&Document); if ( (Node * nWidth = nHandle.FirstNode("myApp").FirstNode("mainWindow").FirstPair("width").Get()) && (Node * nHeight = nHandle.FirstNode("myApp").FirstNode("mainWindow").FirstPair("height").Get()) ) std::cout << "Window size: " << nWidth->Value() << "x" << nHeight->Value() << std::endl;
nodePtr = &Document; if ( (nodePtr = nodePtr->FirstNode("myApp")) ) { if ( (nodePtr = nodePtr->FirstNode("mainWindow")) ) { Pair * Height = nodePtr->FirstPair("height"), * Width = nodePtr->FirstPair("width"); if (Height && Width) std::cout << "Window size: " << Width.Value() << "x" << Height.Value() << std::endl; } }