OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
anonymous_namespace{PrintConfig.cpp} Namespace Reference

Functions

std::set< std::string > SplitStringAndRemoveDuplicateElement (const std::string &str, const std::string &separator)
void ReplaceString (std::string &resource_str, const std::string &old_str, const std::string &new_str)

Function Documentation

◆ ReplaceString()

void anonymous_namespace{PrintConfig.cpp}::ReplaceString ( std::string & resource_str,
const std::string & old_str,
const std::string & new_str )
78{
79 std::string::size_type pos = 0;
80 while ((pos = resource_str.find(old_str, pos)) != std::string::npos) {
81 resource_str.replace(pos, old_str.length(), new_str);
82 pos += new_str.length(); //advance position to continue after replacement
83 }
84}

◆ SplitStringAndRemoveDuplicateElement()

std::set< std::string > anonymous_namespace{PrintConfig.cpp}::SplitStringAndRemoveDuplicateElement ( const std::string & str,
const std::string & separator )
57{
58 std::set<std::string> result;
59 if (str.empty()) return result;
60
61 std::string strs = str + separator;
62 size_t pos;
63 size_t size = strs.size();
64
65 for (int i = 0; i < size; ++i) {
66 pos = strs.find(separator, i);
67 if (pos < size) {
68 std::string sub_str = strs.substr(i, pos - i);
69 result.insert(sub_str);
70 i = pos + separator.size() - 1;
71 }
72 }
73
74 return result;
75}