15void SectionHandler::insertRecursive(SectionNode& node,
const std::deque<std::string>& groups,
const Parameter& param,
size_t levelOfNesting)
22 auto newNode = std::make_unique<SectionNode>();
24 newNode->param = param;
25 newNode->nestingLevel = levelOfNesting;
26 node.nextNode.push_front(std::move(newNode));
30 const std::string& currentGroup = groups.front();
33 for (
const auto& next : node.nextNode)
35 if (next->name == currentGroup)
39 insertRecursive(*next, std::deque<std::string>(groups.begin() + 1, groups.end()), param, levelOfNesting+1);
47 auto newNode = std::make_unique<SectionNode>();
48 newNode->name = currentGroup;
50 newNode->nestingLevel = levelOfNesting;
51 node.nextNode.push_back(std::move(newNode));
53 insertRecursive(*node.nextNode.back(), std::deque<std::string>(groups.begin() + 1, groups.end()), param, levelOfNesting+1);
58 computePreOrderTraversal();
59 auto it = prePreOrderTraversal.begin();
64void SectionHandler::computePreOrderTraversal()
66 std::vector<SectionHandler::SectionNode*> result;
68 std::stack<SectionHandler::SectionNode*> nodeStack;
69 nodeStack.push(&rootnode);
71 while (!nodeStack.empty()) {
72 SectionHandler::SectionNode* node = nodeStack.top();
77 { result.push_back(node); }
80 for (
auto it = node->nextNode.rbegin(); it != node->nextNode.rend(); ++it)
82 nodeStack.push(it->get());
86 prePreOrderTraversal = result;
91 if (iterator_ptr == prePreOrderTraversal.end()) {
return nullptr; }
94 if (iterator_ptr == prePreOrderTraversal.end()) {
return nullptr; }
101 return *iterator_ptr;
104bool SectionHandler::SectionNode::isParameter()
106 return nextNode.size() == 0;
109bool SectionHandler::SectionNode::isGroupOfParameters()
111 return nextNode.size() != 0;
std::string getParamOnly() const
std::deque< std::string > getListOfGroups() const
SectionNode * iterator_next()
SectionNode * iterator_start()
SectionNode * iterator_get()
void insert(const Parameter ¶m)