From 6a2ff287b20924db5b2cebd60311f132dced268a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 19 Feb 2017 06:46:51 -0800 Subject: [PATCH] Follow standard naming conventions --- fmt/format.cc | 36 ++++---- fmt/format.h | 199 +++++++++++++++++++--------------------- fmt/ostream.cc | 2 +- fmt/printf.h | 10 +- test/format-test.cc | 2 +- test/ostream-test.cc | 2 +- test/posix-mock-test.cc | 2 +- test/printf-test.cc | 12 +-- test/util-test.cc | 34 +++---- 9 files changed, 143 insertions(+), 156 deletions(-) diff --git a/fmt/format.cc b/fmt/format.cc index 3823c73c..b4a8f078 100644 --- a/fmt/format.cc +++ b/fmt/format.cc @@ -186,8 +186,8 @@ void format_error_code(buffer &out, int error_code, static const char ERROR_STR[] = "error "; // Subtract 2 to account for terminating null characters in SEP and ERROR_STR. std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2; - typedef internal::IntTraits::MainType MainType; - MainType abs_value = static_cast(error_code); + typedef internal::int_traits::main_type main_type; + main_type abs_value = static_cast(error_code); if (internal::is_negative(error_code)) { abs_value = 0 - abs_value; ++error_code_size; @@ -224,7 +224,7 @@ FMT_FUNC void SystemError::init( } template -int internal::CharTraits::format_float( +int internal::char_traits::format_float( char *buffer, std::size_t size, const char *format, unsigned width, int precision, T value) { if (width == 0) { @@ -238,7 +238,7 @@ int internal::CharTraits::format_float( } template -int internal::CharTraits::format_float( +int internal::char_traits::format_float( wchar_t *buffer, std::size_t size, const wchar_t *format, unsigned width, int precision, T value) { if (width == 0) { @@ -252,7 +252,7 @@ int internal::CharTraits::format_float( } template -const char internal::BasicData::DIGITS[] = +const char internal::basic_data::DIGITS[] = "0001020304050607080910111213141516171819" "2021222324252627282930313233343536373839" "4041424344454647484950515253545556575859" @@ -271,12 +271,12 @@ const char internal::BasicData::DIGITS[] = factor * 1000000000 template -const uint32_t internal::BasicData::POWERS_OF_10_32[] = { +const uint32_t internal::basic_data::POWERS_OF_10_32[] = { 0, FMT_POWERS_OF_10(1) }; template -const uint64_t internal::BasicData::POWERS_OF_10_64[] = { +const uint64_t internal::basic_data::POWERS_OF_10_64[] = { 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(ulong_long(1000000000)), @@ -298,7 +298,7 @@ FMT_FUNC void internal::report_unknown_type(char code, const char *type) { #if FMT_USE_WINDOWS_H -FMT_FUNC internal::UTF8ToUTF16::UTF8ToUTF16(string_view s) { +FMT_FUNC internal::utf8_to_utf16::utf8_to_utf16(string_view s) { static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16"; if (s.size() > INT_MAX) FMT_THROW(WindowsError(ERROR_INVALID_PARAMETER, ERROR_MSG)); @@ -341,7 +341,7 @@ FMT_FUNC int internal::UTF16ToUTF8::convert(wstring_view s) { FMT_FUNC void WindowsError::init( int err_code, CStringRef format_str, args args) { error_code_ = err_code; - internal::MemoryBuffer buffer; + memory_buffer buffer; internal::format_windows_error(buffer, err_code, vformat(format_str, args)); std::runtime_error &base = *this; base = std::runtime_error(to_string(buffer)); @@ -350,7 +350,7 @@ FMT_FUNC void WindowsError::init( FMT_FUNC void internal::format_windows_error( buffer &out, int error_code, string_view message) FMT_NOEXCEPT { FMT_TRY { - MemoryBuffer buffer; + wmemory_buffer buffer; buffer.resize(INLINE_BUFFER_SIZE); for (;;) { wchar_t *system_message = &buffer[0]; @@ -403,7 +403,7 @@ FMT_FUNC void format_system_error( } template -void FixedBuffer::grow(std::size_t) { +void basic_fixed_buffer::grow(std::size_t) { FMT_THROW(std::runtime_error("buffer overflow")); } @@ -453,21 +453,21 @@ FMT_FUNC int vfprintf(std::FILE *f, CStringRef format, printf_args args) { #ifndef FMT_HEADER_ONLY -template struct internal::BasicData; +template struct internal::basic_data; // Explicit instantiations for char. -template void FixedBuffer::grow(std::size_t); +template void basic_fixed_buffer::grow(std::size_t); template void internal::ArgMap::init(const args &args); template void printf_context::format(buffer &); -template int internal::CharTraits::format_float( +template int internal::char_traits::format_float( char *buffer, std::size_t size, const char *format, unsigned width, int precision, double value); -template int internal::CharTraits::format_float( +template int internal::char_traits::format_float( char *buffer, std::size_t size, const char *format, unsigned width, int precision, long double value); @@ -475,17 +475,17 @@ template int internal::CharTraits::format_float( template class basic_context; -template void FixedBuffer::grow(std::size_t); +template void basic_fixed_buffer::grow(std::size_t); template void internal::ArgMap::init(const wargs &args); template void printf_context::format(wbuffer &); -template int internal::CharTraits::format_float( +template int internal::char_traits::format_float( wchar_t *buffer, std::size_t size, const wchar_t *format, unsigned width, int precision, double value); -template int internal::CharTraits::format_float( +template int internal::char_traits::format_float( wchar_t *buffer, std::size_t size, const wchar_t *format, unsigned width, int precision, long double value); diff --git a/fmt/format.h b/fmt/format.h index d4de5ea6..eea1b83e 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -532,13 +532,14 @@ class format_error : public std::runtime_error { namespace internal { -// MakeUnsigned::Type gives an unsigned type corresponding to integer type T. +// make_unsigned::type gives an unsigned type corresponding to integer +// type T. template -struct MakeUnsigned { typedef T Type; }; +struct make_unsigned { typedef T type; }; #define FMT_SPECIALIZE_MAKE_UNSIGNED(T, U) \ template <> \ - struct MakeUnsigned { typedef U Type; } + struct make_unsigned { typedef U type; } FMT_SPECIALIZE_MAKE_UNSIGNED(char, unsigned char); FMT_SPECIALIZE_MAKE_UNSIGNED(signed char, unsigned char); @@ -549,9 +550,9 @@ FMT_SPECIALIZE_MAKE_UNSIGNED(long_long, ulong_long); // Casts nonnegative integer to unsigned. template -inline typename MakeUnsigned::Type to_unsigned(Int value) { +inline typename make_unsigned::type to_unsigned(Int value) { FMT_ASSERT(value >= 0, "negative value"); - return static_cast::Type>(value); + return static_cast::type>(value); } // The number of characters to store in the MemoryBuffer object itself @@ -789,25 +790,26 @@ typedef basic_memory_buffer wmemory_buffer; \endrst */ template -class FixedBuffer : public basic_buffer { +class basic_fixed_buffer : public basic_buffer { public: /** \rst - Constructs a :class:`fmt::FixedBuffer` object for *array* of the + Constructs a :class:`fmt::basic_fixed_buffer` object for *array* of the given size. \endrst */ - FixedBuffer(Char *array, std::size_t size) + basic_fixed_buffer(Char *array, std::size_t size) : basic_buffer(array, size) {} /** \rst - Constructs a :class:`fmt::FixedBuffer` object for *array* of the + Constructs a :class:`fmt::basic_fixed_buffer` object for *array* of the size known at compile time. \endrst */ template - explicit FixedBuffer(Char (&array)[SIZE]) : basic_buffer(array, SIZE) {} + explicit basic_fixed_buffer(Char (&array)[SIZE]) + : basic_buffer(array, SIZE) {} protected: FMT_API void grow(std::size_t size); @@ -816,7 +818,7 @@ class FixedBuffer : public basic_buffer { namespace internal { template -class BasicCharTraits { +class basic_char_traits { public: #if FMT_SECURE_SCL typedef stdext::checked_array_iterator CharPtr; @@ -827,10 +829,10 @@ class BasicCharTraits { }; template -class CharTraits; +class char_traits; template <> -class CharTraits : public BasicCharTraits { +class char_traits : public basic_char_traits { private: // Conversion from wchar_t to char is not allowed. static char convert(wchar_t); @@ -845,7 +847,7 @@ class CharTraits : public BasicCharTraits { }; template <> -class CharTraits : public BasicCharTraits { +class char_traits : public basic_char_traits { public: static wchar_t convert(char value) { return value; } static wchar_t convert(wchar_t value) { return value; } @@ -855,39 +857,37 @@ class CharTraits : public BasicCharTraits { const wchar_t *format, unsigned width, int precision, T value); }; -// Checks if a number is negative - used to avoid warnings. -template -struct SignChecker { - template - static bool is_negative(T value) { return value < 0; } -}; +template +struct enable_if {}; -template <> -struct SignChecker { - template - static bool is_negative(T) { return false; } -}; +template +struct enable_if { typedef T type; }; + +template +struct conditional { typedef T type; }; + +template +struct conditional { typedef F type; }; // Returns true if value is negative, false otherwise. // Same as (value < 0) but doesn't produce warnings if T is an unsigned type. template -inline bool is_negative(T value) { - return SignChecker::is_signed>::is_negative(value); +inline typename enable_if::is_signed, bool>::type + is_negative(T value) { + return value < 0; +} +template +inline typename enable_if::is_signed, bool>::type + is_negative(T) { + return false; } -// Selects uint32_t if FitsIn32Bits is true, uint64_t otherwise. -template -struct TypeSelector { typedef uint32_t Type; }; - -template <> -struct TypeSelector { typedef uint64_t Type; }; - template -struct IntTraits { +struct int_traits { // Smallest of uint32_t and uint64_t that is large enough to represent // all values of T. - typedef typename - TypeSelector::digits <= 32>::Type MainType; + typedef typename conditional< + std::numeric_limits::digits <= 32, uint32_t, uint64_t>::type main_type; }; FMT_API void report_unknown_type(char code, const char *type); @@ -895,7 +895,7 @@ FMT_API void report_unknown_type(char code, const char *type); // Static data is placed in this class template to allow header-only // configuration. template -struct FMT_API BasicData { +struct FMT_API basic_data { static const uint32_t POWERS_OF_10_32[]; static const uint64_t POWERS_OF_10_64[]; static const char DIGITS[]; @@ -908,10 +908,10 @@ struct FMT_API BasicData { #endif #if FMT_USE_EXTERN_TEMPLATES && !defined(FMT_HEADER_ONLY) -extern template struct BasicData; +extern template struct basic_data; #endif -typedef BasicData<> Data; +typedef basic_data<> data; #ifdef FMT_BUILTIN_CLZLL // Returns the number of decimal digits in n. Leading zeros are not counted @@ -920,7 +920,7 @@ inline unsigned count_digits(uint64_t n) { // Based on http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 // and the benchmark https://github.com/localvoid/cxx-benchmark-count-digits. int t = (64 - FMT_BUILTIN_CLZLL(n | 1)) * 1233 >> 12; - return to_unsigned(t) - (n < Data::POWERS_OF_10_64[t]) + 1; + return to_unsigned(t) - (n < data::POWERS_OF_10_64[t]) + 1; } #else // Fallback version of count_digits used when __builtin_clz is not available. @@ -944,18 +944,18 @@ inline unsigned count_digits(uint64_t n) { // Optional version of count_digits for better performance on 32-bit platforms. inline unsigned count_digits(uint32_t n) { int t = (32 - FMT_BUILTIN_CLZ(n | 1)) * 1233 >> 12; - return to_unsigned(t) - (n < Data::POWERS_OF_10_32[t]) + 1; + return to_unsigned(t) - (n < data::POWERS_OF_10_32[t]) + 1; } #endif // A functor that doesn't add a thousands separator. -struct NoThousandsSep { +struct no_thousands_sep { template void operator()(Char *) {} }; // A functor that adds a thousands separator. -class ThousandsSep { +class add_thousands_sep { private: fmt::string_view sep_; @@ -963,7 +963,8 @@ class ThousandsSep { unsigned digit_index_; public: - explicit ThousandsSep(fmt::string_view sep) : sep_(sep), digit_index_(0) {} + explicit add_thousands_sep(fmt::string_view sep) + : sep_(sep), digit_index_(0) {} template void operator()(Char *&buffer) { @@ -988,9 +989,9 @@ inline void format_decimal(Char *buffer, UInt value, unsigned num_digits, // "Three Optimization Tips for C++". See speed-test for a comparison. unsigned index = static_cast((value % 100) * 2); value /= 100; - *--buffer = Data::DIGITS[index + 1]; + *--buffer = data::DIGITS[index + 1]; thousands_sep(buffer); - *--buffer = Data::DIGITS[index]; + *--buffer = data::DIGITS[index]; thousands_sep(buffer); } if (value < 10) { @@ -998,14 +999,14 @@ inline void format_decimal(Char *buffer, UInt value, unsigned num_digits, return; } unsigned index = static_cast(value * 2); - *--buffer = Data::DIGITS[index + 1]; + *--buffer = data::DIGITS[index + 1]; thousands_sep(buffer); - *--buffer = Data::DIGITS[index]; + *--buffer = data::DIGITS[index]; } template inline void format_decimal(Char *buffer, UInt value, unsigned num_digits) { - return format_decimal(buffer, value, num_digits, NoThousandsSep()); + return format_decimal(buffer, value, num_digits, no_thousands_sep()); } #ifndef _WIN32 @@ -1019,12 +1020,12 @@ inline void format_decimal(Char *buffer, UInt value, unsigned num_digits) { #if FMT_USE_WINDOWS_H // A converter from UTF-8 to UTF-16. // It is only provided for Windows since other systems support UTF-8 natively. -class UTF8ToUTF16 { +class utf8_to_utf16 { private: - MemoryBuffer buffer_; + wmemory_buffer buffer_; public: - FMT_API explicit UTF8ToUTF16(string_view s); + FMT_API explicit utf8_to_utf16(string_view s); operator wstring_view() const { return wstring_view(&buffer_[0], size()); } size_t size() const { return buffer_.size() - 1; } const wchar_t *c_str() const { return &buffer_[0]; } @@ -1035,7 +1036,7 @@ class UTF8ToUTF16 { // It is only provided for Windows since other systems support UTF-8 natively. class UTF16ToUTF8 { private: - MemoryBuffer buffer_; + memory_buffer buffer_; public: UTF16ToUTF8() {} @@ -1055,21 +1056,6 @@ FMT_API void format_windows_error(fmt::buffer &out, int error_code, fmt::string_view message) FMT_NOEXCEPT; #endif -template -struct EnableIf {}; - -template -struct EnableIf { typedef T type; }; - -template -struct Conditional { typedef T type; }; - -template -struct Conditional { typedef F type; }; - -template -struct False { enum { value = 0 }; }; - template struct Null {}; @@ -1146,7 +1132,7 @@ struct string_value { }; template -struct CustomValue { +struct custom_value { typedef void (*FormatFunc)( basic_buffer &buffer, const void *arg, void *ctx); @@ -1229,7 +1215,7 @@ class value { string_value sstring; string_value ustring; string_value tstring; - CustomValue custom; + custom_value custom; }; typedef typename Context::char_type Char; @@ -1358,7 +1344,7 @@ class value { template value(const T &value, - typename EnableIf::value, int>::type = 0) { + typename enable_if::value, int>::type = 0) { static_assert(internal::type() == internal::CUSTOM, "invalid type"); this->custom.value = &value; this->custom.format = &format_custom_arg; @@ -1366,7 +1352,7 @@ class value { template value(const T &value, - typename EnableIf::value, int>::type = 0) { + typename enable_if::value, int>::type = 0) { static_assert(internal::type() == internal::INT, "invalid type"); this->int_value = value; } @@ -1528,10 +1514,10 @@ inline fmt::string_view thousands_sep(...) { return ""; } template void format_value(basic_buffer &, const T &, Formatter &, const Char *) { - FMT_STATIC_ASSERT(False::value, + FMT_STATIC_ASSERT(sizeof(T) < 0, "Cannot format argument. To enable the use of ostream " "operator<< include fmt/ostream.h. Otherwise provide " - "an overload of format_arg."); + "an overload of format_value."); } template @@ -1933,18 +1919,18 @@ class ArgFormatterBase { } template - void write_str(basic_string_view value, - typename EnableIf< - std::is_same::value && - std::is_same::value, int>::type = 0) { + typename enable_if< + std::is_same::value && + std::is_same::value>::type + write_str(basic_string_view value) { writer_.write_str(value, spec_); } template - void write_str(basic_string_view value, - typename EnableIf< - !std::is_same::value || - !std::is_same::value, int>::type = 0) { + typename enable_if< + !std::is_same::value || + !std::is_same::value>::type + write_str(basic_string_view value) { // Do nothing. } @@ -1994,7 +1980,7 @@ class ArgFormatterBase { if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0) FMT_THROW(format_error("invalid format specifier for char")); typedef typename basic_writer::CharPtr CharPtr; - Char fill = internal::CharTraits::cast(spec_.fill()); + Char fill = internal::char_traits::cast(spec_.fill()); CharPtr out = CharPtr(); const unsigned CHAR_WIDTH = 1; if (spec_.width_ > CHAR_WIDTH) { @@ -2012,7 +1998,7 @@ class ArgFormatterBase { } else { out = writer_.grow_buffer(CHAR_WIDTH); } - *out = internal::CharTraits::cast(value); + *out = internal::char_traits::cast(value); } void operator()(const char *value) { @@ -2116,7 +2102,7 @@ class arg_formatter : public internal::ArgFormatterBase { using internal::ArgFormatterBase::operator(); /** Formats an argument of a custom (user-defined) type. */ - void operator()(internal::CustomValue c) { + void operator()(internal::custom_value c) { c.format(this->writer().buffer(), c.value, &ctx_); } }; @@ -2260,7 +2246,7 @@ class basic_writer { FMT_DISALLOW_COPY_AND_ASSIGN(basic_writer); - typedef typename internal::CharTraits::CharPtr CharPtr; + typedef typename internal::char_traits::CharPtr CharPtr; #if FMT_SECURE_SCL // Returns pointer value. @@ -2294,8 +2280,8 @@ class basic_writer { // Writes a decimal integer. template void write_decimal(Int value) { - typedef typename internal::IntTraits::MainType MainType; - MainType abs_value = static_cast(value); + typedef typename internal::int_traits::main_type main_type; + main_type abs_value = static_cast(value); if (internal::is_negative(value)) { abs_value = 0 - abs_value; *write_unsigned_decimal(abs_value, 1) = '-'; @@ -2478,7 +2464,7 @@ typename basic_writer::CharPtr basic_writer::write_str( CharPtr out = CharPtr(); if (spec.width() > size) { out = grow_buffer(spec.width()); - Char fill = internal::CharTraits::cast(spec.fill()); + Char fill = internal::char_traits::cast(spec.fill()); if (spec.align() == ALIGN_RIGHT) { std::uninitialized_fill_n(out, spec.width() - size, fill); out += spec.width() - size; @@ -2499,7 +2485,7 @@ template void basic_writer::write_str( basic_string_view s, const format_specs &spec) { // Check if StrChar is convertible to Char. - internal::CharTraits::convert(StrChar()); + internal::char_traits::convert(StrChar()); if (spec.type_ && spec.type_ != 's') internal::report_unknown_type(spec.type_, "string"); const StrChar *str_value = s.data(); @@ -2521,7 +2507,7 @@ typename basic_writer::CharPtr basic_writer::fill_padding( std::size_t content_size, wchar_t fill) { std::size_t padding = total_size - content_size; std::size_t left_padding = padding / 2; - Char fill_char = internal::CharTraits::cast(fill); + Char fill_char = internal::char_traits::cast(fill); std::uninitialized_fill_n(buffer, left_padding, fill_char); buffer += left_padding; CharPtr content = buffer; @@ -2537,7 +2523,7 @@ typename basic_writer::CharPtr basic_writer::prepare_int_buffer( const char *prefix, unsigned prefix_size) { unsigned width = spec.width(); Alignment align = spec.align(); - Char fill = internal::CharTraits::cast(spec.fill()); + Char fill = internal::char_traits::cast(spec.fill()); if (spec.precision() > static_cast(num_digits)) { // Octal prefix '0' is counted as a digit, so ignore it if precision // is specified. @@ -2597,7 +2583,7 @@ template template void basic_writer::write_int(T value, Spec spec) { unsigned prefix_size = 0; - typedef typename internal::IntTraits::MainType UnsignedType; + typedef typename internal::int_traits::main_type UnsignedType; UnsignedType abs_value = static_cast(value); char prefix[4] = ""; if (internal::is_negative(value)) { @@ -2673,7 +2659,8 @@ void basic_writer::write_int(T value, Spec spec) { unsigned size = static_cast( num_digits + sep.size() * ((num_digits - 1) / 3)); CharPtr p = prepare_int_buffer(size, spec, prefix, prefix_size) + 1; - internal::format_decimal(get(p), abs_value, 0, internal::ThousandsSep(sep)); + internal::format_decimal(get(p), abs_value, 0, + internal::add_thousands_sep(sep)); break; } default: @@ -2784,7 +2771,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { *format_ptr = '\0'; // Format using snprintf. - Char fill = internal::CharTraits::cast(spec.fill()); + Char fill = internal::char_traits::cast(spec.fill()); unsigned n = 0; Char *start = 0; for (;;) { @@ -2799,7 +2786,7 @@ void basic_writer::write_double(T value, const format_specs &spec) { } #endif start = &buffer_[offset]; - int result = internal::CharTraits::format_float( + int result = internal::char_traits::format_float( start, buffer_size, format, width_for_sprintf, spec.precision(), value); if (result >= 0) { n = internal::to_unsigned(result); @@ -3015,16 +3002,16 @@ class FormatInt { // "Three Optimization Tips for C++". See speed-test for a comparison. unsigned index = static_cast((value % 100) * 2); value /= 100; - *--buffer_end = internal::Data::DIGITS[index + 1]; - *--buffer_end = internal::Data::DIGITS[index]; + *--buffer_end = internal::data::DIGITS[index + 1]; + *--buffer_end = internal::data::DIGITS[index]; } if (value < 10) { *--buffer_end = static_cast('0' + value); return buffer_end; } unsigned index = static_cast(value * 2); - *--buffer_end = internal::Data::DIGITS[index + 1]; - *--buffer_end = internal::Data::DIGITS[index]; + *--buffer_end = internal::data::DIGITS[index + 1]; + *--buffer_end = internal::data::DIGITS[index]; return buffer_end; } @@ -3079,8 +3066,8 @@ class FormatInt { // write a terminating null character. template inline void format_decimal(char *&buffer, T value) { - typedef typename internal::IntTraits::MainType MainType; - MainType abs_value = static_cast(value); + typedef typename internal::int_traits::main_type main_type; + main_type abs_value = static_cast(value); if (internal::is_negative(value)) { *buffer++ = '-'; abs_value = 0 - abs_value; @@ -3091,8 +3078,8 @@ inline void format_decimal(char *&buffer, T value) { return; } unsigned index = static_cast(abs_value * 2); - *buffer++ = internal::Data::DIGITS[index]; - *buffer++ = internal::Data::DIGITS[index + 1]; + *buffer++ = internal::data::DIGITS[index]; + *buffer++ = internal::data::DIGITS[index + 1]; return; } unsigned num_digits = internal::count_digits(abs_value); @@ -3211,7 +3198,7 @@ class CustomFormatter { CustomFormatter(basic_buffer &buffer, Context &ctx) : buffer_(buffer), ctx_(ctx) {} - bool operator()(internal::CustomValue custom) { + bool operator()(internal::custom_value custom) { custom.format(buffer_, custom.value, &ctx_); return true; } diff --git a/fmt/ostream.cc b/fmt/ostream.cc index f9136482..34c0bc99 100644 --- a/fmt/ostream.cc +++ b/fmt/ostream.cc @@ -14,7 +14,7 @@ namespace fmt { namespace internal { FMT_FUNC void write(std::ostream &os, buffer &buf) { const char *data = buf.data(); - typedef internal::MakeUnsigned::Type UnsignedStreamSize; + typedef internal::make_unsigned::type UnsignedStreamSize; UnsignedStreamSize size = buf.size(); UnsignedStreamSize max_size = internal::to_unsigned((std::numeric_limits::max)()); diff --git a/fmt/printf.h b/fmt/printf.h index 02c33fba..c77100a8 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -101,7 +101,7 @@ class ArgConverter { typename std::enable_if::value>::type operator()(U value) { bool is_signed = type_ == 'd' || type_ == 'i'; - typedef typename internal::Conditional< + typedef typename internal::conditional< is_same::value, U, T>::type TargetType; typedef basic_context context; if (sizeof(TargetType) <= sizeof(int)) { @@ -110,7 +110,7 @@ class ArgConverter { arg_ = internal::make_arg( static_cast(static_cast(value))); } else { - typedef typename internal::MakeUnsigned::Type Unsigned; + typedef typename internal::make_unsigned::type Unsigned; arg_ = internal::make_arg( static_cast(static_cast(value))); } @@ -122,7 +122,7 @@ class ArgConverter { arg_ = internal::make_arg(static_cast(value)); } else { arg_ = internal::make_arg( - static_cast::Type>(value)); + static_cast::type>(value)); } } } @@ -183,7 +183,7 @@ class PrintfWidthHandler { template typename std::enable_if::value, unsigned>::type operator()(T value) { - typedef typename internal::IntTraits::MainType UnsignedType; + typedef typename internal::int_traits::main_type UnsignedType; UnsignedType width = static_cast(value); if (internal::is_negative(value)) { spec_.align_ = ALIGN_LEFT; @@ -285,7 +285,7 @@ class printf_arg_formatter : public internal::ArgFormatterBase { } /** Formats an argument of a custom (user-defined) type. */ - void operator()(internal::CustomValue c) { + void operator()(internal::custom_value c) { const Char format_str[] = {'}', '\0'}; auto args = basic_args>(); basic_context ctx(format_str, args); diff --git a/test/format-test.cc b/test/format-test.cc index 2e1baaf2..14b95361 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1531,7 +1531,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase { void operator()(int value) { call(value); } - void operator()(fmt::internal::CustomValue) {} + void operator()(fmt::internal::custom_value) {} }; void custom_vformat(fmt::CStringRef format_str, fmt::args args) { diff --git a/test/ostream-test.cc b/test/ostream-test.cc index 2ab22248..fd40a2a1 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -155,7 +155,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { const char *data = 0; std::size_t size = max_size; do { - typedef fmt::internal::MakeUnsigned::Type UStreamSize; + typedef fmt::internal::make_unsigned::type UStreamSize; UStreamSize n = std::min( size, fmt::internal::to_unsigned(max_streamsize)); EXPECT_CALL(streambuf, xsputn(data, static_cast(n))) diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index 6b7104fc..5a337b6e 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -279,7 +279,7 @@ TEST(FileTest, Size) { EXPECT_GE(f.size(), 0); EXPECT_EQ(content.size(), static_cast(f.size())); #ifdef _WIN32 - fmt::internal::MemoryBuffer message; + fmt::memory_buffer message; fmt::internal::format_windows_error( message, ERROR_ACCESS_DENIED, "cannot get file size"); fstat_sim = ERROR; diff --git a/test/printf-test.cc b/test/printf-test.cc index 65bcca72..312f714f 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -277,11 +277,11 @@ TEST(PrintfTest, DynamicPrecision) { } template -struct MakeSigned { typedef T Type; }; +struct make_signed { typedef T type; }; #define SPECIALIZE_MAKE_SIGNED(T, S) \ template <> \ - struct MakeSigned { typedef S Type; } + struct make_signed { typedef S type; } SPECIALIZE_MAKE_SIGNED(char, signed char); SPECIALIZE_MAKE_SIGNED(unsigned char, signed char); @@ -306,13 +306,13 @@ void TestLength(const char *length_spec, U value) { signed_value = static_cast(value); unsigned_value = static_cast(value); } - using fmt::internal::MakeUnsigned; + using fmt::internal::make_unsigned; if (sizeof(U) <= sizeof(int) && sizeof(int) < sizeof(T)) { signed_value = static_cast(value); - unsigned_value = static_cast::Type>(value); + unsigned_value = static_cast::type>(value); } else { - signed_value = static_cast::Type>(value); - unsigned_value = static_cast::Type>(value); + signed_value = static_cast::type>(value); + unsigned_value = static_cast::type>(value); } std::ostringstream os; os << signed_value; diff --git a/test/util-test.cc b/test/util-test.cc index f9ca8e5a..387203e5 100644 --- a/test/util-test.cc +++ b/test/util-test.cc @@ -383,7 +383,7 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) { TEST(FixedBufferTest, Ctor) { char array[10] = "garbage"; - fmt::FixedBuffer buffer(array, sizeof(array)); + fmt::basic_fixed_buffer buffer(array, sizeof(array)); EXPECT_EQ(0u, buffer.size()); EXPECT_EQ(10u, buffer.capacity()); EXPECT_EQ(array, buffer.data()); @@ -391,7 +391,7 @@ TEST(FixedBufferTest, Ctor) { TEST(FixedBufferTest, CompileTimeSizeCtor) { char array[10] = "garbage"; - fmt::FixedBuffer buffer(array); + fmt::basic_fixed_buffer buffer(array); EXPECT_EQ(0u, buffer.size()); EXPECT_EQ(10u, buffer.capacity()); EXPECT_EQ(array, buffer.data()); @@ -399,7 +399,7 @@ TEST(FixedBufferTest, CompileTimeSizeCtor) { TEST(FixedBufferTest, BufferOverflow) { char array[10]; - fmt::FixedBuffer buffer(array); + fmt::basic_fixed_buffer buffer(array); buffer.resize(10); EXPECT_THROW_MSG(buffer.resize(11), std::runtime_error, "buffer overflow"); } @@ -445,7 +445,7 @@ namespace fmt { namespace internal { template -bool operator==(CustomValue lhs, CustomValue rhs) { +bool operator==(custom_value lhs, custom_value rhs) { return lhs.value == rhs.value; } } @@ -575,10 +575,10 @@ TEST(UtilTest, PointerArg) { TEST(UtilTest, CustomArg) { ::Test test; - typedef MockVisitor> Visitor; + typedef MockVisitor> Visitor; testing::StrictMock visitor; EXPECT_CALL(visitor, visit(_)).WillOnce( - testing::Invoke([&](fmt::internal::CustomValue custom) { + testing::Invoke([&](fmt::internal::custom_value custom) { EXPECT_EQ(&test, custom.value); fmt::memory_buffer buffer; fmt::context ctx("}", fmt::args()); @@ -659,7 +659,7 @@ TEST(UtilTest, UTF16ToUTF8) { TEST(UtilTest, UTF8ToUTF16) { std::string s = "лошадка"; - fmt::internal::UTF8ToUTF16 u(s.c_str()); + fmt::internal::utf8_to_utf16 u(s.c_str()); EXPECT_EQ(L"\x043B\x043E\x0448\x0430\x0434\x043A\x0430", u.str()); EXPECT_EQ(7, u.size()); } @@ -668,7 +668,7 @@ template void check_utf_conversion_error( const char *message, fmt::basic_string_view str = fmt::basic_string_view(0, 0)) { - fmt::internal::MemoryBuffer out; + fmt::memory_buffer out; fmt::internal::format_windows_error(out, ERROR_INVALID_PARAMETER, message); fmt::SystemError error(0, ""); try { @@ -687,8 +687,8 @@ TEST(UtilTest, UTF16ToUTF8Error) { TEST(UtilTest, UTF8ToUTF16Error) { const char *message = "cannot convert string from UTF-8 to UTF-16"; - check_utf_conversion_error(message); - check_utf_conversion_error( + check_utf_conversion_error(message); + check_utf_conversion_error( message, fmt::string_view("foo", INT_MAX + 1u)); } @@ -753,7 +753,7 @@ TEST(UtilTest, FormatWindowsError) { reinterpret_cast(&message), 0, 0); fmt::internal::UTF16ToUTF8 utf8_message(message); LocalFree(message); - fmt::internal::MemoryBuffer actual_message; + fmt::memory_buffer actual_message; fmt::internal::format_windows_error( actual_message, ERROR_FILE_EXISTS, "test"); EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), @@ -780,7 +780,7 @@ TEST(UtilTest, FormatLongWindowsError) { } fmt::internal::UTF16ToUTF8 utf8_message(message); LocalFree(message); - fmt::internal::MemoryBuffer actual_message; + fmt::memory_buffer actual_message; fmt::internal::format_windows_error( actual_message, provisioning_not_allowed, "test"); EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), @@ -793,7 +793,7 @@ TEST(UtilTest, WindowsError) { } TEST(UtilTest, ReportWindowsError) { - fmt::internal::MemoryBuffer out; + fmt::memory_buffer out; fmt::internal::format_windows_error(out, ERROR_FILE_EXISTS, "test error"); out.push_back('\n'); EXPECT_WRITE(stderr, @@ -820,13 +820,13 @@ TEST(UtilTest, IsEnumConvertibleToInt) { template bool check_enable_if( - typename fmt::internal::EnableIf::type *) { + typename fmt::internal::enable_if::type *) { return true; } template bool check_enable_if( - typename fmt::internal::EnableIf::type *) { + typename fmt::internal::enable_if::type *) { return false; } @@ -839,10 +839,10 @@ TEST(UtilTest, EnableIf) { TEST(UtilTest, Conditional) { int i = 0; - fmt::internal::Conditional::type *pi = &i; + fmt::internal::conditional::type *pi = &i; (void)pi; char c = 0; - fmt::internal::Conditional::type *pc = &c; + fmt::internal::conditional::type *pc = &c; (void)pc; }