userver: userver/formats/parse/variant.hpp File Reference
Loading...
Searching...
No Matches
variant.hpp File Reference

Detailed Description

Generic parser for std::variant type.

Parsing is performed for each of the N alternatives in variant, and an exception is thrown and caught for each alternative that fails to parse. Alternatives that formats::parse::MayParseAs rejects are parsed only if no alternative fits, to report their errors.

Definition in file variant.hpp.

Go to the source code of this file.

#include <array>
#include <cstddef>
#include <exception>
#include <optional>
#include <string>
#include <typeinfo>
#include <utility>
#include <variant>
#include <fmt/format.h>
#include <userver/compiler/demangle.hpp>
#include <userver/formats/parse/may_parse.hpp>
#include <userver/formats/parse/to.hpp>

Namespaces

namespace  formats
 Value formats representation, parsing and serialization.
namespace  formats::json
 JSON support.
namespace  formats::parse
 Generic parsing helpers (formats::parse::To and friends).

Functions

template<typename ParseException, typename Variant, typename TypeA>
void formats::parse::ThrowVariantAmbiguousParse (std::string_view path, std::type_index type_b)
template<class ParseException, typename Variant>
void formats::parse::ThrowVariantParseException (std::string_view path, std::string_view errors)
template<class Value, typename... Types>
std::variant< decltype(Parse(std::declval< Value >(), To< Types >{}))... > formats::parse::Parse (const Value &value, formats::parse::To< std::variant< Types... > >)