NeBuild dev
Loading...
Searching...
No Matches
path Class Reference

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_componentoperator[] (size_t index) noexcept
 Fetch a path component by index.
 
TOML_PURE_INLINE_GETTER const path_componentoperator[] (size_t index) const noexcept
 Fetch a path component by index (const overload).
 
Assignment
pathoperator= (const path &)=default
 Copy-assignment operator.
 
pathoperator= (path &&) noexcept=default
 Move-assignment operator.
 
TOML_EXPORTED_MEMBER_FUNCTION pathoperator= (std::string_view)
 Replaces the contents of the path by parsing from a string.
 
TOML_EXPORTED_MEMBER_FUNCTION pathoperator= (std::wstring_view)
 Replaces the contents of the path by parsing from a string.
 
TOML_ALWAYS_INLINE pathassign (const path &p)
 Replaces the contents of the path with that of another.
 
TOML_ALWAYS_INLINE pathassign (path &&p) noexcept
 Replaces the contents of the path with that of another.
 
TOML_ALWAYS_INLINE pathassign (std::string_view str)
 Replaces the contents of the path object by a new path.
 
TOML_ALWAYS_INLINE pathassign (std::wstring_view str)
 Replaces the contents of the path object by a new path.
 
Appending
TOML_EXPORTED_MEMBER_FUNCTION pathoperator+= (const path &)
 Appends another path onto the end of this one.
 
TOML_EXPORTED_MEMBER_FUNCTION pathoperator+= (path &&)
 Appends another path onto the end of this one.
 
TOML_EXPORTED_MEMBER_FUNCTION pathoperator+= (std::string_view)
 Parses a path and appends it onto the end of this one.
 
TOML_EXPORTED_MEMBER_FUNCTION pathoperator+= (std::wstring_view)
 Parses a path and appends it onto the end of this one.
 
TOML_ALWAYS_INLINE pathappend (const path &p)
 Appends another path onto the end of this one.
 
TOML_ALWAYS_INLINE pathappend (path &&p)
 Appends another path onto the end of this one.
 
TOML_ALWAYS_INLINE pathappend (std::string_view str)
 Parses a path and appends it onto the end of this one.
 
TOML_ALWAYS_INLINE pathappend (std::wstring_view str)
 Parses a path and appends it onto the end of this one.
 
Prepending
TOML_EXPORTED_MEMBER_FUNCTION pathprepend (const path &)
 Prepends another path onto the beginning of this one.
 
TOML_EXPORTED_MEMBER_FUNCTION pathprepend (path &&)
 Prepends another path onto the beginning of this one.
 
TOML_EXPORTED_MEMBER_FUNCTION pathprepend (std::string_view)
 Parses a path and prepends it onto the beginning of this one.
 
TOML_EXPORTED_MEMBER_FUNCTION pathprepend (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 pathtruncate (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.
 

Detailed Description

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

Member Typedef Documentation

◆ const_iterator

using path::const_iterator = std::vector<path_component>::const_iterator

A const iterator for iterating over the components in the path.

See also
#toml::path_component

◆ iterator

using path::iterator = std::vector<path_component>::iterator

An iterator for iterating over the components in the path.

See also
#toml::path_component

Constructor & Destructor Documentation

◆ path() [1/5]

TOML_NODISCARD_CTOR path::path ( )
defaultnoexcept

Default constructor.

◆ path() [2/5]

TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path::path ( std::string_view  )
explicit

Construct a path by parsing from a string.

◆ path() [3/5]

TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path::path ( std::wstring_view  )
explicit

Construct a path by parsing from a string.

\availability This constructor is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ ~path()

path::~path ( )
defaultnoexcept

Default destructor.

◆ path() [4/5]

TOML_NODISCARD_CTOR path::path ( const path )
default

Copy constructor.

◆ path() [5/5]

TOML_NODISCARD_CTOR path::path ( path &&  )
defaultnoexcept

Move constructor.

Member Function Documentation

◆ append() [1/4]

TOML_ALWAYS_INLINE path & path::append ( const path p)
inline

Appends another path onto the end of this one.

◆ append() [2/4]

TOML_ALWAYS_INLINE path & path::append ( path &&  p)
inline

Appends another path onto the end of this one.

◆ append() [3/4]

TOML_ALWAYS_INLINE path & path::append ( std::string_view  str)
inline

Parses a path and appends it onto the end of this one.

◆ append() [4/4]

TOML_ALWAYS_INLINE path & path::append ( std::wstring_view  str)
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.

◆ assign() [1/4]

TOML_ALWAYS_INLINE path & path::assign ( const path p)
inline

Replaces the contents of the path with that of another.

◆ assign() [2/4]

TOML_ALWAYS_INLINE path & path::assign ( path &&  p)
inlinenoexcept

Replaces the contents of the path with that of another.

◆ assign() [3/4]

TOML_ALWAYS_INLINE path & path::assign ( std::string_view  str)
inline

Replaces the contents of the path object by a new path.

◆ assign() [4/4]

TOML_ALWAYS_INLINE path & path::assign ( std::wstring_view  str)
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.

◆ begin() [1/2]

TOML_PURE_INLINE_GETTER const_iterator path::begin ( ) const
inlinenoexcept

Returns a const iterator to the first component in the path.

See also
#toml::path_component

◆ begin() [2/2]

TOML_PURE_INLINE_GETTER iterator path::begin ( )
inlinenoexcept

Returns an iterator to the first component in the path.

See also
#toml::path_component

◆ cbegin()

TOML_PURE_INLINE_GETTER const_iterator path::cbegin ( ) const
inlinenoexcept

Returns a const iterator to the first component in the path.

See also
#toml::path_component

◆ cend()

TOML_PURE_INLINE_GETTER const_iterator path::cend ( ) const
inlinenoexcept

Returns a const iterator to one-past-the-last component in the path.

See also
#toml::path_component

◆ clear()

TOML_EXPORTED_MEMBER_FUNCTION void path::clear ( )
noexcept

Erases the contents of the path.

◆ empty()

TOML_PURE_INLINE_GETTER bool path::empty ( ) const
inlinenoexcept

Whether (true) or not (false) the path is empty.

◆ end() [1/2]

TOML_PURE_INLINE_GETTER const_iterator path::end ( ) const
inlinenoexcept

Returns a const iterator to one-past-the-last component in the path.

See also
#toml::path_component

◆ end() [2/2]

TOML_PURE_INLINE_GETTER iterator path::end ( )
inlinenoexcept

Returns an iterator to one-past-the-last component in the path.

See also
#toml::path_component

◆ leaf()

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.

◆ operator bool()

TOML_PURE_INLINE_GETTER path::operator bool ( ) const
inlineexplicitnoexcept

Returns true if the path has one or more components.

◆ operator std::string()

TOML_NODISCARD TOML_ALWAYS_INLINE path::operator std::string ( ) const
inlineexplicit

Returns a string representation of this path.

◆ operator std::wstring()

TOML_NODISCARD TOML_ALWAYS_INLINE path::operator std::wstring ( ) const
inlineexplicit

Returns a string representation of this path.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ operator+=() [1/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= ( const path )

Appends another path onto the end of this one.

◆ operator+=() [2/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= ( path &&  )

Appends another path onto the end of this one.

◆ operator+=() [3/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::operator+= ( std::string_view  )

Parses a path and appends it onto the end of this one.

◆ operator+=() [4/4]

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.

◆ operator=() [1/4]

path & path::operator= ( const path )
default

Copy-assignment operator.

◆ operator=() [2/4]

path & path::operator= ( path &&  )
defaultnoexcept

Move-assignment operator.

◆ operator=() [3/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::operator= ( std::string_view  )

Replaces the contents of the path by parsing from a string.

◆ operator=() [4/4]

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.

◆ operator[]() [1/2]

TOML_PURE_INLINE_GETTER const path_component & path::operator[] ( size_t  index) const
inlinenoexcept

Fetch a path component by index (const overload).

◆ operator[]() [2/2]

TOML_PURE_INLINE_GETTER path_component & path::operator[] ( size_t  index)
inlinenoexcept

Fetch a path component by index.

◆ parent()

Returns a toml::path object representing the path of the parent node.

◆ prepend() [1/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend ( const path )

Prepends another path onto the beginning of this one.

◆ prepend() [2/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend ( path &&  )

Prepends another path onto the beginning of this one.

◆ prepend() [3/4]

TOML_EXPORTED_MEMBER_FUNCTION path & path::prepend ( std::string_view  )

Parses a path and prepends it onto the beginning of this one.

◆ prepend() [4/4]

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.

◆ size()

TOML_PURE_INLINE_GETTER size_t path::size ( ) const
inlinenoexcept

Returns the number of components in the path.

◆ str()

TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION std::string path::str ( ) const

Returns a string representation of this path.

◆ subpath() [1/2]

Returns a toml::path object that is a specified subpath of the current path, representing the range of path components from [start, end).

◆ subpath() [2/2]

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].

◆ truncate()

TOML_EXPORTED_MEMBER_FUNCTION path & path::truncate ( size_t  n)

Removes the number of terminal path components specified by n.

◆ truncated()

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.

◆ wide_str()

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.

Friends And Related Symbol Documentation

◆ operator!= [1/5]

TOML_PURE_INLINE_GETTER friend bool operator!= ( const path lhs,
const path rhs 
)
friend

Returns whether two paths are not the same.

◆ operator!= [2/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator!= ( const path lhs,
std::string_view  rhs 
)
friend

Returns whether two paths are not the same.

◆ operator!= [3/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator!= ( const path lhs,
std::wstring_view  rhs 
)
friend

Returns whether two paths are not the same.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ operator!= [4/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator!= ( std::string_view  lhs,
const path rhs 
)
friend

Returns whether two paths are not the same.

◆ operator!= [5/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator!= ( std::wstring_view  lhs,
const path rhs 
)
friend

Returns whether two paths are not the same.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ operator+ [1/5]

TOML_NODISCARD friend path operator+ ( const path lhs,
const path rhs 
)
friend

Concatenates two paths.

◆ operator+ [2/5]

TOML_NODISCARD friend path operator+ ( const path lhs,
std::string_view  rhs 
)
friend

Concatenates two paths.

◆ operator+ [3/5]

TOML_NODISCARD friend path operator+ ( const path lhs,
std::wstring_view  rhs 
)
friend

Concatenates two paths.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ operator+ [4/5]

TOML_NODISCARD friend path operator+ ( std::string_view  lhs,
const path rhs 
)
friend

Concatenates two paths.

◆ operator+ [5/5]

TOML_NODISCARD friend path operator+ ( std::wstring_view  lhs,
const path rhs 
)
friend

Concatenates two paths.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ operator<<

TOML_ALWAYS_INLINE friend std::ostream & operator<< ( std::ostream &  os,
const path rhs 
)
friend

Prints the string representation of a #toml::path out to a stream.

◆ operator== [1/5]

TOML_PURE_INLINE_GETTER friend bool operator== ( const path lhs,
const path rhs 
)
friend

Returns whether two paths are the same.

◆ operator== [2/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator== ( const path lhs,
std::string_view  rhs 
)
friend

Returns whether two paths are the same.

◆ operator== [3/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator== ( const path lhs,
std::wstring_view  rhs 
)
friend

Returns whether two paths are the same.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

◆ operator== [4/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator== ( std::string_view  lhs,
const path rhs 
)
friend

Returns whether two paths are the same.

◆ operator== [5/5]

TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator== ( std::wstring_view  lhs,
const path rhs 
)
friend

Returns whether two paths are the same.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.


The documentation for this class was generated from the following file: