| 300 | } |
| 301 | |
| 302 | void Param::ParamNode::insert(const ParamNode& node, const std::string& prefix) |
| 303 | { |
| 304 | //std::cerr << "INSERT NODE " << node.name << " (" << prefix << ")" << std::endl; |
| 305 | std::string prefix2 = prefix + node.name; |
| 306 | |
| 307 | ParamNode* insert_node = this; |
| 308 | while (prefix2.find(':') != std::string::npos) |
| 309 | { |
| 310 | size_t pos = prefix2.find(':'); |
| 311 | std::string local_name = prefix2.substr(0, pos); |
| 312 | //check if the node already exists |
| 313 | NodeIterator it = insert_node->findNode(local_name); |
| 314 | if (it != insert_node->nodes.end()) //exists |
| 315 | { |
| 316 | insert_node = &(*it); |
| 317 | } |
| 318 | else //create it |
| 319 | { |
| 320 | insert_node->nodes.emplace_back(local_name, ""); |
| 321 | insert_node = &(insert_node->nodes.back()); |
| 322 | //std::cerr << " - Created new node: " << insert_node->name << std::endl; |
| 323 | } |
| 324 | //remove prefix |
| 325 | prefix2 = prefix2.substr(local_name.size() + 1); |
| 326 | } |
| 327 | |
| 328 | //check if the node already exists |
| 329 | NodeIterator it = insert_node->findNode(prefix2); |
| 330 | if (it != insert_node->nodes.end()) //append nodes and entries |
| 331 | { |
| 332 | for (ConstNodeIterator it2 = node.nodes.begin(); it2 != node.nodes.end(); ++it2) |
| 333 | { |
| 334 | it->insert(*it2); |
| 335 | } |
| 336 | for (ConstEntryIterator it2 = node.entries.begin(); it2 != node.entries.end(); ++it2) |
| 337 | { |
| 338 | it->insert(*it2); |
| 339 | } |
| 340 | if (it->description.empty() || !node.description.empty()) //replace description if not empty in new node |
| 341 | { |
| 342 | it->description = node.description; |
| 343 | } |
| 344 | } |
| 345 | else //insert it |
| 346 | { |
| 347 | Param::ParamNode tmp(node); |
| 348 | tmp.name = prefix2; |
| 349 | insert_node->nodes.push_back(tmp); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | void Param::ParamNode::insert(const ParamEntry& entry, const std::string& prefix) |
| 354 | { |
no test coverage detected