8#ifndef INCLUDED_BSLALG_NUMERICFORMATTERUTIL
9#define INCLUDED_BSLALG_NUMERICFORMATTERUTIL
364#include <bslscm_version.h>
399 static char *toCharsImpl(
char *first,
414 char *toCharsImpl(
char *first,
416 unsigned long long int value,
430 template <
class TYPE>
431 static char *toCharsIntegral(
char *first,
443 static char *toCharsDecimal(
char *first,
446 static char *toCharsDecimal(
char *first,
457 static char *toCharsScientific(
char *first,
460 static char *toCharsScientific(
char *first,
478 enum { k_MAXLEN_ARG_DEFAULT = -256 };
491 template <
class FLT_TYPE,
int FORMAT>
502 template <
bool IS_SIGNED,
unsigned SIZEOF,
int BASE>
510 template <
class TYPE>
511 struct IsSupportedFloatingPoint;
518 template <
class TYPE>
519 struct IsSupportedIntegral;
555 template <
class TYPE,
556 int ARG = k_MAXLEN_ARG_DEFAULT>
557 struct ToCharsMaxLength;
585 char *toChars(
char *first,
590 char *toChars(
char *first,
595 char *toChars(
char *first,
600 char *toChars(
char *first,
602 signed short int value,
605 char *toChars(
char *first,
607 unsigned short int value,
610 char *toChars(
char *first,
615 char *toChars(
char *first,
620 char *toChars(
char *first,
622 signed long int value,
625 char *toChars(
char *first,
627 unsigned long int value,
630 char *toChars(
char *first,
632 signed long long int value,
635 char *toChars(
char *first,
637 unsigned long long int value,
640 char *toChars(
char *first,
644 char *toChars(
char *first,
648 char *toChars(
char *first,
653 char *toChars(
char *first,
663template <class FLT_TYPE,
int FORMAT>
686#define BSLALG_NUMERICFORMATTERUTIL_INTMAXLEN_ONE(issigned, bytes, \
687 val02, val03, val04, val05, val06, val07, val08, val09, val10, \
688 val11, val12, val13, val14, val15, val16, val17, val18, val19, val20, \
689 val21, val22, val23, val24, val25, val26, val27, val28, val29, val30, \
690 val31, val32, val33, val34, val35, val36) \
691 template <int BASE> \
692 struct NumericFormatterUtil::IntMaxLen<issigned, bytes, BASE> { \
694 k_VALUE = (BASE == 2) ? val02 \
695 : (BASE == 3) ? val03 \
696 : (BASE == 4) ? val04 \
697 : (BASE == 5) ? val05 \
698 : (BASE == 6) ? val06 \
699 : (BASE == 7) ? val07 \
700 : (BASE == 8) ? val08 \
701 : (BASE == 9) ? val09 \
702 : (BASE == 10) ? val10 \
703 : (BASE == 11) ? val11 \
704 : (BASE == 12) ? val12 \
705 : (BASE == 13) ? val13 \
706 : (BASE == 14) ? val14 \
707 : (BASE == 15) ? val15 \
708 : (BASE == 16) ? val16 \
709 : (BASE == 17) ? val17 \
710 : (BASE == 18) ? val18 \
711 : (BASE == 19) ? val19 \
712 : (BASE == 20) ? val20 \
713 : (BASE == 21) ? val21 \
714 : (BASE == 22) ? val22 \
715 : (BASE == 23) ? val23 \
716 : (BASE == 24) ? val24 \
717 : (BASE == 25) ? val25 \
718 : (BASE == 26) ? val26 \
719 : (BASE == 27) ? val27 \
720 : (BASE == 28) ? val28 \
721 : (BASE == 29) ? val29 \
722 : (BASE == 30) ? val30 \
723 : (BASE == 31) ? val31 \
724 : (BASE == 32) ? val32 \
725 : (BASE == 33) ? val33 \
726 : (BASE == 34) ? val34 \
727 : (BASE == 35) ? val35 \
728 : (BASE == 36) ? val36 \
1032#undef BSLALG_NUMERICFORMATTERUTIL_INTMAXLEN_ONE
1038template <
class TYPE>
1039struct NumericFormatterUtil::IsSupportedFloatingPoint {
1057template <
class TYPE>
1058struct NumericFormatterUtil::IsSupportedIntegral {
1086template <
class TYPE,
int ARG>
1093 typedef const bool Cbool;
1098 static Cbool k_INTEGRAL_TYPE = IsSupportedIntegral<TYPE>::k_SUPPORTED;
1099 static Cbool k_FLOAT_TYPE = IsSupportedFloatingPoint<TYPE>::k_SUPPORTED;
1101 static Cbool k_UNSUPPORTED_INPUT_TYPE = !k_INTEGRAL_TYPE && !k_FLOAT_TYPE;
1105 static Cbool k_ARG_NOT_BASE = (ARG < 2 || ARG > 37);
1106 static Cbool k_ARG_NOT_FORMAT = (ARG != e_FIXED && ARG != e_SCIENTIFIC);
1108 static Cbool k_ARGUMENT_VALUE_IS_WRONG = !(
1110 (ARG == k_MAXLEN_ARG_DEFAULT) ||
1113 (k_INTEGRAL_TYPE && !k_ARG_NOT_BASE) ||
1116 (k_FLOAT_TYPE && !k_ARG_NOT_FORMAT) ||
1119 (k_UNSUPPORTED_INPUT_TYPE && !(k_ARG_NOT_BASE && k_ARG_NOT_FORMAT)));
1132 k_VALUE = k_INTEGRAL_TYPE
1133 ? IntMaxLen<std::numeric_limits<TYPE>::is_signed,
1134 static_cast<unsigned>(
sizeof(TYPE)),
1137 ? FltMaxLen<TYPE, ARG>::k_VALUE
1151template <
class TYPE>
1153char *NumericFormatterUtil::toCharsIntegral(
char *first,
1163 BSLMF_ASSERT(
sizeof(TYPE) <=
sizeof(
unsigned long long int));
1166 unsigned long long int,
1167 unsigned>::type VirtualUnsignedType;
1169 if (first == last) {
1180 VirtualUnsignedType uValue = value;
1183 uValue = ~uValue + 1;
1188 return toCharsImpl(first, last, uValue, base);
1193char *NumericFormatterUtil::toChars(
char *first,
1198 return toCharsIntegral(first, last, value, base);
1202char *NumericFormatterUtil::toChars(
char *first,
1207 return toCharsIntegral(first, last, value, base);
1211char *NumericFormatterUtil::toChars(
char *first,
1213 unsigned char value,
1216 return toCharsIntegral(first, last, value, base);
1221NumericFormatterUtil::toChars(
char *first,
1223 signed short int value,
1226 return toCharsIntegral(first, last, value, base);
1230char *NumericFormatterUtil::toChars(
char *first,
1232 unsigned short int value,
1236 return toCharsIntegral(first, last, value, base);
1240char *NumericFormatterUtil::toChars(
char *first,
1245 return toCharsIntegral(first, last, value, base);
1249char *NumericFormatterUtil::toChars(
char *first,
1254 return toCharsIntegral(first, last, value, base);
1258char *NumericFormatterUtil::toChars(
char *first,
1260 signed long int value,
1264 return toCharsIntegral(first, last, value, base);
1268char *NumericFormatterUtil::toChars(
char *first,
1270 unsigned long int value,
1274 return toCharsIntegral(first, last, value, base);
1278char *NumericFormatterUtil::toChars(
char *first,
1280 signed long long int value,
1284 return toCharsIntegral(first, last, value, base);
1288char *NumericFormatterUtil::toChars(
char *first,
1290 unsigned long long int value,
1294 return toCharsIntegral(first, last, value, base);
1298char *NumericFormatterUtil::toChars(
char *first,
1304 case e_FIXED:
return toCharsDecimal(first, last, value);
1305 case e_SCIENTIFIC:
return toCharsScientific(first, last, value);
1313char *NumericFormatterUtil::toChars(
char *first,
1319 case e_FIXED:
return toCharsDecimal(first, last, value);
1320 case e_SCIENTIFIC:
return toCharsScientific(first, last, value);
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_ASSERT_INVOKE_NORETURN(X)
Definition bsls_assert.h:1895
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:609
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
Definition bdlc_flathashmap.h:1805
Definition bslmf_conditional.h:120
Definition bslmf_isintegral.h:130
Definition bslmf_issame.h:146
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126