| 555 | } |
| 556 | |
| 557 | void Param::setDefaults(const Param& defaults, const std::string& prefix, bool showMessage) |
| 558 | { |
| 559 | std::string prefix2 = prefix; |
| 560 | if (!prefix2.empty()) |
| 561 | { |
| 562 | if (prefix2.back() != ':') |
| 563 | { |
| 564 | prefix2 += ':'; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | std::string pathname; |
| 569 | for (Param::ParamIterator it = defaults.begin(); it != defaults.end(); ++it) |
| 570 | { |
| 571 | if (!exists(prefix2 + it.getName())) |
| 572 | { |
| 573 | if (showMessage) |
| 574 | std::cerr << "Setting " << prefix2 + it.getName() << " to " << it->value << std::endl; |
| 575 | std::string name = prefix2 + it.getName(); |
| 576 | root_.insert(ParamEntry("", it->value, it->description), name); |
| 577 | //copy tags |
| 578 | for (std::set<std::string>::const_iterator tag_it = it->tags.begin(); tag_it != it->tags.end(); ++tag_it) |
| 579 | { |
| 580 | addTag(name, *tag_it); |
| 581 | } |
| 582 | //copy restrictions |
| 583 | if (it->value.valueType() == ParamValue::STRING_VALUE || it->value.valueType() == ParamValue::STRING_LIST) |
| 584 | { |
| 585 | setValidStrings(name, it->valid_strings); |
| 586 | } |
| 587 | else if (it->value.valueType() == ParamValue::INT_VALUE || it->value.valueType() == ParamValue::INT_LIST) |
| 588 | { |
| 589 | setMinInt(name, it->min_int); |
| 590 | setMaxInt(name, it->max_int); |
| 591 | } |
| 592 | else if (it->value.valueType() == ParamValue::DOUBLE_VALUE || it->value.valueType() == ParamValue::DOUBLE_LIST) |
| 593 | { |
| 594 | setMinFloat(name, it->min_float); |
| 595 | setMaxFloat(name, it->max_float); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | //copy section descriptions |
| 600 | const std::vector<ParamIterator::TraceInfo>& trace = it.getTrace(); |
| 601 | for (std::vector<ParamIterator::TraceInfo>::const_iterator it2 = trace.begin(); it2 != trace.end(); ++it2) |
| 602 | { |
| 603 | if (it2->opened) |
| 604 | { |
| 605 | pathname += it2->name + ":"; |
| 606 | } |
| 607 | else |
| 608 | { |
| 609 | pathname.resize(pathname.size() - it2->name.size() - 1); |
| 610 | } |
| 611 | std::string real_pathname = pathname.substr(0, pathname.length() - 1); //remove ':' at the end |
| 612 | if (!real_pathname.empty()) |
| 613 | { |
| 614 | std::string description_old = getSectionDescription(prefix + real_pathname); |
no test coverage detected