Go to the documentation of this file.
    9 #ifndef EAGINE_STRING_PATH_HPP 
   10 #define EAGINE_STRING_PATH_HPP 
   36     using iterator = string_list::iterator<const char*>;
 
   62       , _str(str.data(), 
std_size(str.size())) {}
 
   66       , _str(std::move(str)) {}
 
   82       : _size(a._size + b._size)
 
   83       , _str(a._str + b._str) {}
 
   91     template <std::
size_t N>
 
   96     template <
typename... Str>
 
  107         return a._str == b._str;
 
  114         return a._str != b._str;
 
  120         return a._str < b._str;
 
  127         return a._str <= b._str;
 
  133         return a._str > b._str;
 
  140         return a._str >= b._str;
 
  152     auto empty() const noexcept -> 
bool {
 
  153         EAGINE_ASSERT((
size() == 0) == _str.empty());
 
  172         return l + 2 * required_sequence_length(code_point_t(l)).value();
 
  176         return required_bytes(
size_type(str.size()));
 
  186         EAGINE_ASSERT(!
empty());
 
  187         return string_list::front_value(_str);
 
  192         EAGINE_ASSERT(!
empty());
 
  193         return string_list::back_value(_str);
 
  199         string_list::push_back(_str, _fix(name));
 
  203     void push_back_elem(
const string_list::element& elem) {
 
  211         EAGINE_ASSERT(!
empty());
 
  212         _str.resize(
std_size(string_list::pop_back(_str).
size()));
 
  228                        : 
iterator(_str.data() + _str.size());
 
  248     template <
typename Func>
 
  250         string_list::for_each_elem(
view(_str), func);
 
  253     template <
typename Func>
 
  254     void for_each(Func func)
 const {
 
  255         string_list::for_each(
view(_str), func);
 
  259     template <
typename Func>
 
  261         string_list::rev_for_each_elem(
view(_str), func);
 
  264     template <
typename Func>
 
  265     void rev_for_each(Func func)
 const {
 
  266         string_list::rev_for_each(
view(_str), func);
 
  271         return string_list::join(
view(_str), sep, trail_sep);
 
  283     template <
typename Str>
 
  284     void _init(span<Str> names) {
 
  286         for(
const auto& name : names) {
 
  291         for(
const auto& name : names) {
 
  294         EAGINE_ASSERT(
span_size(_str.size()) == len);
 
  298         while(str.size() > 0) {
 
  299             if(str[str.size() - 1] == 
'\0') {
 
  308     template <
typename... Str>
 
  309     static inline auto _pack_names(
const Str&... n) noexcept
 
  311         return {{_fix(n)...}};
 
  317 #endif // EAGINE_STRING_PATH_HPP 
  
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
friend auto operator!=(const basic_string_path &a, const basic_string_path &b) noexcept
Non-equality comparison.
Definition: string_path.hpp:111
static constexpr auto as_bytes(basic_span< T, P, S > spn) noexcept -> basic_block< std::is_const_v< T >>
Converts a span into a basic_block.
Definition: block.hpp:39
basic_string_path(const std::array< string_view, N > &names)
Construction from a list of path element names.
Definition: string_path.hpp:92
static constexpr auto span_size(T v) noexcept
Converts argument to span size type.
Definition: types.hpp:59
Common code is placed in this namespace.
Definition: eagine.hpp:21
void pop_back()
Removes a single element from the end of this path.
Definition: string_path.hpp:210
void rev_for_each_elem(Func func) const
Calls the specified function for each element in reverse order.
Definition: string_path.hpp:260
string_list::iterator< const char * > iterator
Iterator type.
Definition: string_path.hpp:36
friend auto operator+(const basic_string_path &a, const basic_string_path &b) noexcept
Concatenates two paths.
Definition: string_path.hpp:145
auto block() noexcept -> memory::const_block
Returns a block covering the internal representation of this path.
Definition: string_path.hpp:275
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
span_size_t size_type
The element count type.
Definition: string_path.hpp:33
basic_string_path(EAGINE_TAG_TYPE(from_pack), string_view name, const Str &... names)
Construction from a pack of path element names.
Definition: string_path.hpp:97
static constexpr auto view(T *addr, S size) noexcept -> const_span< T >
Creates a view starting at the specified pointer and specified length.
Definition: span.hpp:458
basic_string_path() noexcept=default
Default constructor. Creates an empty path.
auto size() const noexcept -> size_type
Returns the number of elements in this path.
Definition: string_path.hpp:166
friend auto operator<=(const basic_string_path &a, const basic_string_path &b) noexcept
Less-equal comparison.
Definition: string_path.hpp:124
Basic class storing paths made of string elements.
Definition: string_path.hpp:27
void reserve_bytes(size_type s)
Reserves the specified number of bytes in the storage.
Definition: string_path.hpp:180
void clear() noexcept
Clears this path.
Definition: string_path.hpp:159
void for_each_elem(Func func) const
Calls the specified function for each element of this path.
Definition: string_path.hpp:249
basic_string_path(span< const string_view > names)
Construction from a list of path element names.
Definition: string_path.hpp:86
string_list::rev_iterator< const char * > reverse_iterator
Reverse iterator type.
Definition: string_path.hpp:39
static constexpr auto std_size(T v) noexcept
Converts argument to std size type.
Definition: types.hpp:52
#define EAGINE_TAG(NAME)
Macro for defining selector values corresponding to identifier NAME.
Definition: identifier.hpp:375
auto rend() const noexcept -> reverse_iterator
Returns an iterator pointing past the start of the path.
Definition: string_path.hpp:242
friend auto operator==(const basic_string_path &a, const basic_string_path &b) noexcept
Equality comparison.
Definition: string_path.hpp:104
basic_string_path(string_view path, EAGINE_TAG_TYPE(split_by), string_view sep)
Construction from a path string and a separator string.
Definition: string_path.hpp:72
void push_back(string_view name)
Appends a new element with the specified name to the end.
Definition: string_path.hpp:198
friend auto operator>(const basic_string_path &a, const basic_string_path &b) noexcept
Greater-than comparison.
Definition: string_path.hpp:132
auto rbegin() const noexcept -> reverse_iterator
Returns a reverse iterator pointing to the end of the path.
Definition: string_path.hpp:234
friend auto operator<(const basic_string_path &a, const basic_string_path &b) noexcept
Less-than comparison.
Definition: string_path.hpp:119
friend auto operator>=(const basic_string_path &a, const basic_string_path &b) noexcept
Greater-equal comparison.
Definition: string_path.hpp:137
auto back() const noexcept -> string_view
Returns the element at the back of the path.
Definition: string_path.hpp:191
auto begin() const noexcept -> iterator
Returns an iterator pointing to the start of the path.
Definition: string_path.hpp:219
auto as_string(string_view sep, bool trail_sep) const -> std::string
Returns this path as string with elements separated by sep.
Definition: string_path.hpp:270
auto front() const noexcept -> string_view
Returns the element at the front of the path.
Definition: string_path.hpp:185
#define EAGINE_TAG_TYPE(NAME)
Macro for defining selector types corresponding to identifier NAME.
Definition: identifier.hpp:367
auto empty() const noexcept -> bool
Indicates if this path is empty.
Definition: string_path.hpp:152
auto end() const noexcept -> iterator
Returns an iterator pointing past the end of the path.
Definition: string_path.hpp:226
static constexpr auto append_to(std::basic_string< C, T, A > &str, memory::basic_span< const C, P, S > spn) -> auto &
Appends the contents of a span of characters to a standard string.
Definition: string_span.hpp:147