2018-06-21 21:55:12 +02:00
|
|
|
//
|
|
|
|
// POSIX spec:
|
|
|
|
// http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html
|
|
|
|
//
|
|
|
|
#include "absl/strings/internal/str_format/arg.h"
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
#include "absl/base/port.h"
|
|
|
|
#include "absl/strings/internal/str_format/float_conversion.h"
|
2020-04-24 15:12:31 +02:00
|
|
|
#include "absl/strings/numbers.h"
|
2018-06-21 21:55:12 +02:00
|
|
|
|
|
|
|
namespace absl {
|
2019-12-12 19:36:03 +01:00
|
|
|
ABSL_NAMESPACE_BEGIN
|
2018-06-21 21:55:12 +02:00
|
|
|
namespace str_format_internal {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Reduce *capacity by s.size(), clipped to a 0 minimum.
|
|
|
|
void ReducePadding(string_view s, size_t *capacity) {
|
|
|
|
*capacity = Excess(s.size(), *capacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reduce *capacity by n, clipped to a 0 minimum.
|
|
|
|
void ReducePadding(size_t n, size_t *capacity) {
|
|
|
|
*capacity = Excess(n, *capacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct MakeUnsigned : std::make_unsigned<T> {};
|
|
|
|
template <>
|
2019-11-18 20:02:26 +01:00
|
|
|
struct MakeUnsigned<absl::int128> {
|
|
|
|
using type = absl::uint128;
|
|
|
|
};
|
|
|
|
template <>
|
2018-06-21 21:55:12 +02:00
|
|
|
struct MakeUnsigned<absl::uint128> {
|
|
|
|
using type = absl::uint128;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct IsSigned : std::is_signed<T> {};
|
|
|
|
template <>
|
2019-11-18 20:02:26 +01:00
|
|
|
struct IsSigned<absl::int128> : std::true_type {};
|
|
|
|
template <>
|
2018-06-21 21:55:12 +02:00
|
|
|
struct IsSigned<absl::uint128> : std::false_type {};
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
// Integral digit printer.
|
|
|
|
// Call one of the PrintAs* routines after construction once.
|
|
|
|
// Use with_neg_and_zero/without_neg_or_zero/is_negative to access the results.
|
|
|
|
class IntDigits {
|
2018-06-21 21:55:12 +02:00
|
|
|
public:
|
2020-04-24 15:12:31 +02:00
|
|
|
// Print the unsigned integer as octal.
|
|
|
|
// Supports unsigned integral types and uint128.
|
|
|
|
template <typename T>
|
|
|
|
void PrintAsOct(T v) {
|
|
|
|
static_assert(!IsSigned<T>::value, "");
|
|
|
|
char *p = storage_ + sizeof(storage_);
|
|
|
|
do {
|
|
|
|
*--p = static_cast<char>('0' + (static_cast<size_t>(v) & 7));
|
|
|
|
v >>= 3;
|
|
|
|
} while (v);
|
|
|
|
start_ = p;
|
|
|
|
size_ = storage_ + sizeof(storage_) - p;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the signed or unsigned integer as decimal.
|
|
|
|
// Supports all integral types.
|
2018-06-21 21:55:12 +02:00
|
|
|
template <typename T>
|
2020-04-24 15:12:31 +02:00
|
|
|
void PrintAsDec(T v) {
|
|
|
|
static_assert(std::is_integral<T>::value, "");
|
|
|
|
start_ = storage_;
|
|
|
|
size_ = numbers_internal::FastIntToBuffer(v, storage_) - storage_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintAsDec(int128 v) {
|
|
|
|
auto u = static_cast<uint128>(v);
|
|
|
|
bool add_neg = false;
|
|
|
|
if (v < 0) {
|
|
|
|
add_neg = true;
|
|
|
|
u = uint128{} - u;
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
2020-04-24 15:12:31 +02:00
|
|
|
PrintAsDec(u, add_neg);
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
void PrintAsDec(uint128 v, bool add_neg = false) {
|
|
|
|
// This function can be sped up if needed. We can call FastIntToBuffer
|
|
|
|
// twice, or fix FastIntToBuffer to support uint128.
|
|
|
|
char *p = storage_ + sizeof(storage_);
|
|
|
|
do {
|
|
|
|
p -= 2;
|
|
|
|
numbers_internal::PutTwoDigits(static_cast<size_t>(v % 100), p);
|
|
|
|
v /= 100;
|
|
|
|
} while (v);
|
|
|
|
if (p[0] == '0') {
|
|
|
|
// We printed one too many hexits.
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
if (add_neg) {
|
|
|
|
*--p = '-';
|
|
|
|
}
|
|
|
|
size_ = storage_ + sizeof(storage_) - p;
|
|
|
|
start_ = p;
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
// Print the unsigned integer as hex using lowercase.
|
|
|
|
// Supports unsigned integral types and uint128.
|
2018-06-21 21:55:12 +02:00
|
|
|
template <typename T>
|
2020-04-24 15:12:31 +02:00
|
|
|
void PrintAsHexLower(T v) {
|
|
|
|
static_assert(!IsSigned<T>::value, "");
|
|
|
|
char *p = storage_ + sizeof(storage_);
|
|
|
|
|
|
|
|
do {
|
|
|
|
p -= 2;
|
|
|
|
constexpr const char* table = numbers_internal::kHexTable;
|
|
|
|
std::memcpy(p, table + 2 * (static_cast<size_t>(v) & 0xFF), 2);
|
|
|
|
if (sizeof(T) == 1) break;
|
|
|
|
v >>= 8;
|
|
|
|
} while (v);
|
|
|
|
if (p[0] == '0') {
|
|
|
|
// We printed one too many digits.
|
|
|
|
++p;
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
2020-04-24 15:12:31 +02:00
|
|
|
start_ = p;
|
|
|
|
size_ = storage_ + sizeof(storage_) - p;
|
|
|
|
}
|
2018-06-21 21:55:12 +02:00
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
// Print the unsigned integer as hex using uppercase.
|
|
|
|
// Supports unsigned integral types and uint128.
|
2018-06-21 21:55:12 +02:00
|
|
|
template <typename T>
|
2020-04-24 15:12:31 +02:00
|
|
|
void PrintAsHexUpper(T v) {
|
|
|
|
static_assert(!IsSigned<T>::value, "");
|
|
|
|
char *p = storage_ + sizeof(storage_);
|
|
|
|
|
|
|
|
// kHexTable is only lowercase, so do it manually for uppercase.
|
|
|
|
do {
|
|
|
|
*--p = "0123456789ABCDEF"[static_cast<size_t>(v) & 15];
|
|
|
|
v >>= 4;
|
|
|
|
} while (v);
|
|
|
|
start_ = p;
|
|
|
|
size_ = storage_ + sizeof(storage_) - p;
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
// The printed value including the '-' sign if available.
|
|
|
|
// For inputs of value `0`, this will return "0"
|
|
|
|
string_view with_neg_and_zero() const { return {start_, size_}; }
|
|
|
|
|
|
|
|
// The printed value not including the '-' sign.
|
|
|
|
// For inputs of value `0`, this will return "".
|
|
|
|
string_view without_neg_or_zero() const {
|
|
|
|
static_assert('-' < '0', "The check below verifies both.");
|
|
|
|
size_t advance = start_[0] <= '0' ? 1 : 0;
|
|
|
|
return {start_ + advance, size_ - advance};
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
bool is_negative() const { return start_[0] == '-'; }
|
2018-06-21 21:55:12 +02:00
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
private:
|
|
|
|
const char *start_;
|
|
|
|
size_t size_;
|
|
|
|
// Max size: 128 bit value as octal -> 43 digits, plus sign char
|
|
|
|
char storage_[128 / 3 + 1 + 1];
|
2018-06-21 21:55:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Note: 'o' conversions do not have a base indicator, it's just that
|
|
|
|
// the '#' flag is specified to modify the precision for 'o' conversions.
|
2020-04-24 15:12:31 +02:00
|
|
|
string_view BaseIndicator(const IntDigits &as_digits,
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv) {
|
2020-04-24 15:12:31 +02:00
|
|
|
// always show 0x for %p.
|
|
|
|
bool alt = conv.has_alt_flag() || conv.conversion_char() == ConversionChar::p;
|
|
|
|
bool hex = (conv.conversion_char() == FormatConversionChar::x ||
|
|
|
|
conv.conversion_char() == FormatConversionChar::X ||
|
|
|
|
conv.conversion_char() == FormatConversionChar::p);
|
2018-06-21 21:55:12 +02:00
|
|
|
// From the POSIX description of '#' flag:
|
|
|
|
// "For x or X conversion specifiers, a non-zero result shall have
|
|
|
|
// 0x (or 0X) prefixed to it."
|
2020-04-24 15:12:31 +02:00
|
|
|
if (alt && hex && !as_digits.without_neg_or_zero().empty()) {
|
|
|
|
return conv.conversion_char() == FormatConversionChar::X ? "0X" : "0x";
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2018-09-12 20:03:25 +02:00
|
|
|
string_view SignColumn(bool neg, const ConversionSpec conv) {
|
2020-04-24 15:12:31 +02:00
|
|
|
if (conv.conversion_char() == FormatConversionChar::d ||
|
|
|
|
conv.conversion_char() == FormatConversionChar::i) {
|
2018-06-21 21:55:12 +02:00
|
|
|
if (neg) return "-";
|
2020-03-26 16:48:01 +01:00
|
|
|
if (conv.has_show_pos_flag()) return "+";
|
|
|
|
if (conv.has_sign_col_flag()) return " ";
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2018-09-12 20:03:25 +02:00
|
|
|
bool ConvertCharImpl(unsigned char v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
size_t fill = 0;
|
|
|
|
if (conv.width() >= 0) fill = conv.width();
|
|
|
|
ReducePadding(1, &fill);
|
2020-03-26 16:48:01 +01:00
|
|
|
if (!conv.has_left_flag()) sink->Append(fill, ' ');
|
2018-06-21 21:55:12 +02:00
|
|
|
sink->Append(1, v);
|
2020-03-26 16:48:01 +01:00
|
|
|
if (conv.has_left_flag()) sink->Append(fill, ' ');
|
2018-06-21 21:55:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
bool ConvertIntImplInnerSlow(const IntDigits &as_digits,
|
|
|
|
const ConversionSpec conv, FormatSinkImpl *sink) {
|
2018-06-21 21:55:12 +02:00
|
|
|
// Print as a sequence of Substrings:
|
|
|
|
// [left_spaces][sign][base_indicator][zeroes][formatted][right_spaces]
|
|
|
|
size_t fill = 0;
|
|
|
|
if (conv.width() >= 0) fill = conv.width();
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
string_view formatted = as_digits.without_neg_or_zero();
|
2018-06-21 21:55:12 +02:00
|
|
|
ReducePadding(formatted, &fill);
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
string_view sign = SignColumn(as_digits.is_negative(), conv);
|
2018-06-21 21:55:12 +02:00
|
|
|
ReducePadding(sign, &fill);
|
|
|
|
|
2020-04-24 15:12:31 +02:00
|
|
|
string_view base_indicator = BaseIndicator(as_digits, conv);
|
2018-06-21 21:55:12 +02:00
|
|
|
ReducePadding(base_indicator, &fill);
|
|
|
|
|
|
|
|
int precision = conv.precision();
|
|
|
|
bool precision_specified = precision >= 0;
|
|
|
|
if (!precision_specified)
|
|
|
|
precision = 1;
|
|
|
|
|
2020-03-26 16:48:01 +01:00
|
|
|
if (conv.has_alt_flag() && conv.conversion_char() == ConversionChar::o) {
|
2018-06-21 21:55:12 +02:00
|
|
|
// From POSIX description of the '#' (alt) flag:
|
|
|
|
// "For o conversion, it increases the precision (if necessary) to
|
|
|
|
// force the first digit of the result to be zero."
|
|
|
|
if (formatted.empty() || *formatted.begin() != '0') {
|
|
|
|
int needed = static_cast<int>(formatted.size()) + 1;
|
|
|
|
precision = std::max(precision, needed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t num_zeroes = Excess(formatted.size(), precision);
|
|
|
|
ReducePadding(num_zeroes, &fill);
|
|
|
|
|
2020-03-26 16:48:01 +01:00
|
|
|
size_t num_left_spaces = !conv.has_left_flag() ? fill : 0;
|
|
|
|
size_t num_right_spaces = conv.has_left_flag() ? fill : 0;
|
2018-06-21 21:55:12 +02:00
|
|
|
|
|
|
|
// From POSIX description of the '0' (zero) flag:
|
|
|
|
// "For d, i, o, u, x, and X conversion specifiers, if a precision
|
|
|
|
// is specified, the '0' flag is ignored."
|
2020-03-26 16:48:01 +01:00
|
|
|
if (!precision_specified && conv.has_zero_flag()) {
|
2018-06-21 21:55:12 +02:00
|
|
|
num_zeroes += num_left_spaces;
|
|
|
|
num_left_spaces = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sink->Append(num_left_spaces, ' ');
|
|
|
|
sink->Append(sign);
|
|
|
|
sink->Append(base_indicator);
|
|
|
|
sink->Append(num_zeroes, '0');
|
|
|
|
sink->Append(formatted);
|
|
|
|
sink->Append(num_right_spaces, ' ');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2018-09-12 20:03:25 +02:00
|
|
|
bool ConvertIntArg(T v, const ConversionSpec conv, FormatSinkImpl *sink) {
|
2020-04-24 15:12:31 +02:00
|
|
|
using U = typename MakeUnsigned<T>::type;
|
|
|
|
IntDigits as_digits;
|
|
|
|
|
|
|
|
switch (conv.conversion_char()) {
|
|
|
|
case FormatConversionChar::c:
|
|
|
|
return ConvertCharImpl(static_cast<unsigned char>(v), conv, sink);
|
|
|
|
|
|
|
|
case FormatConversionChar::o:
|
|
|
|
as_digits.PrintAsOct(static_cast<U>(v));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FormatConversionChar::x:
|
|
|
|
as_digits.PrintAsHexLower(static_cast<U>(v));
|
|
|
|
break;
|
|
|
|
case FormatConversionChar::X:
|
|
|
|
as_digits.PrintAsHexUpper(static_cast<U>(v));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FormatConversionChar::u:
|
|
|
|
as_digits.PrintAsDec(static_cast<U>(v));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FormatConversionChar::d:
|
|
|
|
case FormatConversionChar::i:
|
|
|
|
as_digits.PrintAsDec(v);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FormatConversionChar::a:
|
|
|
|
case FormatConversionChar::e:
|
|
|
|
case FormatConversionChar::f:
|
|
|
|
case FormatConversionChar::g:
|
|
|
|
case FormatConversionChar::A:
|
|
|
|
case FormatConversionChar::E:
|
|
|
|
case FormatConversionChar::F:
|
|
|
|
case FormatConversionChar::G:
|
|
|
|
return ConvertFloatImpl(static_cast<double>(v), conv, sink);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
2020-04-24 15:12:31 +02:00
|
|
|
|
|
|
|
if (conv.is_basic()) {
|
|
|
|
sink->Append(as_digits.with_neg_and_zero());
|
|
|
|
return true;
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
2020-04-24 15:12:31 +02:00
|
|
|
return ConvertIntImplInnerSlow(as_digits, conv, sink);
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2018-09-12 20:03:25 +02:00
|
|
|
bool ConvertFloatArg(T v, const ConversionSpec conv, FormatSinkImpl *sink) {
|
2020-03-26 16:48:01 +01:00
|
|
|
return FormatConversionCharIsFloat(conv.conversion_char()) &&
|
2020-02-14 18:41:25 +01:00
|
|
|
ConvertFloatImpl(v, conv, sink);
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 20:03:25 +02:00
|
|
|
inline bool ConvertStringArg(string_view v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
2020-05-01 02:44:10 +02:00
|
|
|
if (conv.conversion_char() != FormatConversionCharInternal::s) return false;
|
2020-03-26 16:48:01 +01:00
|
|
|
if (conv.is_basic()) {
|
2018-06-21 21:55:12 +02:00
|
|
|
sink->Append(v);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return sink->PutPaddedString(v, conv.width(), conv.precision(),
|
2020-03-26 16:48:01 +01:00
|
|
|
conv.has_left_flag());
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// ==================== Strings ====================
|
2020-05-01 02:44:10 +02:00
|
|
|
StringConvertResult FormatConvertImpl(const std::string &v,
|
|
|
|
const ConversionSpec conv,
|
|
|
|
FormatSinkImpl *sink) {
|
2018-06-21 21:55:12 +02:00
|
|
|
return {ConvertStringArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
|
2020-05-01 02:44:10 +02:00
|
|
|
StringConvertResult FormatConvertImpl(string_view v, const ConversionSpec conv,
|
|
|
|
FormatSinkImpl *sink) {
|
2018-06-21 21:55:12 +02:00
|
|
|
return {ConvertStringArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
|
2020-05-01 02:44:10 +02:00
|
|
|
ArgConvertResult<FormatConversionCharSetUnion(
|
|
|
|
FormatConversionCharSetInternal::s, FormatConversionCharSetInternal::p)>
|
|
|
|
FormatConvertImpl(const char *v, const ConversionSpec conv,
|
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
if (conv.conversion_char() == FormatConversionCharInternal::p)
|
2018-06-21 21:55:12 +02:00
|
|
|
return {FormatConvertImpl(VoidPtr(v), conv, sink).value};
|
|
|
|
size_t len;
|
|
|
|
if (v == nullptr) {
|
|
|
|
len = 0;
|
|
|
|
} else if (conv.precision() < 0) {
|
|
|
|
len = std::strlen(v);
|
|
|
|
} else {
|
2019-12-18 20:46:26 +01:00
|
|
|
// If precision is set, we look for the NUL-terminator on the valid range.
|
2018-06-21 21:55:12 +02:00
|
|
|
len = std::find(v, v + conv.precision(), '\0') - v;
|
|
|
|
}
|
|
|
|
return {ConvertStringArg(string_view(v, len), conv, sink)};
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==================== Raw pointers ====================
|
2020-05-01 02:44:10 +02:00
|
|
|
ArgConvertResult<FormatConversionCharSetInternal::p> FormatConvertImpl(
|
|
|
|
VoidPtr v, const ConversionSpec conv, FormatSinkImpl *sink) {
|
|
|
|
if (conv.conversion_char() != FormatConversionCharInternal::p) return {false};
|
2018-06-21 21:55:12 +02:00
|
|
|
if (!v.value) {
|
|
|
|
sink->Append("(nil)");
|
|
|
|
return {true};
|
|
|
|
}
|
2020-04-24 15:12:31 +02:00
|
|
|
IntDigits as_digits;
|
|
|
|
as_digits.PrintAsHexLower(v.value);
|
|
|
|
return {ConvertIntImplInnerSlow(as_digits, conv, sink)};
|
2018-06-21 21:55:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ==================== Floats ====================
|
2018-09-12 20:03:25 +02:00
|
|
|
FloatingConvertResult FormatConvertImpl(float v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertFloatArg(v, conv, sink)};
|
|
|
|
}
|
2018-09-12 20:03:25 +02:00
|
|
|
FloatingConvertResult FormatConvertImpl(double v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertFloatArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
FloatingConvertResult FormatConvertImpl(long double v,
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertFloatArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==================== Chars ====================
|
2018-09-12 20:03:25 +02:00
|
|
|
IntegralConvertResult FormatConvertImpl(char v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(signed char v,
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(unsigned char v,
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==================== Ints ====================
|
|
|
|
IntegralConvertResult FormatConvertImpl(short v, // NOLINT
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(unsigned short v, // NOLINT
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
2018-09-12 20:03:25 +02:00
|
|
|
IntegralConvertResult FormatConvertImpl(int v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
2018-09-12 20:03:25 +02:00
|
|
|
IntegralConvertResult FormatConvertImpl(unsigned v, const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(long v, // NOLINT
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(unsigned long v, // NOLINT
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(long long v, // NOLINT
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
IntegralConvertResult FormatConvertImpl(unsigned long long v, // NOLINT
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
2019-11-18 20:02:26 +01:00
|
|
|
IntegralConvertResult FormatConvertImpl(absl::int128 v,
|
|
|
|
const ConversionSpec conv,
|
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
2018-06-21 21:55:12 +02:00
|
|
|
IntegralConvertResult FormatConvertImpl(absl::uint128 v,
|
2018-09-12 20:03:25 +02:00
|
|
|
const ConversionSpec conv,
|
2018-06-21 21:55:12 +02:00
|
|
|
FormatSinkImpl *sink) {
|
|
|
|
return {ConvertIntArg(v, conv, sink)};
|
|
|
|
}
|
|
|
|
|
2018-09-12 20:03:25 +02:00
|
|
|
ABSL_INTERNAL_FORMAT_DISPATCH_OVERLOADS_EXPAND_();
|
|
|
|
|
2018-06-21 21:55:12 +02:00
|
|
|
|
2019-11-18 20:02:26 +01:00
|
|
|
|
2018-06-21 21:55:12 +02:00
|
|
|
} // namespace str_format_internal
|
|
|
|
|
2019-12-12 19:36:03 +01:00
|
|
|
ABSL_NAMESPACE_END
|
2018-06-21 21:55:12 +02:00
|
|
|
} // namespace absl
|