2 #include <ossia/detail/optional.hpp>
3 #include <ossia/detail/regex_fwd.hpp>
4 #include <ossia/network/base/address_scope.hpp>
5 #include <ossia/network/base/name_validation.hpp>
7 #include <smallfun.hpp>
42 : address{std::move(s)}
52 operator std::string()
const {
return address; }
56 std::ostream& operator<<(std::ostream& s,
const path_element& p);
61 explicit device(std::string s)
70 static std::string instance_regex()
73 =
"(\\.[" + std::string(ossia::net::name_characters_no_instance()) +
"]+)?";
91 any_between(std::initializer_list<std::string> args)
94 const auto N = args.size();
99 auto it = args.begin();
102 for(std::size_t i = 1; i < N; i++)
134 inline path_element operator/(
const path_element& lhs,
const any_instance& rhs)
136 return path_element{lhs.address +
"\\/" + rhs.address};
139 inline path_element operator/(
const path_element& lhs,
const any_node&)
142 lhs.address +
"\\/[" + std::string(ossia::net::name_characters()) +
"]*"};
145 inline path_element operator/(
const path_element& lhs,
const any_path&)
148 lhs.address +
"(\\/[" + std::string(ossia::net::name_characters()) +
"]*)+"};
151 inline path_element operator/(
const any_path&,
const path_element& rhs)
153 const std::string sub = std::string(ossia::net::name_characters());
154 std::string sub2 =
"^([";
156 sub2 +=
"]*:)(\\/?[";
160 return path_element{std::move(sub2)};
163 inline path_element operator/(
const path_element& lhs,
const stop& rhs)
165 return path_element{lhs.address +
"$"};
208 struct OSSIA_EXPORT path
212 ossia::net::address_scope scope;
217 using child_function = smallfun::function<
218 void(std::vector<ossia::net::node_base*>&), sizeof_regex +
sizeof(
void*)>;
219 std::vector<child_function> child_functions;
221 friend bool operator==(
const path& lhs,
const path& rhs)
223 return lhs.pattern == rhs.pattern;
225 friend bool operator!=(
const path& lhs,
const path& rhs)
227 return lhs.pattern != rhs.pattern;
232 OSSIA_EXPORT
bool is_pattern(std::string_view address);
237 OSSIA_EXPORT std::optional<path> make_path(std::string_view address);
247 OSSIA_EXPORT
void apply(
const path& p, std::vector<ossia::net::node_base*>& nodes);
257 OSSIA_EXPORT std::string substitute_characters(
const std::string& path);
260 OSSIA_EXPORT
bool match(std::string_view address,
const regex_path::path_element& e);
268 struct hash<
ossia::traversal::path>
270 std::size_t operator()(
const ossia::traversal::path& p)
const
272 return std::hash<std::string>{}(p.pattern);
The node_base class.
Definition: node.hpp:48
Utilities to construct regexes to validate paths.
Utilities to construct classes that will perform an action for nodes matching a path.
Can match nodes that are instances : foo:/bar, foo:/bar.1, etc.
Definition: path.hpp:69
Can match any node : foo:/bar, foo:/baz.1234, etc.
Definition: path.hpp:116
Can match any subpath : foo:/bar/baz, foo:/bar/bo.12/baz, etc.
Definition: path.hpp:121
Represents a device in a path, e.g. "foo:".
Definition: path.hpp:60
Base class for our paths.
Definition: path.hpp:39
Matches the end of a parameter.
Definition: path.hpp:126