27 #include <SimoxUtility/algorithm/string/string_tools.h>
34 Path::Path() : rootIdentifier(DEFAULT_ROOT_IDENTIFIER), delimeter(DEFAULT_DELIMETER)
39 rootIdentifier(DEFAULT_ROOT_IDENTIFIER), delimeter(DEFAULT_DELIMETER), path(p)
44 rootIdentifier(p.getRootIdentifier()), delimeter(p.getDelimeter()), path(p.getPath())
50 for (
const std::string&
s : p)
65 return rootIdentifier;
81 Path::append(
const std::string&
str)
86 std::vector<std::string>
98 "Try to access last element of empty vector.");
109 "Try to access last element of empty vector.");
117 return path.size() > 0;
129 std::stringstream ss;
130 ss << rootIdentifier;
131 for (
const std::string&
s : path)
133 ss << delimeter <<
s;
140 const std::string& rootIdentifier,
141 const std::string& delimeter)
146 elements[0] = simox::alg::remove_prefix(elements[0], rootIdentifier);
148 return Path(elements);
157 el =
"\"" + el +
"\"";
159 return Path(*
this, {el});
168 el =
"\"" + el +
"\"";
170 return Path(*
this, {el});
176 std::string el =
"::accepted_type";
179 el =
"\"" + el +
"\"";
181 return Path(*
this, {el});
190 el =
"\"" + el +
"\"";
192 return Path(*
this, {el});
198 std::vector<std::string> p = path;
201 ret.setRootIdentifier(rootIdentifier);
202 ret.setDelimeter(delimeter);
209 std::vector<std::string> p = path;
212 ret.setRootIdentifier(rootIdentifier);
213 ret.setDelimeter(delimeter);
220 unsigned int firstWithoutMatch = 0;
221 for (
const std::string& el : pref.
getPath())
223 if (path.size() <= firstWithoutMatch || el != path[firstWithoutMatch])
232 std::vector<std::string> elementsWithoutPrefix(path.begin() + firstWithoutMatch,
235 auto ret =
Path(elementsWithoutPrefix);
236 ret.setRootIdentifier(rootIdentifier);
237 ret.setDelimeter(delimeter);
246 if (path.size() < p.size())
253 for (
const auto& el : path)
268 if (p.size() + 1 != path.size())