8#ifndef INCLUDED_BALJSN_PARSERUTIL
9#define INCLUDED_BALJSN_PARSERUTIL
107#include <balscm_version.h>
120#include <bsl_limits.h>
121#include <bsl_cstring.h>
122#include <bsl_string.h>
123#include <bsl_string_view.h>
124#include <bsl_vector.h>
153 template <
class TYPE>
154 static int getDateAndTimeValue(TYPE *value,
166 template <
class TYPE>
177 template <
class TYPE>
178 static int getUnsignedIntegralValue(TYPE *value,
223 static int getValue(
unsigned char *value,
225 static int getValue(
signed char *value,
229 static int getValue(
unsigned short *value,
233 static int getValue(
unsigned int *value,
303int ParserUtil::getUnsignedIntegralValue(TYPE *value,
308 if (0 == data.length()) {
314 int rc = getUint64(&tmp, data);
324 *value =
static_cast<TYPE
>(tmp);
333 if (0 ==
data.length()) {
338 if (
'-' == data[0]) {
340 data.remove_prefix(1);
348 const int rc = getUint64(&tmp, data);
356 if (isNegative && tmp <= maxValue + 1) {
357 *value =
static_cast<TYPE
>(tmp * -1);
359 else if (tmp <= maxValue) {
360 *value =
static_cast<TYPE
>(tmp);
370int ParserUtil::getDateAndTimeValue(TYPE *value,
373 enum { k_STRING_LENGTH_WITH_QUOTES = 2 };
375 if (
data.length() < k_STRING_LENGTH_WITH_QUOTES
376 ||
'"' != *
data.begin()
377 ||
'"' != *(
data.end() - 1)) {
384 static_cast<int>(
data.length() - k_STRING_LENGTH_WITH_QUOTES));
391 const int rc = getIntegralValue(&tmp, data);
401 return getUnsignedIntegralValue(value, data);
407 return getValue((
char *) value, data);
413 return getIntegralValue(value, data);
419 return getUnsignedIntegralValue(value, data);
425 return getIntegralValue(value, data);
431 return getUnsignedIntegralValue(value, data);
438 return getIntegralValue(value, data);
445 return getUnsignedIntegralValue(value, data);
452 const int rc =
getValue(&tmp, data);
454 *value =
static_cast<float>(tmp);
471 return getDateAndTimeValue(value, data);
477 return getDateAndTimeValue(value, data);
483 return getDateAndTimeValue(value, data);
489 return getDateAndTimeValue(value, data);
495 return getDateAndTimeValue(value, data);
501 return getDateAndTimeValue(value, data);
507 return getDateAndTimeValue(value, data);
513 return getDateAndTimeValue(value, data);
520 return getDateAndTimeValue(value, data);
Definition bdlb_variant.h:2514
Definition bdldfp_decimal.h:1834
Definition bdlt_datetz.h:162
Definition bdlt_date.h:294
Definition bdlt_datetimetz.h:308
Definition bdlt_datetime.h:331
Definition bdlt_timetz.h:190
Definition bdlt_time.h:196
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
Definition bslstl_vector.h:1025
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition baljsn_datumdecoderoptions.h:113
BSLS_KEYWORD_CONSTEXPR CONTAINER::value_type * data(CONTAINER &container)
Definition bslstl_iterator.h:1231
Definition baljsn_parserutil.h:140
static int getValue(bool *value, const bsl::string_view &data)
static int getValue(bdldfp::Decimal64 *value, const bsl::string_view &data)
bdlb::Variant2< bdlt::Date, bdlt::DateTz > DateOrDateTz
Definition baljsn_parserutil.h:194
static int getValue(TimeOrTimeTz *value, const bsl::string_view &data)
static int getValue(DatetimeOrDatetimeTz *value, const bsl::string_view &data)
static int getValue(bsl::vector< char > *value, const bsl::string_view &data)
static int getQuotedString(bsl::string *value, const bsl::string_view &data)
Definition baljsn_parserutil.h:293
static int getValue(double *value, const bsl::string_view &data)
static bool stripQuotes(bsl::string_view *str)
bdlb::Variant2< bdlt::Datetime, bdlt::DatetimeTz > DatetimeOrDatetimeTz
Definition baljsn_parserutil.h:203
static int getUnquotedString(bsl::string *value, const bsl::string_view &data)
bdlb::Variant2< bdlt::Time, bdlt::TimeTz > TimeOrTimeTz
Definition baljsn_parserutil.h:198
@ e_ACCEPT_CAPITAL_UNICODE_ESCAPE
Definition bdljsn_stringutil.h:241
static int readString(bsl::string *value, const bsl::string_view &string, int flags=e_NONE)
Definition bdljsn_stringutil.h:285
static int parse(bsls::TimeInterval *result, const char *string, ssize_t length)
unsigned long long Uint64
Definition bsls_types.h:137
long long Int64
Definition bsls_types.h:132