NeBuild dev
|
A TOML path. More...
#include <path.hpp>
Public Member Functions | |
TOML_NODISCARD_CTOR | path () noexcept=default |
Default constructor. | |
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION | path (std::string_view) |
Construct a path by parsing from a string. | |
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION | path (std::wstring_view) |
Construct a path by parsing from a string. | |
~path () noexcept=default | |
Default destructor. | |
TOML_NODISCARD_CTOR | path (const path &)=default |
Copy constructor. | |
TOML_NODISCARD_CTOR | path (path &&) noexcept=default |
Move constructor. | |
TOML_PURE_INLINE_GETTER size_t | size () const noexcept |
Returns the number of components in the path. | |
TOML_PURE_INLINE_GETTER | operator bool () const noexcept |
Returns true if the path has one or more components. | |
TOML_PURE_INLINE_GETTER bool | empty () const noexcept |
Whether (true) or not (false) the path is empty. | |
TOML_PURE_INLINE_GETTER path_component & | operator[] (size_t index) noexcept |
Fetch a path component by index. | |
TOML_PURE_INLINE_GETTER const path_component & | operator[] (size_t index) const noexcept |
Fetch a path component by index (const overload). | |
Assignment | |
path & | operator= (const path &)=default |
Copy-assignment operator. | |
path & | operator= (path &&) noexcept=default |
Move-assignment operator. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | operator= (std::string_view) |
Replaces the contents of the path by parsing from a string. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | operator= (std::wstring_view) |
Replaces the contents of the path by parsing from a string. | |
TOML_ALWAYS_INLINE path & | assign (const path &p) |
Replaces the contents of the path with that of another. | |
TOML_ALWAYS_INLINE path & | assign (path &&p) noexcept |
Replaces the contents of the path with that of another. | |
TOML_ALWAYS_INLINE path & | assign (std::string_view str) |
Replaces the contents of the path object by a new path. | |
TOML_ALWAYS_INLINE path & | assign (std::wstring_view str) |
Replaces the contents of the path object by a new path. | |
Appending | |
TOML_EXPORTED_MEMBER_FUNCTION path & | operator+= (const path &) |
Appends another path onto the end of this one. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | operator+= (path &&) |
Appends another path onto the end of this one. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | operator+= (std::string_view) |
Parses a path and appends it onto the end of this one. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | operator+= (std::wstring_view) |
Parses a path and appends it onto the end of this one. | |
TOML_ALWAYS_INLINE path & | append (const path &p) |
Appends another path onto the end of this one. | |
TOML_ALWAYS_INLINE path & | append (path &&p) |
Appends another path onto the end of this one. | |
TOML_ALWAYS_INLINE path & | append (std::string_view str) |
Parses a path and appends it onto the end of this one. | |
TOML_ALWAYS_INLINE path & | append (std::wstring_view str) |
Parses a path and appends it onto the end of this one. | |
Prepending | |
TOML_EXPORTED_MEMBER_FUNCTION path & | prepend (const path &) |
Prepends another path onto the beginning of this one. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | prepend (path &&) |
Prepends another path onto the beginning of this one. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | prepend (std::string_view) |
Parses a path and prepends it onto the beginning of this one. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | prepend (std::wstring_view) |
Parses a path and prepends it onto the beginning of this one. | |
Subpaths and Truncation | |
TOML_EXPORTED_MEMBER_FUNCTION void | clear () noexcept |
Erases the contents of the path. | |
TOML_EXPORTED_MEMBER_FUNCTION path & | truncate (size_t n) |
Removes the number of terminal path components specified by n. | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path | truncated (size_t n) const |
Returns a toml::path object which has had n terminal path components removed. | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path | parent () const |
Returns a toml::path object representing the path of the parent node. | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path | leaf (size_t n=1) const |
Returns a toml::path object representing terminal n-parts of a TOML path. | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path | subpath (const_iterator start, const_iterator end) const |
Returns a toml::path object that is a specified subpath of the current path, representing the range of path components from [start, end). | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path | subpath (size_t start, size_t length) const |
Returns a toml::path object that is a specified subpath of the current path, representing the range of path components with indexes from [start, start + length]. | |
Friends | |
Concatenation | |
TOML_NODISCARD friend path | operator+ (const path &lhs, const path &rhs) |
Concatenates two paths. | |
TOML_NODISCARD friend path | operator+ (const path &lhs, std::string_view rhs) |
Concatenates two paths. | |
TOML_NODISCARD friend path | operator+ (std::string_view lhs, const path &rhs) |
Concatenates two paths. | |
TOML_NODISCARD friend path | operator+ (const path &lhs, std::wstring_view rhs) |
Concatenates two paths. | |
TOML_NODISCARD friend path | operator+ (std::wstring_view lhs, const path &rhs) |
Concatenates two paths. | |
Equality | |
TOML_PURE_INLINE_GETTER friend bool | operator== (const path &lhs, const path &rhs) noexcept |
Returns whether two paths are the same. | |
TOML_PURE_INLINE_GETTER friend bool | operator!= (const path &lhs, const path &rhs) noexcept |
Returns whether two paths are not the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator== (const path &lhs, std::string_view rhs) |
Returns whether two paths are the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator== (std::string_view lhs, const path &rhs) |
Returns whether two paths are the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator!= (const path &lhs, std::string_view rhs) |
Returns whether two paths are not the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator!= (std::string_view lhs, const path &rhs) |
Returns whether two paths are not the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator== (const path &lhs, std::wstring_view rhs) |
Returns whether two paths are the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator== (std::wstring_view lhs, const path &rhs) |
Returns whether two paths are the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator!= (const path &lhs, std::wstring_view rhs) |
Returns whether two paths are not the same. | |
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool | operator!= (std::wstring_view lhs, const path &rhs) |
Returns whether two paths are not the same. | |
Iteration | |
using | iterator = std::vector< path_component >::iterator |
using | const_iterator = std::vector< path_component >::const_iterator |
TOML_PURE_INLINE_GETTER iterator | begin () noexcept |
Returns an iterator to the first component in the path. | |
TOML_PURE_INLINE_GETTER iterator | end () noexcept |
Returns an iterator to one-past-the-last component in the path. | |
TOML_PURE_INLINE_GETTER const_iterator | begin () const noexcept |
Returns a const iterator to the first component in the path. | |
TOML_PURE_INLINE_GETTER const_iterator | end () const noexcept |
Returns a const iterator to one-past-the-last component in the path. | |
TOML_PURE_INLINE_GETTER const_iterator | cbegin () const noexcept |
Returns a const iterator to the first component in the path. | |
TOML_PURE_INLINE_GETTER const_iterator | cend () const noexcept |
Returns a const iterator to one-past-the-last component in the path. | |
String conversion | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION std::string | str () const |
Returns a string representation of this path. | |
TOML_NODISCARD TOML_ALWAYS_INLINE | operator std::string () const |
Returns a string representation of this path. | |
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION std::wstring | wide_str () const |
Returns a string representation of this path. | |
TOML_NODISCARD TOML_ALWAYS_INLINE | operator std::wstring () const |
Returns a string representation of this path. | |
TOML_ALWAYS_INLINE friend std::ostream & | operator<< (std::ostream &os, const path &rhs) |
Prints the string representation of a #toml::path out to a stream. | |
A TOML path.
\detail This type parses and represents a path to a TOML node. It validates the syntax of the path but does not ensure that the path refers to a valid node in any particular TOML document. If parsing fails, the object will evaluate as 'falsy', and will be empty.
\cpp toml::path the_path("animals.cats[1]");
// can use with tbl.at_path or operator[] std::cout << "second cat: " << tbl[the_path] << "\n"; std::cout << "cats: " << tbl.at_path(the_path.parent_path()) << "\n"; \ecpp
\out second cat: lion cats: ['tiger', 'lion', 'puma'] \eout
using path::const_iterator = std::vector<path_component>::const_iterator |
A const iterator for iterating over the components in the path.
using path::iterator = std::vector<path_component>::iterator |
An iterator for iterating over the components in the path.
|
defaultnoexcept |
Default constructor.
|
explicit |
Construct a path by parsing from a string.
|
explicit |
Construct a path by parsing from a string.
\availability This constructor is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
defaultnoexcept |
Default destructor.
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
inline |
Appends another path onto the end of this one.
|
inline |
Appends another path onto the end of this one.
|
inline |
Parses a path and appends it onto the end of this one.
|
inline |
Parses a path and appends it onto the end of this one.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
inline |
Replaces the contents of the path with that of another.
|
inlinenoexcept |
Replaces the contents of the path with that of another.
|
inline |
Replaces the contents of the path object by a new path.
|
inline |
Replaces the contents of the path object by a new path.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
inlinenoexcept |
Returns a const iterator to the first component in the path.
|
inlinenoexcept |
Returns an iterator to the first component in the path.
|
inlinenoexcept |
Returns a const iterator to the first component in the path.
|
inlinenoexcept |
Returns a const iterator to one-past-the-last component in the path.
|
noexcept |
Erases the contents of the path.
|
inlinenoexcept |
Whether (true) or not (false) the path is empty.
|
inlinenoexcept |
Returns a const iterator to one-past-the-last component in the path.
|
inlinenoexcept |
Returns an iterator to one-past-the-last component in the path.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path path::leaf | ( | size_t | n = 1 | ) | const |
Returns a toml::path object representing terminal n-parts of a TOML path.
|
inlineexplicitnoexcept |
Returns true if the path has one or more components.
|
inlineexplicit |
Returns a string representation of this path.
|
inlineexplicit |
Returns a string representation of this path.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= | ( | const path & | ) |
Appends another path onto the end of this one.
TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= | ( | path && | ) |
Appends another path onto the end of this one.
TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= | ( | std::string_view | ) |
Parses a path and appends it onto the end of this one.
TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= | ( | std::wstring_view | ) |
Parses a path and appends it onto the end of this one.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_EXPORTED_MEMBER_FUNCTION path & path::operator= | ( | std::string_view | ) |
Replaces the contents of the path by parsing from a string.
TOML_EXPORTED_MEMBER_FUNCTION path & path::operator= | ( | std::wstring_view | ) |
Replaces the contents of the path by parsing from a string.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
inlinenoexcept |
Fetch a path component by index (const overload).
|
inlinenoexcept |
Fetch a path component by index.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path path::parent | ( | ) | const |
Returns a toml::path object representing the path of the parent node.
TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend | ( | const path & | ) |
Prepends another path onto the beginning of this one.
TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend | ( | path && | ) |
Prepends another path onto the beginning of this one.
TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend | ( | std::string_view | ) |
Parses a path and prepends it onto the beginning of this one.
TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend | ( | std::wstring_view | ) |
Parses a path and prepends it onto the beginning of this one.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
inlinenoexcept |
Returns the number of components in the path.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION std::string path::str | ( | ) | const |
Returns a string representation of this path.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path path::subpath | ( | const_iterator | start, |
const_iterator | end | ||
) | const |
Returns a toml::path object that is a specified subpath of the current path, representing the range of path components from [start, end).
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path path::subpath | ( | size_t | start, |
size_t | length | ||
) | const |
Returns a toml::path object that is a specified subpath of the current path, representing the range of path components with indexes from [start, start + length].
TOML_EXPORTED_MEMBER_FUNCTION path & path::truncate | ( | size_t | n | ) |
Removes the number of terminal path components specified by n.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path path::truncated | ( | size_t | n | ) | const |
Returns a toml::path object which has had n terminal path components removed.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION std::wstring path::wide_str | ( | ) | const |
Returns a string representation of this path.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
friend |
Returns whether two paths are not the same.
|
friend |
Returns whether two paths are not the same.
|
friend |
Returns whether two paths are not the same.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
friend |
Returns whether two paths are not the same.
|
friend |
Returns whether two paths are not the same.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
friend |
Concatenates two paths.
|
friend |
Concatenates two paths.
|
friend |
Concatenates two paths.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
friend |
Concatenates two paths.
|
friend |
Concatenates two paths.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
friend |
Prints the string representation of a #toml::path out to a stream.
|
friend |
Returns whether two paths are the same.
|
friend |
Returns whether two paths are the same.
|
friend |
Returns whether two paths are the same.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
friend |
Returns whether two paths are the same.
|
friend |
Returns whether two paths are the same.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.