8#ifndef INCLUDED_BDLJSN_JSONNUMBER
9#define INCLUDED_BDLJSN_JSONNUMBER
371#include <bdlscm_version.h>
393#include <bsl_iosfwd.h>
394#include <bsl_string.h>
627 int asShort (
short *result)
const;
628 int asInt (
int *result)
const;
629 int asLong (
long *result)
const;
632 int asUshort (
unsigned short *result)
const;
633 int asUint (
unsigned int *result)
const;
634 int asUlong (
unsigned long *result)
const;
667#if defined(BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT)
674 explicit operator float()
const;
675 explicit operator double()
const;
703 bsl::ostream&
print(bsl::ostream& stream,
705 int spacesPerLevel = 4)
const;
734template <
class HASHALG>
766: d_value(1,
'0', allocator)
773: d_value(text, allocator)
781: d_value(text, allocator)
863: d_value(
bslmf::MovableRefUtil::move(text))
871: d_value(
bslmf::MovableRefUtil::move(text), allocator)
879: d_value(original.d_value, allocator)
894: d_value(
bslmf::MovableRefUtil::move(
895 bslmf::MovableRefUtil::access(original).d_value),
904 d_value = rhs.d_value;
1083 return static_cast<float>(
asDouble());
1108#if defined(BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT)
1112JsonNumber::operator float()
const
1118JsonNumber::operator double()
const
1126 return asDecimal64();
1150 return object.print(stream, 0, -1);
1157 return lhs.value() ==
rhs.value();
1164 return lhs.value() !=
rhs.value();
1168template <
class HASHALG>
Definition bdldfp_decimal.h:1890
Definition bdljsn_jsonnumber.h:412
int asUshort(unsigned short *result) const
Definition bdljsn_jsonnumber.h:1051
int asUlong(unsigned long *result) const
Definition bdljsn_jsonnumber.h:1063
JsonNumber()
Definition bdljsn_jsonnumber.h:759
JsonNumber & operator=(const JsonNumber &rhs)
Definition bdljsn_jsonnumber.h:902
static bool isValidNumber(const bsl::string_view &text)
Definition bdljsn_jsonnumber.h:752
int asUlonglong(unsigned long long *result) const
Definition bdljsn_jsonnumber.h:1069
int asUint64(bsls::Types::Uint64 *result) const
Definition bdljsn_jsonnumber.h:1075
allocator_type get_allocator() const
Return the allocator used by this object to supply memory.
Definition bdljsn_jsonnumber.h:1138
friend void swap(JsonNumber &, JsonNumber &)
BSLMF_NESTED_TRAIT_DECLARATION(JsonNumber, bslmf::IsBitwiseMoveable)
int asInt(int *result) const
Definition bdljsn_jsonnumber.h:1027
int asDecimal64Exact(bdldfp::Decimal64 *result) const
Definition bdljsn_jsonnumber.h:1101
const bsl::string & value() const
Return the textual representation of this JsonNumber.
Definition bdljsn_jsonnumber.h:1010
float asFloat() const
Definition bdljsn_jsonnumber.h:1081
int asShort(short *result) const
Definition bdljsn_jsonnumber.h:1021
int asInt64(bsls::Types::Int64 *result) const
Definition bdljsn_jsonnumber.h:1045
bsl::allocator allocator_type
Definition bdljsn_jsonnumber.h:439
int asLong(long *result) const
Definition bdljsn_jsonnumber.h:1033
bdldfp::Decimal64 asDecimal64() const
Definition bdljsn_jsonnumber.h:1093
bool isEqual(const JsonNumber &other) const
Definition bdljsn_jsonnumber.h:998
@ k_INEXACT
Definition bdljsn_jsonnumber.h:432
@ k_UNDERFLOW
Definition bdljsn_jsonnumber.h:428
@ k_NOT_INTEGRAL
Definition bdljsn_jsonnumber.h:429
@ k_OVERFLOW
Definition bdljsn_jsonnumber.h:427
bslma::Allocator *BSLS_ANNOTATION_DEPRECATED allocator() const
Definition bdljsn_jsonnumber.h:1132
int asUint(unsigned int *result) const
Definition bdljsn_jsonnumber.h:1057
double asDouble() const
Definition bdljsn_jsonnumber.h:1087
bool isIntegral() const
Definition bdljsn_jsonnumber.h:1004
int asLonglong(long long *result) const
Definition bdljsn_jsonnumber.h:1039
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bslma_bslallocator.h:588
BloombergLP::bslma::Allocator * mechanism() const
Definition bslma_bslallocator.h:1146
Definition bslstl_stringview.h:471
Definition bslstl_string.h:1252
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Return the allocator used by this string to supply memory.
Definition bslstl_string.h:7423
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:182
Definition bslma_allocator.h:545
Definition bslmf_movableref.h:752
#define BSLS_ANNOTATION_DEPRECATED
Definition bsls_annotation.h:324
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const BigEndianInt16 &object)
Decimal_Type64 Decimal64
Definition bdldfp_decimal.h:750
Definition bdljsn_error.h:142
bool operator!=(const Error &lhs, const Error &rhs)
void swap(Error &a, Error &b)
bool operator==(const Error &lhs, const Error &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const Error &object)
void hashAppend(HASHALG &hashAlgorithm, const Error &object)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition bdlbb_blob.h:579
static bool isNan(float number)
static bool isInfinite(float number)
static bool isNan(Decimal32 x)
static bool isInf(Decimal32 x)
Definition bdljsn_numberutil.h:190
static bool isIntegralNumber(const bsl::string_view &value)
static int asUint64(Uint64 *result, const bsl::string_view &value)
static int asDecimal64Exact(bdldfp::Decimal64 *result, const bsl::string_view &value)
@ k_UNDERFLOW
Definition bdljsn_numberutil.h:200
@ k_NOT_INTEGRAL
Definition bdljsn_numberutil.h:201
@ k_INEXACT
Definition bdljsn_numberutil.h:204
@ k_OVERFLOW
Definition bdljsn_numberutil.h:199
static bool isValidNumber(const bsl::string_view &value)
static int asUlonglong(unsigned long long *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:571
static int asUint(unsigned int *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:559
static double asDouble(const bsl::string_view &value)
Definition bdljsn_numberutil.h:494
static int asLonglong(long long *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:541
static bool areEqual(const bsl::string_view &lhs, const bsl::string_view &rhs)
static bdldfp::Decimal64 asDecimal64(const bsl::string_view &value)
static int asLong(long *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:535
static int asUlong(unsigned long *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:565
static int asShort(short *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:523
static int asInt(int *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:529
static void stringify(bsl::string *result, long long value)
static int asUshort(unsigned short *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:553
static int asInt64(Int64 *result, const bsl::string_view &value)
Definition bdljsn_numberutil.h:547
Definition bslmf_isbitwisemoveable.h:718
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1067
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1039
unsigned long long Uint64
Definition bsls_types.h:139
long long Int64
Definition bsls_types.h:134