|
| enum | { buffer_size = std::numeric_limits<unsigned long long>::digits10 + 3
} |
|
|
char | buffer_ [buffer_size] |
|
char * | str_ |
◆ anonymous enum
19002{ buffer_size = std::numeric_limits<unsigned long long>::digits10 + 3 };
◆ format_int() [1/6]
| format_int::format_int |
( |
int | value | ) |
|
|
inlineexplicit |
19037{ format_signed(value); }
◆ format_int() [2/6]
| format_int::format_int |
( |
long | value | ) |
|
|
inlineexplicit |
19038{ format_signed(value); }
◆ format_int() [3/6]
| format_int::format_int |
( |
long long | value | ) |
|
|
inlineexplicit |
19039{ format_signed(value); }
◆ format_int() [4/6]
| format_int::format_int |
( |
unsigned | value | ) |
|
|
inlineexplicit |
19040: str_(format_decimal(value)) {}
◆ format_int() [5/6]
| format_int::format_int |
( |
unsigned long | value | ) |
|
|
inlineexplicit |
19041: str_(format_decimal(value)) {}
◆ format_int() [6/6]
| format_int::format_int |
( |
unsigned long long | value | ) |
|
|
inlineexplicit |
19042: str_(format_decimal(value)) {}
◆ format_decimal()
| char * format_int::format_decimal |
( |
unsigned long long | value | ) |
|
|
inlineprivate |
19007 {
19008 char* ptr = buffer_ + (buffer_size - 1);
19009 while (value >= 100) {
19010
19011
19012
19013 auto index =
static_cast<unsigned>((value % 100) * 2);
19014 value /= 100;
19015 *--ptr = internal::data::digits[
index + 1];
19016 *--ptr = internal::data::digits[
index];
19017 }
19018 if (value < 10) {
19019 *--ptr = static_cast<char>('0' + value);
19020 return ptr;
19021 }
19022 auto index =
static_cast<unsigned>(value * 2);
19023 *--ptr = internal::data::digits[
index + 1];
19024 *--ptr = internal::data::digits[
index];
19025 return ptr;
19026 }
◆ format_signed()
| void format_int::format_signed |
( |
long long | value | ) |
|
|
inlineprivate |
19028 {
19029 auto abs_value = static_cast<unsigned long long>(value);
19030 bool negative = value < 0;
19031 if (negative) abs_value = 0 - abs_value;
19032 str_ = format_decimal(abs_value);
19033 if (negative) *--str_ = '-';
19034 }
◆ size()
| std::size_t format_int::size |
( |
| ) |
const |
|
inline |
Returns the number of characters written to the output buffer.
19045 {
19046 return internal::to_unsigned(buffer_ - str_ + buffer_size - 1);
19047 }
◆ data()
| const char * format_int::data |
( |
| ) |
const |
|
inline |
Returns a pointer to the output buffer content. No terminating null character is appended.
◆ c_str()
| const char * format_int::c_str |
( |
| ) |
const |
|
inline |
Returns a pointer to the output buffer content with terminating null character appended.
19059 {
19060 buffer_[buffer_size - 1] = '\0';
19061 return str_;
19062 }
◆ str()
| std::string format_int::str |
( |
| ) |
const |
|
inline |
\rst Returns the content of the output buffer as an std::string. \endrst
19069{
return std::string(str_,
size()); }
The documentation for this class was generated from the following file: