20#ifndef BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED
21#define BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED
23#include <xrpl/beast/utility/instrumentation.h>
25#include <boost/core/detail/string_view.hpp>
42template <
class Out,
class In>
51 template <
class Arithmetic = In>
59 template <
class Enumeration = In>
70template <
typename Out>
76 std::is_integral_v<Out>,
77 "beast::LexicalCast can only be used with integral types");
79 template <
class Integral = Out>
81 std::is_integral_v<Integral> && !std::is_same_v<Integral, bool>,
85 auto first = in.data();
86 auto last = in.data() + in.size();
88 if (first != last && *first ==
'+')
93 return ret.ec ==
std::errc() && ret.ptr == last;
104 return std::tolower(static_cast<unsigned char>(c));
107 if (result ==
"1" || result ==
"true")
113 if (result ==
"0" || result ==
"false")
135 operator()(Out& out, boost::core::basic_string_view<char> in)
const
164 in,
"beast::detail::LexicalCast(char const*) : non-null input");
179 XRPL_ASSERT(in,
"beast::detail::LexicalCast(char*) : non-null input");
199template <
class Out,
class In>
212template <
class Out,
class In>
227template <
class Out,
class In>
T back_inserter(T... args)
Out lexicalCastThrow(In in)
Convert from one type to another, throw on error.
Out lexicalCast(In in, Out defaultValue=Out())
Convert from one type to another.
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
Thrown when a conversion is not possible with LexicalCast.
bool operator()(Out &out, boost::core::basic_string_view< char > in) const
bool operator()(Out &out, char *in) const
bool operator()(Out &out, char const *in) const
bool operator()(Out &out, std::string in) const
std::enable_if_t< std::is_integral_v< Integral > &&!std::is_same_v< Integral, bool >, bool > operator()(Integral &out, std::string_view in) const
bool operator()(bool &out, std::string_view in) const
std::enable_if_t< std::is_arithmetic_v< Arithmetic >, bool > operator()(std::string &out, Arithmetic in)
std::enable_if_t< std::is_enum_v< Enumeration >, bool > operator()(std::string &out, Enumeration in)