MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / copy

Method copy

src/openms/source/DATASTRUCTURES/Param.cpp:761–820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759 }
760
761 Param Param::copy(const std::string& prefix, bool remove_prefix) const
762 {
763 ParamNode out("ROOT", "");
764
765 ParamNode* node = root_.findParentOf(prefix);
766 if (node == nullptr)
767 {
768 return Param();
769 }
770 //we have to copy this node only
771 if (!prefix.empty() && prefix.back() == ':')
772 {
773 if (remove_prefix)
774 {
775 out = *node;
776 }
777 else
778 {
779 out.insert(*node, prefix.substr(0, prefix.size() - node->name.size() - 1));
780 }
781 }
782 else //we have to copy all entries and nodes starting with the right suffix
783 {
784 std::string suffix = node->suffix(prefix);
785 for (Param::ParamNode::NodeIterator it = node->nodes.begin(); it != node->nodes.end(); ++it)
786 {
787 if (it->name.compare(0, suffix.size(), suffix) == 0)
788 {
789 if (remove_prefix)
790 {
791 ParamNode tmp = *it;
792 tmp.name = tmp.name.substr(suffix.size());
793 out.insert(tmp);
794 }
795 else
796 {
797 out.insert(*it, prefix.substr(0, prefix.size() - suffix.size()));
798 }
799 }
800 }
801 for (Param::ParamNode::EntryIterator it = node->entries.begin(); it != node->entries.end(); ++it)
802 {
803 if (it->name.compare(0, suffix.size(), suffix) == 0)
804 {
805 if (remove_prefix)
806 {
807 ParamEntry tmp = *it;
808 tmp.name = tmp.name.substr(suffix.size());
809 out.insert(tmp);
810 }
811 else
812 {
813 out.insert(*it, prefix.substr(0, prefix.size() - suffix.size()));
814 }
815 }
816 }
817 }
818

Callers 15

_testParamFunction · 0.95
loadMethod · 0.45
initParam_Method · 0.45
preferencesDialogMethod · 0.45
loadPreferencesMethod · 0.45
savePreferencesMethod · 0.45
getCanvasParametersMethod · 0.45
loadPreferencesMethod · 0.45
savePreferencesMethod · 0.45
setParamMethod · 0.45
loadINI_Method · 0.45

Calls 10

findParentOfMethod · 0.80
backMethod · 0.80
substrMethod · 0.80
ParamClass · 0.50
emptyMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45
suffixMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 15

_testParamFunction · 0.76
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36