AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::val::Path Class Reference

Path of a value from the root value (validation violations): segments are field names or map keys and collection items indexes. Formats format it their way (JSON Pointer with pointer , XPath for XML, ...). More...

#include <constraints.hpp>

Collaboration diagram for anch::val::Path:

Public Types

using Segment = std::variant<std::string, std::size_t>

Public Member Functions

 Path ()=default
 Path (std::vector< Segment > segments)
const std::vector< Segment > & segments () const noexcept
bool empty () const noexcept
std::string pointer () const
bool operator== (const Path &other) const =default

Detailed Description

Path of a value from the root value (validation violations): segments are field names or map keys and collection items indexes. Formats format it their way (JSON Pointer with pointer , XPath for XML, ...).

Author
Vincent Lachenal
Since
0.3

Member Typedef Documentation

◆ Segment

using anch::val::Path::Segment = std::variant<std::string, std::size_t>

Path segment: field name or map key, or collection item index

Constructor & Destructor Documentation

◆ Path() [1/2]

anch::val::Path::Path ( )
default

Root value path

◆ Path() [2/2]

anch::val::Path::Path ( std::vector< Segment > segments)
explicit

Path constructor

Parameters
segmentsthe segments, from the root value
Here is the call graph for this function:

Member Function Documentation

◆ empty()

bool anch::val::Path::empty ( ) const
noexcept

Check if path is the root value one

Returns
true for the root value
Here is the call graph for this function:

◆ operator==()

bool anch::val::Path::operator== ( const Path & other) const
default

Compare paths

Parameters
otherthe other path
Returns
true when segments are equal
Here is the call graph for this function:

◆ pointer()

std::string anch::val::Path::pointer ( ) const

Format path as a JSON Pointer (RFC 6901): /pets/1/name , empty for the root value ( ~ and / are escaped)

Returns
the JSON Pointer
Here is the call graph for this function:

◆ segments()

const std::vector< Segment > & anch::val::Path::segments ( ) const
noexcept

Segments getter

Returns
the segments, from the root value

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