9#ifndef INCLUDED_BSLFMT_FORMATTERSPECIFICATIONNUMERICVALUE
10#define INCLUDED_BSLFMT_FORMATTERSPECIFICATIONNUMERICVALUE
60#include <bslscm_version.h>
84#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_FORMAT)
142 template <
class t_ITER>
145 bool needInitialDot);
152 template <
typename t_FORMAT_CONTEXT>
219 template <
class t_TYPE>
227 template <
class t_TYPE>
244: d_category(e_DEFAULT)
253: d_category(category)
259template <
class t_ITER>
266 if (*start == end || **start ==
'}') {
271 t_ITER current = *start;
273 if (needInitialDot) {
275 if (*current !=
'.') {
281 if (current == end) {
283 "Invalid Precision (nothing after '.')"));
287 bool isArgId =
false;
289 if (*current ==
'{') {
291 if (current == end) {
292 BSLS_THROW(bsl::format_error(
"Nested arg id closing '}' "
297 if (*current ==
'}') {
300 *start = current + 1;
309 long long accumulator = 0;
310 while (*current >=
'0' && *current <=
'9') {
311 accumulator = (accumulator * 10) +
static_cast<int>(*current -
'0');
312 if (accumulator > INT_MAX) {
313 BSLS_THROW(bsl::format_error(
"Too large integer value"));
317 if (current == end) {
321 value =
static_cast<int>(accumulator);
324 if (digitCount == 0) {
329 "Nested argument id is not numeric"));
331 if (needInitialDot) {
333 "Invalid precision (no digits following '.')"));
344 if (current == end || *current !=
'}') {
346 "Nested argument id '}' is missing"));
357template <
typename t_FORMAT_CONTEXT>
360 const t_FORMAT_CONTEXT& context)
374 "INTERNAL ERROR: Unconverted dynamic nested argument"));
379#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_FORMAT)
394 return d_category == other.d_category && d_value == other.d_value;
402 BSLS_THROW(bsl::format_error(
"INTERNAL ERROR: Access to unspecified "
403 "nested value in format spec."));
407 bsl::format_error(
"INTERNAL ERROR: Failed to identify arg-id for "
408 "nested value in format spec."));
437 BSLS_THROW(bsl::format_error(
"Nested argument id out of range"));
443 BSLS_THROW(bsl::format_error(
"Nested value argument must be integral"));
446template <
class t_TYPE>
450 if (x < 0 || x > INT_MAX) {
452 bsl::format_error(
"Nested value argument out of range"));
454 d_value_p->d_value =
static_cast<int>(x);
458template <
class t_TYPE>
462 BSLS_THROW(bsl::format_error(
"Nested value argument must be integral"));
#define BSLS_THROW(X)
Definition bsls_exceptionutil.h:374
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_CONSTEXPR_CPP20
Definition bsls_keyword.h:645
Definition bslfmt_enablestreamedformatter.h:130
bsl::invoke_result< t_VISITOR &, bsl::monostate & >::type visit_format_arg(t_VISITOR &visitor, basic_format_arg< t_CONTEXT > arg)
Definition bslfmt_format_arg.h:907
Definition bdldfp_decimal.h:5549
Definition bslmf_enableif.h:530
Definition bslstl_monostate.h:77