#include <folly/Conv.h>
#include <array>
#include <istream>
#include <folly/lang/SafeAssert.h>
namespace folly {
namespace detail {
namespace {
inline const char* findFirstNonDigit(const char* b, const char* e) { … }
template <class T>
struct MaxString { … };
template <>
const char* const MaxString<uint8_t>::value = …;
template <>
const char* const MaxString<uint16_t>::value = …;
template <>
const char* const MaxString<uint32_t>::value = …;
#if __SIZEOF_LONG__ == 4
template <>
const char* const MaxString<unsigned long>::value = "4294967295";
#else
template <>
const char* const MaxString<unsigned long>::value = …;
#endif
static_assert …;
template <>
const char* const MaxString<unsigned long long>::value = …;
static_assert …;
#if FOLLY_HAVE_INT128_T
template <>
const char* const MaxString<__uint128_t>::value =
"340282366920938463463374607431768211455";
#endif
constexpr int32_t OOR = …;
alignas(16) constexpr uint16_t shift1[] = …;
alignas(16) constexpr uint16_t shift10[] = …;
alignas(16) constexpr uint16_t shift100[] = …;
alignas(16) constexpr uint16_t shift1000[] = …;
struct ErrorString { … };
constexpr const std::array<
ErrorString,
static_cast<std::size_t>(ConversionCode::NUM_ERROR_CODES)>
kErrorStrings{ … };
IsAscii;
inline char tolower_ascii(char in) { … }
inline bool bool_str_cmp(const char** b, size_t len, const char* value) { … }
}
Expected<bool, ConversionCode> str_to_bool(StringPiece* src) noexcept { … }
template <class Tgt>
Expected<Tgt, ConversionCode> str_to_floating(StringPiece* src) noexcept { … }
template Expected<float, ConversionCode> str_to_floating<float>(
StringPiece* src) noexcept;
template Expected<double, ConversionCode> str_to_floating<double>(
StringPiece* src) noexcept;
namespace {
template <typename T, bool IsSigned = is_signed_v<T>>
class SignedValueHandler;
SignedValueHandler<T, true>;
SignedValueHandler<T, false>;
}
template <class Tgt>
inline Expected<Tgt, ConversionCode> digits_to(
const char* b, const char* const e) noexcept { … }
template Expected<char, ConversionCode> digits_to<char>(
const char*, const char*) noexcept;
template Expected<signed char, ConversionCode> digits_to<signed char>(
const char*, const char*) noexcept;
template Expected<unsigned char, ConversionCode> digits_to<unsigned char>(
const char*, const char*) noexcept;
template Expected<short, ConversionCode> digits_to<short>(
const char*, const char*) noexcept;
template Expected<unsigned short, ConversionCode> digits_to<unsigned short>(
const char*, const char*) noexcept;
template Expected<int, ConversionCode> digits_to<int>(
const char*, const char*) noexcept;
template Expected<unsigned int, ConversionCode> digits_to<unsigned int>(
const char*, const char*) noexcept;
template Expected<long, ConversionCode> digits_to<long>(
const char*, const char*) noexcept;
template Expected<unsigned long, ConversionCode> digits_to<unsigned long>(
const char*, const char*) noexcept;
template Expected<long long, ConversionCode> digits_to<long long>(
const char*, const char*) noexcept;
template Expected<unsigned long long, ConversionCode>
digits_to<unsigned long long>(const char*, const char*) noexcept;
#if FOLLY_HAVE_INT128_T
template Expected<__int128, ConversionCode> digits_to<__int128>(
const char*, const char*) noexcept;
template Expected<unsigned __int128, ConversionCode>
digits_to<unsigned __int128>(const char*, const char*) noexcept;
#endif
template <class Tgt>
Expected<Tgt, ConversionCode> str_to_integral(StringPiece* src) noexcept { … }
template Expected<char, ConversionCode> str_to_integral<char>(
StringPiece* src) noexcept;
template Expected<signed char, ConversionCode> str_to_integral<signed char>(
StringPiece* src) noexcept;
template Expected<unsigned char, ConversionCode> str_to_integral<unsigned char>(
StringPiece* src) noexcept;
template Expected<short, ConversionCode> str_to_integral<short>(
StringPiece* src) noexcept;
template Expected<unsigned short, ConversionCode>
str_to_integral<unsigned short>(StringPiece* src) noexcept;
template Expected<int, ConversionCode> str_to_integral<int>(
StringPiece* src) noexcept;
template Expected<unsigned int, ConversionCode> str_to_integral<unsigned int>(
StringPiece* src) noexcept;
template Expected<long, ConversionCode> str_to_integral<long>(
StringPiece* src) noexcept;
template Expected<unsigned long, ConversionCode> str_to_integral<unsigned long>(
StringPiece* src) noexcept;
template Expected<long long, ConversionCode> str_to_integral<long long>(
StringPiece* src) noexcept;
template Expected<unsigned long long, ConversionCode>
str_to_integral<unsigned long long>(StringPiece* src) noexcept;
#if FOLLY_HAVE_INT128_T
template Expected<__int128, ConversionCode> str_to_integral<__int128>(
StringPiece* src) noexcept;
template Expected<unsigned __int128, ConversionCode>
str_to_integral<unsigned __int128>(StringPiece* src) noexcept;
#endif
#if defined(FOLLY_CONV_AVALIABILITY_TO_CHARS_FLOATING_POINT) && \
FOLLY_CONV_AVALIABILITY_TO_CHARS_FLOATING_POINT == 1
DtoaFlagsSet::DtoaFlagsSet(DtoaFlags flags) : … { … }
bool DtoaFlagsSet::isSet(DtoaFlags flag) const { … }
bool DtoaFlagsSet::emitPositiveExponentSign() const { … }
bool DtoaFlagsSet::emitTrailingDecimalPoint() const { … }
bool DtoaFlagsSet::emitTrailingZeroAfterPoint() const { … }
bool DtoaFlagsSet::uniqueZero() const { … }
bool DtoaFlagsSet::noTrailingZero() const { … }
int ParsedDecimal::numPrecisionFigures() const { … }
std::optional<detail::ParsedDecimal::FractionalSuffix>
ParsedDecimal::fractionalSuffix() const { … }
void ParsedDecimal::shiftFractionalSuffixPtrs(size_t amount) { … }
namespace {
struct Stream : std::istream { … };
}
ParsedDecimal::ParsedDecimal(char* begin, char* end) { … }
std::pair<char*, char*> formatAsDoubleConversion(
bool valueIsZero,
DtoaMode mode,
unsigned int numDigits,
DtoaFlags flags,
char* resultBegin,
char* resultEnd,
char* bufferEnd) { … }
#endif
}
ConversionError makeConversionError(ConversionCode code, StringPiece input) { … }
}