diff --git a/doc/ref/jsonpath/basic_json_location.md b/doc/ref/jsonpath/basic_json_location.md new file mode 100644 index 0000000000..e3e1149285 --- /dev/null +++ b/doc/ref/jsonpath/basic_json_location.md @@ -0,0 +1,114 @@ +### jsoncons::jsonpath::basic_json_location + +```cpp +#include + +template +class basic_json_location +``` + +Two specializations for common character types are defined: + +Type |Definition +----------|------------------------------ +json_location |`basic_json_location` (since 0.172.0) +wjson_location |`basic_json_location` (since 0.172.0) + +Objects of type `basic_json_location` represent a normalized path. + +#### Member types +Type |Definition +------------|------------------------------ +char_type | `CharT` +string_type | `std::basic_string` +string_view_type | `jsoncons::basic_string_view` +const_iterator | A constant [LegacyRandomAccessIterator](https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator) with a `value_type` of `std::basic_string` +iterator | An alias to `const_iterator` + +#### Constructors + + basic_json_location(); (1) + + explicit basic_json_location(const string_view_type& str); + + explicit basic_json_location(const string_view_type& str, + std::error_code& ec); (2) + + basic_json_location(const basic_json_location&); (3) + + basic_json_location(basic_json_location&&) noexcept; (4) + +(1) Constructs an empty `basic_json_location`. + +(2) Constructs a `basic_json_location` from a string representation or a +URI fragment identifier (starts with `#`). + +#### operator= + + basic_json_location& operator=(const basic_json_location&); + + basic_json_location& operator=(basic_json_location&&); + +#### Modifiers + + basic_json_location& operator/=(const string_type& s) +Appends the token s. + + template + basic_json_location& operator/=(IntegerType index) +Appends the token `index`. +This overload only participates in overload resolution if `IntegerType` is an integer type. + + basic_json_location& operator+=(const basic_json_location& ptr) +Concatenates the current pointer and the specified pointer `ptr`. + +#### Iterators + + iterator begin() const; + iterator end() const; +Iterator access to the tokens in the pointer. + +#### Accessors + + bool empty() const +Checks if the pointer is empty + + string_type to_string() const +Returns a normalized path represented as a string value, escaping any `/` or `~` characters. + + string_type to_uri_fragment() const +Returns a string representing the normalized path as a URI fragment identifier, +escaping any `/` or `~` characters. + + +#### Static member functions + + static parse(const string_view_type& str); + static parse(const string_view_type& str, std::error_code& ec); +Constructs a `basic_json_location` from a string representation or a +URI fragment identifier (starts with `#`). + +#### Non-member functions + basic_json_location operator/(const basic_json_location& lhs, const basic_string& s); +Concatenates a normalized path pointer and a string. Effectively returns basic_json_location(lhs) /= s. + + template + basic_json_location operator/(const basic_json_location& lhs, IntegerType index); +Concatenates a normalized path pointer and an index. Effectively returns basic_json_location(lhs) /= index. +This overload only participates in overload resolution if `IntegerType` is an integer type. + + template + basic_json_location operator+( const basic_json_location& lhs, const basic_json_location& rhs ); +Concatenates two normalized paths. Effectively returns basic_json_location(lhs) += rhs. + + template + bool operator==(const basic_json_location& lhs, const basic_json_location& rhs); + + template + bool operator!=(const basic_json_location& lhs, const basic_json_location& rhs); + + template + std::basic_ostream& operator<<(std::basic_ostream& os, const basic_json_location& ptr); +Performs stream output + +