diff --git a/fmt/format.h b/fmt/format.h index ebf36025..93d4e0e8 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -371,7 +371,7 @@ typedef basic_writer writer; typedef basic_writer wwriter; template -class basic_format_arg; +class basic_arg; template class ArgFormatter; @@ -587,16 +587,16 @@ inline T *make_ptr(T *ptr, std::size_t) { return ptr; } \endrst */ template -class Buffer { +class buffer { private: - FMT_DISALLOW_COPY_AND_ASSIGN(Buffer); + FMT_DISALLOW_COPY_AND_ASSIGN(buffer); protected: T *ptr_; std::size_t size_; std::size_t capacity_; - Buffer(T *ptr = 0, std::size_t capacity = 0) + buffer(T *ptr = 0, std::size_t capacity = 0) : ptr_(ptr), size_(0), capacity_(capacity) {} /** @@ -608,7 +608,7 @@ class Buffer { virtual void grow(std::size_t size) = 0; public: - virtual ~Buffer() {} + virtual ~buffer() {} /** Returns the size of this buffer. */ std::size_t size() const { return size_; } @@ -653,7 +653,7 @@ class Buffer { template template -void Buffer::append(const U *begin, const U *end) { +void buffer::append(const U *begin, const U *end) { std::size_t new_size = size_ + internal::to_unsigned(end - begin); if (new_size > capacity_) grow(new_size); @@ -667,7 +667,7 @@ namespace internal { // A memory buffer for trivially copyable/constructible types with the first // SIZE elements stored in the object itself. template > -class MemoryBuffer : private Allocator, public Buffer { +class MemoryBuffer : private Allocator, public buffer { private: T data_[SIZE]; @@ -681,7 +681,7 @@ class MemoryBuffer : private Allocator, public Buffer { public: explicit MemoryBuffer(const Allocator &alloc = Allocator()) - : Allocator(alloc), Buffer(data_, SIZE) {} + : Allocator(alloc), buffer(data_, SIZE) {} ~MemoryBuffer() { deallocate(); } #if FMT_USE_RVALUE_REFERENCES @@ -743,9 +743,10 @@ void MemoryBuffer::grow(std::size_t size) { // A fixed-size buffer. template -class FixedBuffer : public fmt::Buffer { +class FixedBuffer : public fmt::buffer { public: - FixedBuffer(Char *array, std::size_t size) : fmt::Buffer(array, size) {} + FixedBuffer(Char *array, std::size_t size) + : fmt::buffer(array, size) {} protected: FMT_API void grow(std::size_t size); @@ -1322,34 +1323,34 @@ template class ArgMap; template -basic_format_arg make_arg(const T &value); +basic_arg make_arg(const T &value); } // namespace internal struct monostate {}; template -class basic_format_args; +class basic_args; // A formatting argument. It is a trivially copyable/constructible type to // allow storage in internal::MemoryBuffer. template -class basic_format_arg { +class basic_arg { private: internal::value value_; internal::Type type_; template - friend basic_format_arg internal::make_arg(const T &value); + friend basic_arg internal::make_arg(const T &value); template friend typename std::result_of::type - visit(Visitor &&vis, basic_format_arg arg); + visit(Visitor &&vis, basic_arg arg); - friend class basic_format_args; + friend class basic_args; friend class internal::ArgMap; public: - basic_format_arg() : type_(internal::NONE) {} + basic_arg() : type_(internal::NONE) {} explicit operator bool() const noexcept { return type_ != internal::NONE; } @@ -1368,8 +1369,8 @@ class basic_format_arg { } }; -typedef basic_format_arg format_arg; -typedef basic_format_arg wformat_arg; +typedef basic_arg format_arg; +typedef basic_arg wformat_arg; /** \rst @@ -1380,7 +1381,7 @@ typedef basic_format_arg wformat_arg; */ template typename std::result_of::type - visit(Visitor &&vis, basic_format_arg arg) { + visit(Visitor &&vis, basic_arg arg) { typedef typename Context::char_type Char; switch (arg.type_) { case internal::NONE: @@ -1422,8 +1423,8 @@ typename std::result_of::type namespace internal { template -basic_format_arg make_arg(const T &value) { - basic_format_arg arg; +basic_arg make_arg(const T &value) { + basic_arg arg; arg.type_ = internal::type(); arg.value_ = value; return arg; @@ -1474,14 +1475,14 @@ void format_value(basic_writer &, const T &, Formatter &, const Char *) { } template -struct NamedArg : basic_format_arg { +struct NamedArg : basic_arg { typedef typename Context::char_type Char; BasicStringRef name; template NamedArg(BasicStringRef argname, const T &value) - : basic_format_arg(make_arg(value)), name(argname) {} + : basic_arg(make_arg(value)), name(argname) {} }; class RuntimeError : public std::runtime_error { @@ -1508,7 +1509,7 @@ inline typename std::enable_if>::type } template -inline typename std::enable_if>::type +inline typename std::enable_if>::type make_arg(const T& value) { return make_arg(value); } @@ -1525,7 +1526,7 @@ class format_arg_store { typedef typename Context::char_type char_type; typedef typename std::conditional, basic_format_arg>::type value_type; + internal::value, basic_arg>::type value_type; // If the arguments are not packed, add one more element to mark the end. typedef std::array Array; @@ -1554,10 +1555,10 @@ inline format_arg_store /** Formatting arguments. */ template -class basic_format_args { +class basic_args { public: typedef unsigned size_type; - typedef basic_format_arg format_arg; + typedef basic_arg format_arg; private: // To reduce compiled code size per formatting function call, types of first @@ -1610,10 +1611,10 @@ class basic_format_args { } public: - basic_format_args() : types_(0) {} + basic_args() : types_(0) {} template - basic_format_args(const format_arg_store &store) + basic_args(const format_arg_store &store) : types_(store.TYPES) { set_data(store.data()); } @@ -1626,8 +1627,8 @@ class basic_format_args { } }; -typedef basic_format_args format_args; -typedef basic_format_args wformat_args; +typedef basic_args format_args; +typedef basic_args wformat_args; enum Alignment { ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ALIGN_NUMERIC @@ -1791,15 +1792,15 @@ class ArgMap { private: typedef typename Context::char_type Char; typedef std::vector< - std::pair, basic_format_arg > > MapType; + std::pair, basic_arg > > MapType; typedef typename MapType::value_type Pair; MapType map_; public: - void init(const basic_format_args &args); + void init(const basic_args &args); - const basic_format_arg + const basic_arg *find(const fmt::BasicStringRef &name) const { // The list is unsorted, so just return the first matching name. for (typename MapType::const_iterator it = map_.begin(), end = map_.end(); @@ -1812,7 +1813,7 @@ class ArgMap { }; template -void ArgMap::init(const basic_format_args &args) { +void ArgMap::init(const basic_args &args) { if (!map_.empty()) return; typedef internal::NamedArg NamedArg; @@ -1987,17 +1988,17 @@ template class format_context_base { private: const Char *ptr_; - basic_format_args args_; + basic_args args_; int next_arg_index_; protected: - typedef basic_format_arg format_arg; + typedef basic_arg format_arg; - format_context_base(const Char *format_str, basic_format_args args) + format_context_base(const Char *format_str, basic_args args) : ptr_(format_str), args_(args), next_arg_index_(0) {} ~format_context_base() {} - basic_format_args args() const { return args_; } + basic_args args() const { return args_; } // Returns the argument with specified index. format_arg do_get_arg(unsigned arg_index, const char *&error) { @@ -2097,7 +2098,7 @@ class basic_format_context : \endrst */ basic_format_context(const Char *format_str, - basic_format_args args) + basic_args args) : Base(format_str, args) {} // Parses argument id and returns corresponding argument. @@ -2203,7 +2204,7 @@ class basic_writer { private: // Output buffer. - Buffer &buffer_; + buffer &buffer_; FMT_DISALLOW_COPY_AND_ASSIGN(basic_writer); @@ -2306,7 +2307,7 @@ class basic_writer { /** Constructs a ``basic_writer`` object. */ - explicit basic_writer(Buffer &b) : buffer_(b) {} + explicit basic_writer(buffer &b) : buffer_(b) {} public: /** @@ -2348,7 +2349,7 @@ class basic_writer { } void vformat(BasicCStringRef format, - basic_format_args> args); + basic_args> args); /** \rst Writes formatted data. @@ -2447,7 +2448,7 @@ class basic_writer { void clear() FMT_NOEXCEPT { buffer_.clear(); } - Buffer &buffer() FMT_NOEXCEPT { return buffer_; } + buffer &buffer() FMT_NOEXCEPT { return buffer_; } }; template @@ -3242,7 +3243,7 @@ unsigned parse_nonnegative_int(const Char *&s) { template inline void require_numeric_argument( - const basic_format_arg &arg, char spec) { + const basic_arg &arg, char spec) { if (!arg.is_numeric()) { FMT_THROW(fmt::format_error( fmt::format("format specifier '{}' requires numeric argument", spec))); @@ -3264,7 +3265,7 @@ struct IsUnsigned { }; template -void check_sign(const Char *&s, const basic_format_arg &arg) { +void check_sign(const Char *&s, const basic_arg &arg) { char sign = static_cast(*s); require_numeric_argument(arg, sign); if (visit(IsUnsigned(), arg)) { @@ -3378,7 +3379,7 @@ inline typename basic_format_context::format_arg // Formats a single argument. template -void do_format_arg(basic_writer &writer, basic_format_arg arg, +void do_format_arg(basic_writer &writer, basic_arg arg, Context &ctx) { const Char *&s = ctx.ptr(); basic_format_specs spec; @@ -3505,7 +3506,7 @@ void do_format_arg(basic_writer &writer, basic_format_arg arg, /** Formats arguments and writes the output to the writer. */ template void vwrite(basic_writer &writer, BasicCStringRef format_str, - basic_format_args args) { + basic_args args) { basic_format_context ctx(format_str.c_str(), args); const Char *&s = ctx.ptr(); const Char *start = s; @@ -3531,7 +3532,7 @@ void vwrite(basic_writer &writer, BasicCStringRef format_str, template inline void basic_writer::vformat( BasicCStringRef format, - basic_format_args> args) { + basic_args> args) { vwrite>(*this, format, args); } } // namespace fmt diff --git a/fmt/ostream.h b/fmt/ostream.h index bae83100..c6eb17a5 100644 --- a/fmt/ostream.h +++ b/fmt/ostream.h @@ -23,11 +23,11 @@ class FormatBuf : public std::basic_streambuf { typedef typename std::basic_streambuf::int_type int_type; typedef typename std::basic_streambuf::traits_type traits_type; - Buffer &buffer_; + buffer &buffer_; Char *start_; public: - FormatBuf(Buffer &buffer) : buffer_(buffer), start_(&buffer[0]) { + FormatBuf(buffer &buffer) : buffer_(buffer), start_(&buffer[0]) { this->setp(start_, start_ + buffer_.capacity()); } diff --git a/fmt/printf.h b/fmt/printf.h index 3316887a..09ed7762 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -85,11 +85,11 @@ class ArgConverter { private: typedef typename Context::char_type Char; - basic_format_arg &arg_; + basic_arg &arg_; typename Context::char_type type_; public: - ArgConverter(basic_format_arg &arg, Char type) + ArgConverter(basic_arg &arg, Char type) : arg_(arg), type_(type) {} void operator()(bool value) { @@ -139,7 +139,7 @@ class ArgConverter { // type depending on the type specifier: 'd' and 'i' - signed, other - // unsigned). template -void convert_arg(basic_format_arg &arg, Char type) { +void convert_arg(basic_arg &arg, Char type) { visit(ArgConverter(arg, type), arg); } @@ -147,12 +147,12 @@ void convert_arg(basic_format_arg &arg, Char type) { template class CharConverter { private: - basic_format_arg &arg_; + basic_arg &arg_; FMT_DISALLOW_COPY_AND_ASSIGN(CharConverter); public: - explicit CharConverter(basic_format_arg &arg) : arg_(arg) {} + explicit CharConverter(basic_arg &arg) : arg_(arg) {} template typename std::enable_if::value>::type @@ -287,7 +287,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase { /** Formats an argument of a custom (user-defined) type. */ void operator()(internal::CustomValue c) { const Char format_str[] = {'}', '\0'}; - auto args = basic_format_args>(); + auto args = basic_args>(); basic_format_context ctx(format_str, args); c.format(this->writer(), c.value, &ctx); } @@ -328,7 +328,7 @@ class printf_context : \endrst */ explicit printf_context(BasicCStringRef format_str, - basic_format_args args) + basic_args args) : Base(format_str.c_str(), args) {} /** Formats stored arguments and writes the output to the writer. */ @@ -516,11 +516,11 @@ void format_value(basic_writer &w, const T &value, template void printf(basic_writer &w, BasicCStringRef format, - basic_format_args> args) { + basic_args> args) { printf_context(format, args).format(w); } -typedef basic_format_args> printf_args; +typedef basic_args> printf_args; inline std::string vsprintf(CStringRef format, printf_args args) { MemoryWriter w; @@ -543,7 +543,7 @@ inline std::string sprintf(CStringRef format_str, const Args & ... args) { } inline std::wstring vsprintf( - WCStringRef format, basic_format_args> args) { + WCStringRef format, basic_args> args) { WMemoryWriter w; printf(w, format, args); return w.str(); diff --git a/fmt/string.h b/fmt/string.h index 0de41b98..acb399b6 100644 --- a/fmt/string.h +++ b/fmt/string.h @@ -18,7 +18,7 @@ namespace internal { // A buffer that stores data in ``std::string``. template -class StringBuffer : public Buffer { +class StringBuffer : public buffer { private: std::basic_string data_; diff --git a/fmt/time.h b/fmt/time.h index 6b970bcb..f021a892 100644 --- a/fmt/time.h +++ b/fmt/time.h @@ -27,7 +27,7 @@ void format_value(writer &w, const std::tm &tm, format_context &ctx) { internal::MemoryBuffer format; format.append(s, end + 1); format[format.size() - 1] = '\0'; - Buffer &buffer = w.buffer(); + buffer &buffer = w.buffer(); std::size_t start = buffer.size(); for (;;) { std::size_t size = buffer.capacity() - start; diff --git a/test/custom-formatter-test.cc b/test/custom-formatter-test.cc index 8c646211..95117c7c 100644 --- a/test/custom-formatter-test.cc +++ b/test/custom-formatter-test.cc @@ -63,7 +63,7 @@ typedef fmt::printf_context std::string custom_vsprintf( const char* format_str, - fmt::basic_format_args args) { + fmt::basic_args args) { fmt::MemoryWriter writer; CustomPrintfFormatter formatter(format_str, args); formatter.format(writer); diff --git a/test/ostream-test.cc b/test/ostream-test.cc index c2498e90..73c8c053 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -136,7 +136,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { class TestWriter : public fmt::basic_writer { private: - struct TestBuffer : fmt::Buffer { + struct TestBuffer : fmt::buffer { explicit TestBuffer(std::size_t size) { size_ = size; } void grow(std::size_t) {} } buffer_; diff --git a/test/util-test.cc b/test/util-test.cc index 88bad995..7f931f78 100644 --- a/test/util-test.cc +++ b/test/util-test.cc @@ -52,9 +52,9 @@ #undef min #undef max -using fmt::basic_format_arg; +using fmt::basic_arg; using fmt::format_arg; -using fmt::Buffer; +using fmt::buffer; using fmt::StringRef; using fmt::internal::MemoryBuffer; using fmt::internal::value; @@ -74,7 +74,7 @@ void format_value(fmt::basic_writer &w, Test, } template -basic_format_arg make_arg(const T &value) { +basic_arg make_arg(const T &value) { return fmt::internal::make_arg(value); } } // namespace @@ -107,24 +107,24 @@ TEST(AllocatorTest, AllocatorRef) { #if FMT_USE_TYPE_TRAITS TEST(BufferTest, Noncopyable) { - EXPECT_FALSE(std::is_copy_constructible >::value); - EXPECT_FALSE(std::is_copy_assignable >::value); + EXPECT_FALSE(std::is_copy_constructible >::value); + EXPECT_FALSE(std::is_copy_assignable >::value); } TEST(BufferTest, Nonmoveable) { - EXPECT_FALSE(std::is_move_constructible >::value); - EXPECT_FALSE(std::is_move_assignable >::value); + EXPECT_FALSE(std::is_move_constructible >::value); + EXPECT_FALSE(std::is_move_assignable >::value); } #endif // A test buffer with a dummy grow method. template -struct TestBuffer : Buffer { +struct TestBuffer : buffer { void grow(std::size_t size) { this->capacity_ = size; } }; template -struct MockBuffer : Buffer { +struct MockBuffer : buffer { MOCK_METHOD1(do_grow, void (std::size_t size)); void grow(std::size_t size) { @@ -133,8 +133,8 @@ struct MockBuffer : Buffer { } MockBuffer() {} - MockBuffer(T *ptr) : Buffer(ptr) {} - MockBuffer(T *ptr, std::size_t capacity) : Buffer(ptr, capacity) {} + MockBuffer(T *ptr) : buffer(ptr) {} + MockBuffer(T *ptr, std::size_t capacity) : buffer(ptr, capacity) {} }; TEST(BufferTest, Ctor) { @@ -170,7 +170,7 @@ TEST(BufferTest, VirtualDtor) { typedef StrictMock StictMockBuffer; StictMockBuffer *mock_buffer = new StictMockBuffer(); EXPECT_CALL(*mock_buffer, die()); - Buffer *buffer = mock_buffer; + buffer *buffer = mock_buffer; delete buffer; } @@ -181,7 +181,7 @@ TEST(BufferTest, Access) { EXPECT_EQ(11, buffer[0]); buffer[3] = 42; EXPECT_EQ(42, *(&buffer[0] + 3)); - const Buffer &const_buffer = buffer; + const fmt::buffer &const_buffer = buffer; EXPECT_EQ(42, const_buffer[3]); }