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

Detailed Description

Cheap checks that tell when parsing a value is certain to fail, for skipping alternatives without throwing an exception.

Definition in file may_parse.hpp.

Go to the source code of this file.

#include <exception>
#include <string>
#include <type_traits>
#include <userver/formats/parse/to.hpp>
#include <userver/utils/meta_light.hpp>
This graph shows which files directly or indirectly include this file:

Namespaces

namespace  formats
 Value formats representation, parsing and serialization.
namespace  formats::json
 JSON support.
namespace  formats::parse
 Generic parsers and converters.

Functions

template<typename Value, typename T>
bool formats::parse::MayParseAs (const Value &, To< T >) noexcept
 Fallback for types without a check: returns true, so the value has to be parsed.
bool formats::parse::MayParseAs (const formats::json::Value &value, To< std::string >)
 Built-in check for std::string: returns false if the JSON value is not a string.
bool formats::parse::MayParseAs (const formats::json::Value &value, To< bool >)
 Built-in check for bool: returns false if the JSON value is not a boolean.
template<typename T>
requires (meta::IsInteger<T> || std::is_floating_point_v<T>)
bool formats::parse::MayParseAs (const formats::json::Value &value, To< T >)
 Built-in check for integer and floating point types: returns false if the JSON value is not a number.
template<typename T, typename Value>
bool formats::parse::MayParseAs (const Value &value)
 Cheap necessary condition for value.As<T>() to succeed.