Commit 7ae8bd70 authored by Victor Zverovich's avatar Victor Zverovich

basic_format_arg -> basic_arg, Buffer -> buffer

parent bf0f1075
This diff is collapsed.
......@@ -23,11 +23,11 @@ class FormatBuf : public std::basic_streambuf<Char> {
typedef typename std::basic_streambuf<Char>::int_type int_type;
typedef typename std::basic_streambuf<Char>::traits_type traits_type;
Buffer<Char> &buffer_;
buffer<Char> &buffer_;
Char *start_;
public:
FormatBuf(Buffer<Char> &buffer) : buffer_(buffer), start_(&buffer[0]) {
FormatBuf(buffer<Char> &buffer) : buffer_(buffer), start_(&buffer[0]) {
this->setp(start_, start_ + buffer_.capacity());
}
......
......@@ -85,11 +85,11 @@ class ArgConverter {
private:
typedef typename Context::char_type Char;
basic_format_arg<Context> &arg_;
basic_arg<Context> &arg_;
typename Context::char_type type_;
public:
ArgConverter(basic_format_arg<Context> &arg, Char type)
ArgConverter(basic_arg<Context> &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 <typename T, typename Context, typename Char>
void convert_arg(basic_format_arg<Context> &arg, Char type) {
void convert_arg(basic_arg<Context> &arg, Char type) {
visit(ArgConverter<T, Context>(arg, type), arg);
}
......@@ -147,12 +147,12 @@ void convert_arg(basic_format_arg<Context> &arg, Char type) {
template <typename Context>
class CharConverter {
private:
basic_format_arg<Context> &arg_;
basic_arg<Context> &arg_;
FMT_DISALLOW_COPY_AND_ASSIGN(CharConverter);
public:
explicit CharConverter(basic_format_arg<Context> &arg) : arg_(arg) {}
explicit CharConverter(basic_arg<Context> &arg) : arg_(arg) {}
template <typename T>
typename std::enable_if<std::is_integral<T>::value>::type
......@@ -287,7 +287,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
/** Formats an argument of a custom (user-defined) type. */
void operator()(internal::CustomValue<Char> c) {
const Char format_str[] = {'}', '\0'};
auto args = basic_format_args<basic_format_context<Char>>();
auto args = basic_args<basic_format_context<Char>>();
basic_format_context<Char> ctx(format_str, args);
c.format(this->writer(), c.value, &ctx);
}
......@@ -328,7 +328,7 @@ class printf_context :
\endrst
*/
explicit printf_context(BasicCStringRef<Char> format_str,
basic_format_args<printf_context> args)
basic_args<printf_context> 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<Char> &w, const T &value,
template <typename Char>
void printf(basic_writer<Char> &w, BasicCStringRef<Char> format,
basic_format_args<printf_context<Char>> args) {
basic_args<printf_context<Char>> args) {
printf_context<Char>(format, args).format(w);
}
typedef basic_format_args<printf_context<char>> printf_args;
typedef basic_args<printf_context<char>> 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<printf_context<wchar_t>> args) {
WCStringRef format, basic_args<printf_context<wchar_t>> args) {
WMemoryWriter w;
printf(w, format, args);
return w.str();
......
......@@ -18,7 +18,7 @@ namespace internal {
// A buffer that stores data in ``std::string``.
template <typename Char>
class StringBuffer : public Buffer<Char> {
class StringBuffer : public buffer<Char> {
private:
std::basic_string<Char> data_;
......
......@@ -27,7 +27,7 @@ void format_value(writer &w, const std::tm &tm, format_context &ctx) {
internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> format;
format.append(s, end + 1);
format[format.size() - 1] = '\0';
Buffer<char> &buffer = w.buffer();
buffer<char> &buffer = w.buffer();
std::size_t start = buffer.size();
for (;;) {
std::size_t size = buffer.capacity() - start;
......
......@@ -63,7 +63,7 @@ typedef fmt::printf_context<char, CustomPrintfArgFormatter>
std::string custom_vsprintf(
const char* format_str,
fmt::basic_format_args<CustomPrintfFormatter> args) {
fmt::basic_args<CustomPrintfFormatter> args) {
fmt::MemoryWriter writer;
CustomPrintfFormatter formatter(format_str, args);
formatter.format(writer);
......
......@@ -136,7 +136,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
class TestWriter : public fmt::basic_writer<char> {
private:
struct TestBuffer : fmt::Buffer<char> {
struct TestBuffer : fmt::buffer<char> {
explicit TestBuffer(std::size_t size) { size_ = size; }
void grow(std::size_t) {}
} buffer_;
......
......@@ -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<Char> &w, Test,
}
template <typename Context, typename T>
basic_format_arg<Context> make_arg(const T &value) {
basic_arg<Context> make_arg(const T &value) {
return fmt::internal::make_arg<Context>(value);
}
} // namespace
......@@ -107,24 +107,24 @@ TEST(AllocatorTest, AllocatorRef) {
#if FMT_USE_TYPE_TRAITS
TEST(BufferTest, Noncopyable) {
EXPECT_FALSE(std::is_copy_constructible<Buffer<char> >::value);
EXPECT_FALSE(std::is_copy_assignable<Buffer<char> >::value);
EXPECT_FALSE(std::is_copy_constructible<buffer<char> >::value);
EXPECT_FALSE(std::is_copy_assignable<buffer<char> >::value);
}
TEST(BufferTest, Nonmoveable) {
EXPECT_FALSE(std::is_move_constructible<Buffer<char> >::value);
EXPECT_FALSE(std::is_move_assignable<Buffer<char> >::value);
EXPECT_FALSE(std::is_move_constructible<buffer<char> >::value);
EXPECT_FALSE(std::is_move_assignable<buffer<char> >::value);
}
#endif
// A test buffer with a dummy grow method.
template <typename T>
struct TestBuffer : Buffer<T> {
struct TestBuffer : buffer<T> {
void grow(std::size_t size) { this->capacity_ = size; }
};
template <typename T>
struct MockBuffer : Buffer<T> {
struct MockBuffer : buffer<T> {
MOCK_METHOD1(do_grow, void (std::size_t size));
void grow(std::size_t size) {
......@@ -133,8 +133,8 @@ struct MockBuffer : Buffer<T> {
}
MockBuffer() {}
MockBuffer(T *ptr) : Buffer<T>(ptr) {}
MockBuffer(T *ptr, std::size_t capacity) : Buffer<T>(ptr, capacity) {}
MockBuffer(T *ptr) : buffer<T>(ptr) {}
MockBuffer(T *ptr, std::size_t capacity) : buffer<T>(ptr, capacity) {}
};
TEST(BufferTest, Ctor) {
......@@ -170,7 +170,7 @@ TEST(BufferTest, VirtualDtor) {
typedef StrictMock<DyingBuffer> StictMockBuffer;
StictMockBuffer *mock_buffer = new StictMockBuffer();
EXPECT_CALL(*mock_buffer, die());
Buffer<int> *buffer = mock_buffer;
buffer<int> *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<char> &const_buffer = buffer;
const fmt::buffer<char> &const_buffer = buffer;
EXPECT_EQ(42, const_buffer[3]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment