Common utilities for all the formats.
Classes | |
class | ConversionStack |
Used in the implementation of functions that convert between different formats, e.g. formats::yaml::Value to formats::json::Value, etc. More... | |
class | ItemsWrapper |
Wrapper for handy python-like iteration over a map. More... | |
struct | ItemsWrapperValue |
class | Path |
class | TransferTag |
This tag class is used to move a ValueBuilder object without copying. More... | |
Typedefs | |
template<typename Value , typename T > | |
using | ParseType = decltype(Parse(std::declval<Value>(), parse::To<T>())) |
Enumerations | |
enum class | IteratorDirection { kForward = 1 , kReverse = -1 } |
Helper to distinguish forward and reverse iterators for Value. More... | |
enum class | Type { kNull , kArray , kObject } |
Common enum of types. More... | |
Functions | |
template<typename ValueTo , typename ValueFrom > | |
ValueTo | PerformMinimalFormatConversion (ValueFrom &&value) |
Performs the conversion between different formats. Only supports basic formats node types, throws on any non-standard ones. | |
template<typename Value > | |
ItemsWrapper< Value > | Items (Value &&value) |
Wrapper for handy python-like iteration over a map. | |
template<typename Value > | |
void | Merge (typename Value::Builder &original, const Value &patch) |
Add to original new non-object elements from patch (overwriting the old ones, if any) and merge object elements recursively. | |
std::string | GetIndexString (size_t index) |
Returns string of [idx], e.g. "[0]" or "[1025]". | |
void | AppendPath (std::string &path, std::string_view key) |
void | AppendPath (std::string &path, std::size_t index) |
std::string | MakeChildPath (std::string_view parent, std::string_view key) |
std::string | MakeChildPath (std::string &&parent, std::string_view key) |
std::string | MakeChildPath (std::string_view parent, std::size_t index) |
std::string | MakeChildPath (std::string &&parent, std::size_t index) |
template<typename Value > | |
std::enable_if_t< common::kIsFormatValue< Value >, Value > | GetAtPath (Value parent, const std::vector< std::string > &path) |
Get the Value at path in parent . | |
template<typename ValueBuilder > | |
std::enable_if_t<!common::kIsFormatValue< ValueBuilder >, ValueBuilder > | GetAtPath (ValueBuilder &parent, std::vector< std::string > &&path) |
Get the ValueBuilder at path in parent . | |
template<typename Value > | |
void | SetAtPath (typename Value::Builder &parent, std::vector< std::string > &&path, Value new_value) |
Set the new_value along the path in the parent . | |
template<typename ValueBuilder > | |
void | RemoveAtPath (ValueBuilder &parent, std::vector< std::string > &&path) |
Remove the element along the path in the parent . | |
std::vector< std::string > | SplitPathString (std::string_view path) |
Split path to vector<std::string> by dots. | |
Variables | |
template<class Value > | |
constexpr bool | kIsFormatValue |
constexpr char | kPathSeparator = '.' |
constexpr char | kPathRoot [] = "/" |
constexpr char | kPathPrefixSeparator [] = ":/" |
using formats::common::ParseType = decltype(Parse(std::declval<Value>(), parse::To<T>())) |
|
strong |
Helper to distinguish forward and reverse iterators for Value.
Definition at line 8 of file iterator_direction.hpp.
|
strong |
std::enable_if_t< common::kIsFormatValue< Value >, Value > formats::common::GetAtPath | ( | Value | parent, |
const std::vector< std::string > & | path ) |
std::enable_if_t<!common::kIsFormatValue< ValueBuilder >, ValueBuilder > formats::common::GetAtPath | ( | ValueBuilder & | parent, |
std::vector< std::string > && | path ) |
ItemsWrapper< Value > formats::common::Items | ( | Value && | value | ) |
void formats::common::Merge | ( | typename Value::Builder & | original, |
const Value & | patch ) |
ValueTo formats::common::PerformMinimalFormatConversion | ( | ValueFrom && | value | ) |
Performs the conversion between different formats. Only supports basic formats node types, throws on any non-standard ones.
value.As<AnotherFormat>()
or value.ConvertTo<AnotherFormat>()
. Definition at line 156 of file conversion_stack.hpp.
void formats::common::RemoveAtPath | ( | ValueBuilder & | parent, |
std::vector< std::string > && | path ) |
void formats::common::SetAtPath | ( | typename Value::Builder & | parent, |
std::vector< std::string > && | path, | ||
Value | new_value ) |
std::vector< std::string > formats::common::SplitPathString | ( | std::string_view | path | ) |
Split path
to vector<std::string>
by dots.
path
has a double dot or a dot at the beginning or end, the result will contain an empty string. vector
if path
is empty
|
inlineconstexpr |
Used in Parse
overloads that are templated on Value
, avoids clashing with Parse
from string
|
inlineconstexpr |
|
inlineconstexpr |