27#include <SimoxUtility/algorithm/string/string_tools.h>
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)
143 std::vector<std::string> elements = simox::alg::split(s, delimeter);
146 elements[0] = simox::alg::remove_prefix(elements[0], rootIdentifier);
148 return Path(elements);
154 std::string el = std::to_string(i);
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});
187 std::string el =
"::accepted_type_" + std::to_string(i);
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())
void setRootIdentifier(const std::string &)
Path withDetachedFirstElement() const
Path getWithoutPrefix(const Path &) const
static Path FromString(const std::string &, const std::string &rootIdentifier=DEFAULT_ROOT_IDENTIFIER, const std::string &delimeter=DEFAULT_DELIMETER)
bool hasDirectPrefix(const Path &) const
std::string toString() const
bool hasPrefix(const Path &) const
Path withIndex(int, bool escape=false) const
std::vector< std::string > getPath() const
std::string getLastElement() const
Path withElement(const std::string &, bool escape=false) const
Path withAcceptedType(bool escape=false) const
Path withAcceptedTypeIndex(int, bool escape=false) const
static const constexpr char * DEFAULT_ROOT_IDENTIFIER
Path()
default constructor
Path withDetachedLastElement() const
std::string getFirstElement() const
std::string getDelimeter() const
void setDelimeter(const std::string &)
static const constexpr char * DEFAULT_DELIMETER
std::string getRootIdentifier() const
A base class for aron exceptions.