Commit 8428621d authored by Victor Zverovich's avatar Victor Zverovich

BasicWriter -> basic_writer

parent 939aff29
...@@ -106,7 +106,7 @@ inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) { ...@@ -106,7 +106,7 @@ inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
const char RESET_COLOR[] = "\x1b[0m"; const char RESET_COLOR[] = "\x1b[0m";
typedef void (*FormatFunc)(Writer &, int, StringRef); typedef void (*FormatFunc)(writer &, int, StringRef);
// Portable thread-safe version of strerror. // Portable thread-safe version of strerror.
// Sets buffer to point to a string describing the error code. // Sets buffer to point to a string describing the error code.
...@@ -176,7 +176,7 @@ int safe_strerror( ...@@ -176,7 +176,7 @@ int safe_strerror(
return StrError(error_code, buffer, buffer_size).run(); return StrError(error_code, buffer, buffer_size).run();
} }
void format_error_code(Writer &out, int error_code, void format_error_code(writer &out, int error_code,
StringRef message) FMT_NOEXCEPT { StringRef message) FMT_NOEXCEPT {
// Report error code making sure that the output fits into // Report error code making sure that the output fits into
// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential // INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
...@@ -215,7 +215,7 @@ namespace internal { ...@@ -215,7 +215,7 @@ namespace internal {
// This method is used to preserve binary compatibility with fmt 3.0. // This method is used to preserve binary compatibility with fmt 3.0.
// It can be removed in 4.0. // It can be removed in 4.0.
FMT_FUNC void format_system_error( FMT_FUNC void format_system_error(
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT { writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
fmt::format_system_error(out, error_code, message); fmt::format_system_error(out, error_code, message);
} }
} // namespace internal } // namespace internal
...@@ -354,7 +354,7 @@ FMT_FUNC void WindowsError::init( ...@@ -354,7 +354,7 @@ FMT_FUNC void WindowsError::init(
} }
FMT_FUNC void internal::format_windows_error( FMT_FUNC void internal::format_windows_error(
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT { writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
FMT_TRY { FMT_TRY {
MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer; MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer;
buffer.resize(INLINE_BUFFER_SIZE); buffer.resize(INLINE_BUFFER_SIZE);
...@@ -383,7 +383,7 @@ FMT_FUNC void internal::format_windows_error( ...@@ -383,7 +383,7 @@ FMT_FUNC void internal::format_windows_error(
#endif // FMT_USE_WINDOWS_H #endif // FMT_USE_WINDOWS_H
FMT_FUNC void format_system_error( FMT_FUNC void format_system_error(
Writer &out, int error_code, StringRef message) FMT_NOEXCEPT { writer &out, int error_code, StringRef message) FMT_NOEXCEPT {
FMT_TRY { FMT_TRY {
internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> buffer; internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> buffer;
buffer.resize(internal::INLINE_BUFFER_SIZE); buffer.resize(internal::INLINE_BUFFER_SIZE);
...@@ -440,7 +440,7 @@ FMT_FUNC void vprint_colored(Color c, CStringRef format, format_args args) { ...@@ -440,7 +440,7 @@ FMT_FUNC void vprint_colored(Color c, CStringRef format, format_args args) {
} }
template <typename Char> template <typename Char>
void printf(BasicWriter<Char> &w, BasicCStringRef<Char> format, void printf(basic_writer<Char> &w, BasicCStringRef<Char> format,
format_args args); format_args args);
FMT_FUNC int vfprintf(std::FILE *f, CStringRef format, printf_args args) { FMT_FUNC int vfprintf(std::FILE *f, CStringRef format, printf_args args) {
...@@ -460,7 +460,7 @@ template void internal::FixedBuffer<char>::grow(std::size_t); ...@@ -460,7 +460,7 @@ template void internal::FixedBuffer<char>::grow(std::size_t);
template void internal::ArgMap<format_context>::init(const format_args &args); template void internal::ArgMap<format_context>::init(const format_args &args);
template void printf_context<char>::format(Writer &writer); template void printf_context<char>::format(writer &writer);
template int internal::CharTraits<char>::format_float( template int internal::CharTraits<char>::format_float(
char *buffer, std::size_t size, const char *format, char *buffer, std::size_t size, const char *format,
...@@ -478,7 +478,7 @@ template void internal::FixedBuffer<wchar_t>::grow(std::size_t); ...@@ -478,7 +478,7 @@ template void internal::FixedBuffer<wchar_t>::grow(std::size_t);
template void internal::ArgMap<wformat_context>::init(const wformat_args &args); template void internal::ArgMap<wformat_context>::init(const wformat_args &args);
template void printf_context<wchar_t>::format(WWriter &writer); template void printf_context<wchar_t>::format(wwriter &writer);
template int internal::CharTraits<wchar_t>::format_float( template int internal::CharTraits<wchar_t>::format_float(
wchar_t *buffer, std::size_t size, const wchar_t *format, wchar_t *buffer, std::size_t size, const wchar_t *format,
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
namespace fmt { namespace fmt {
namespace internal { namespace internal {
FMT_FUNC void write(std::ostream &os, Writer &w) { FMT_FUNC void write(std::ostream &os, writer &w) {
const char *data = w.data(); const char *data = w.data();
typedef internal::MakeUnsigned<std::streamsize>::Type UnsignedStreamSize; typedef internal::MakeUnsigned<std::streamsize>::Type UnsignedStreamSize;
UnsignedStreamSize size = w.size(); UnsignedStreamSize size = w.size();
......
...@@ -68,7 +68,7 @@ struct ConvertToIntImpl<T, true> { ...@@ -68,7 +68,7 @@ struct ConvertToIntImpl<T, true> {
}; };
// Write the content of w to os. // Write the content of w to os.
void write(std::ostream &os, Writer &w); void write(std::ostream &os, writer &w);
template <typename Char, typename T> template <typename Char, typename T>
BasicStringRef<Char> format_value( BasicStringRef<Char> format_value(
...@@ -83,7 +83,7 @@ BasicStringRef<Char> format_value( ...@@ -83,7 +83,7 @@ BasicStringRef<Char> format_value(
// Formats a value. // Formats a value.
template <typename Char, typename T> template <typename Char, typename T>
void format_value(BasicWriter<Char> &w, const T &value, void format_value(basic_writer<Char> &w, const T &value,
basic_format_context<Char> &ctx) { basic_format_context<Char> &ctx) {
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer; internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
auto str = internal::format_value(buffer, value); auto str = internal::format_value(buffer, value);
......
...@@ -224,7 +224,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> { ...@@ -224,7 +224,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
specifier information for standard argument types. specifier information for standard argument types.
\endrst \endrst
*/ */
PrintfArgFormatter(BasicWriter<Char> &writer, FormatSpec &spec) PrintfArgFormatter(basic_writer<Char> &writer, FormatSpec &spec)
: internal::ArgFormatterBase<Char>(writer, spec) {} : internal::ArgFormatterBase<Char>(writer, spec) {}
using Base::operator(); using Base::operator();
...@@ -241,10 +241,10 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> { ...@@ -241,10 +241,10 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
/** Formats a character. */ /** Formats a character. */
void operator()(Char value) { void operator()(Char value) {
const FormatSpec &fmt_spec = this->spec(); const FormatSpec &fmt_spec = this->spec();
BasicWriter<Char> &w = this->writer(); basic_writer<Char> &w = this->writer();
if (fmt_spec.type_ && fmt_spec.type_ != 'c') if (fmt_spec.type_ && fmt_spec.type_ != 'c')
w.write_int(value, fmt_spec); w.write_int(value, fmt_spec);
typedef typename BasicWriter<Char>::CharPtr CharPtr; typedef typename basic_writer<Char>::CharPtr CharPtr;
CharPtr out = CharPtr(); CharPtr out = CharPtr();
if (fmt_spec.width_ > 1) { if (fmt_spec.width_ > 1) {
Char fill = ' '; Char fill = ' ';
...@@ -326,7 +326,7 @@ class printf_context : ...@@ -326,7 +326,7 @@ class printf_context :
: Base(format_str.c_str(), args) {} : Base(format_str.c_str(), args) {}
/** Formats stored arguments and writes the output to the writer. */ /** Formats stored arguments and writes the output to the writer. */
FMT_API void format(BasicWriter<Char> &writer); FMT_API void format(basic_writer<Char> &writer);
}; };
template <typename Char, typename AF> template <typename Char, typename AF>
...@@ -402,7 +402,7 @@ unsigned printf_context<Char, AF>::parse_header( ...@@ -402,7 +402,7 @@ unsigned printf_context<Char, AF>::parse_header(
} }
template <typename Char, typename AF> template <typename Char, typename AF>
void printf_context<Char, AF>::format(BasicWriter<Char> &writer) { void printf_context<Char, AF>::format(basic_writer<Char> &writer) {
const Char *start = this->ptr(); const Char *start = this->ptr();
const Char *s = start; const Char *s = start;
while (*s) { while (*s) {
...@@ -502,14 +502,14 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) { ...@@ -502,14 +502,14 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) {
// Formats a value. // Formats a value.
template <typename Char, typename T> template <typename Char, typename T>
void format_value(BasicWriter<Char> &w, const T &value, void format_value(basic_writer<Char> &w, const T &value,
printf_context<Char>& ctx) { printf_context<Char>& ctx) {
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer; internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
w << internal::format_value(buffer, value); w << internal::format_value(buffer, value);
} }
template <typename Char> template <typename Char>
void printf(BasicWriter<Char> &w, BasicCStringRef<Char> format, void printf(basic_writer<Char> &w, BasicCStringRef<Char> format,
basic_format_args<printf_context<Char>> args) { basic_format_args<printf_context<Char>> args) {
printf_context<Char>(format, args).format(w); printf_context<Char>(format, args).format(w);
} }
......
...@@ -72,7 +72,7 @@ class StringBuffer : public Buffer<Char> { ...@@ -72,7 +72,7 @@ class StringBuffer : public Buffer<Char> {
\endrst \endrst
*/ */
template <typename Char> template <typename Char>
class BasicStringWriter : public BasicWriter<Char> { class BasicStringWriter : public basic_writer<Char> {
private: private:
internal::StringBuffer<Char> buffer_; internal::StringBuffer<Char> buffer_;
...@@ -82,7 +82,7 @@ class BasicStringWriter : public BasicWriter<Char> { ...@@ -82,7 +82,7 @@ class BasicStringWriter : public BasicWriter<Char> {
Constructs a :class:`fmt::BasicStringWriter` object. Constructs a :class:`fmt::BasicStringWriter` object.
\endrst \endrst
*/ */
BasicStringWriter() : BasicWriter<Char>(buffer_) {} BasicStringWriter() : basic_writer<Char>(buffer_) {}
/** /**
\rst \rst
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace fmt { namespace fmt {
void format_value(Writer &w, const std::tm &tm, format_context &ctx) { void format_value(writer &w, const std::tm &tm, format_context &ctx) {
const char *&s = ctx.ptr(); const char *&s = ctx.ptr();
if (*s == ':') if (*s == ':')
++s; ++s;
......
...@@ -16,7 +16,7 @@ using fmt::PrintfArgFormatter; ...@@ -16,7 +16,7 @@ using fmt::PrintfArgFormatter;
// rounded to 0. // rounded to 0.
class CustomArgFormatter : public fmt::ArgFormatter<char> { class CustomArgFormatter : public fmt::ArgFormatter<char> {
public: public:
CustomArgFormatter(fmt::Writer &w, fmt::basic_format_context<char> &ctx, CustomArgFormatter(fmt::writer &w, fmt::basic_format_context<char> &ctx,
fmt::FormatSpec &s) fmt::FormatSpec &s)
: fmt::ArgFormatter<char>(w, ctx, s) {} : fmt::ArgFormatter<char>(w, ctx, s) {}
...@@ -33,7 +33,7 @@ class CustomArgFormatter : public fmt::ArgFormatter<char> { ...@@ -33,7 +33,7 @@ class CustomArgFormatter : public fmt::ArgFormatter<char> {
// rounded to 0. // rounded to 0.
class CustomPrintfArgFormatter : public PrintfArgFormatter<char> { class CustomPrintfArgFormatter : public PrintfArgFormatter<char> {
public: public:
CustomPrintfArgFormatter(fmt::BasicWriter<char> &w, fmt::FormatSpec &spec) CustomPrintfArgFormatter(fmt::basic_writer<char> &w, fmt::FormatSpec &spec)
: PrintfArgFormatter<char>(w, spec) {} : PrintfArgFormatter<char>(w, spec) {}
using PrintfArgFormatter<char>::operator(); using PrintfArgFormatter<char>::operator();
......
...@@ -70,7 +70,7 @@ lconv *localeconv() { ...@@ -70,7 +70,7 @@ lconv *localeconv() {
using std::size_t; using std::size_t;
using fmt::BasicWriter; using fmt::basic_writer;
using fmt::format; using fmt::format;
using fmt::format_error; using fmt::format_error;
using fmt::StringRef; using fmt::StringRef;
...@@ -165,11 +165,11 @@ TEST(CStringRefTest, Ctor) { ...@@ -165,11 +165,11 @@ TEST(CStringRefTest, Ctor) {
#if FMT_USE_TYPE_TRAITS #if FMT_USE_TYPE_TRAITS
TEST(WriterTest, NotCopyConstructible) { TEST(WriterTest, NotCopyConstructible) {
EXPECT_FALSE(std::is_copy_constructible<BasicWriter<char> >::value); EXPECT_FALSE(std::is_copy_constructible<basic_writer<char> >::value);
} }
TEST(WriterTest, NotCopyAssignable) { TEST(WriterTest, NotCopyAssignable) {
EXPECT_FALSE(std::is_copy_assignable<BasicWriter<char> >::value); EXPECT_FALSE(std::is_copy_assignable<basic_writer<char> >::value);
} }
#endif #endif
...@@ -399,7 +399,7 @@ TEST(WriterTest, hexu) { ...@@ -399,7 +399,7 @@ TEST(WriterTest, hexu) {
} }
template <typename Char> template <typename Char>
BasicWriter<Char> &operator<<(BasicWriter<Char> &f, const Date &d) { basic_writer<Char> &operator<<(basic_writer<Char> &f, const Date &d) {
return f << d.year() << '-' << d.month() << '-' << d.day(); return f << d.year() << '-' << d.month() << '-' << d.day();
} }
...@@ -410,8 +410,8 @@ public: ...@@ -410,8 +410,8 @@ public:
ISO8601DateFormatter(const Date &d) : date_(&d) {} ISO8601DateFormatter(const Date &d) : date_(&d) {}
template <typename Char> template <typename Char>
friend BasicWriter<Char> &operator<<( friend basic_writer<Char> &operator<<(
BasicWriter<Char> &w, const ISO8601DateFormatter &d) { basic_writer<Char> &w, const ISO8601DateFormatter &d) {
return w << pad(d.date_->year(), 4, '0') << '-' return w << pad(d.date_->year(), 4, '0') << '-'
<< pad(d.date_->month(), 2, '0') << '-' << pad(d.date_->day(), 2, '0'); << pad(d.date_->month(), 2, '0') << '-' << pad(d.date_->day(), 2, '0');
} }
...@@ -1355,7 +1355,7 @@ TEST(FormatterTest, FormatCStringRef) { ...@@ -1355,7 +1355,7 @@ TEST(FormatterTest, FormatCStringRef) {
EXPECT_EQ("test", format("{0}", CStringRef("test"))); EXPECT_EQ("test", format("{0}", CStringRef("test")));
} }
void format_value(fmt::Writer &w, const Date &d, fmt::format_context &) { void format_value(fmt::writer &w, const Date &d, fmt::format_context &) {
w << d.year() << '-' << d.month() << '-' << d.day(); w << d.year() << '-' << d.month() << '-' << d.day();
} }
...@@ -1368,7 +1368,7 @@ TEST(FormatterTest, FormatCustom) { ...@@ -1368,7 +1368,7 @@ TEST(FormatterTest, FormatCustom) {
class Answer {}; class Answer {};
template <typename Char> template <typename Char>
void format_value(BasicWriter<Char> &w, Answer, fmt::format_context &) { void format_value(basic_writer<Char> &w, Answer, fmt::format_context &) {
w << "42"; w << "42";
} }
...@@ -1627,7 +1627,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase<char> { ...@@ -1627,7 +1627,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase<char> {
public: public:
typedef fmt::internal::ArgFormatterBase<char> Base; typedef fmt::internal::ArgFormatterBase<char> Base;
MockArgFormatter(fmt::Writer &w, fmt::format_context &ctx, MockArgFormatter(fmt::writer &w, fmt::format_context &ctx,
fmt::FormatSpec &s) fmt::FormatSpec &s)
: fmt::internal::ArgFormatterBase<char>(w, s) { : fmt::internal::ArgFormatterBase<char>(w, s) {
EXPECT_CALL(*this, call(42)); EXPECT_CALL(*this, call(42));
......
...@@ -59,7 +59,7 @@ TEST(OStreamTest, Enum) { ...@@ -59,7 +59,7 @@ TEST(OStreamTest, Enum) {
} }
struct TestArgFormatter : fmt::ArgFormatter<char> { struct TestArgFormatter : fmt::ArgFormatter<char> {
TestArgFormatter(fmt::Writer &w, fmt::format_context &ctx, TestArgFormatter(fmt::writer &w, fmt::format_context &ctx,
fmt::FormatSpec &s) fmt::FormatSpec &s)
: fmt::ArgFormatter<char>(w, ctx, s) {} : fmt::ArgFormatter<char>(w, ctx, s) {}
}; };
...@@ -134,7 +134,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { ...@@ -134,7 +134,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
if (max_size <= fmt::internal::to_unsigned(max_streamsize)) if (max_size <= fmt::internal::to_unsigned(max_streamsize))
return; return;
class TestWriter : public fmt::BasicWriter<char> { class TestWriter : public fmt::basic_writer<char> {
private: private:
struct TestBuffer : fmt::Buffer<char> { struct TestBuffer : fmt::Buffer<char> {
explicit TestBuffer(std::size_t size) { size_ = size; } explicit TestBuffer(std::size_t size) { size_ = size; }
...@@ -142,7 +142,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { ...@@ -142,7 +142,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
} buffer_; } buffer_;
public: public:
explicit TestWriter(std::size_t size) explicit TestWriter(std::size_t size)
: fmt::BasicWriter<char>(buffer_), buffer_(size) {} : fmt::basic_writer<char>(buffer_), buffer_(size) {}
} w(max_size); } w(max_size);
struct MockStreamBuf : std::streambuf { struct MockStreamBuf : std::streambuf {
......
...@@ -68,7 +68,7 @@ namespace { ...@@ -68,7 +68,7 @@ namespace {
struct Test {}; struct Test {};
template <typename Char> template <typename Char>
void format_value(fmt::BasicWriter<Char> &w, Test, void format_value(fmt::basic_writer<Char> &w, Test,
fmt::basic_format_context<Char> &) { fmt::basic_format_context<Char> &) {
w << "test"; w << "test";
} }
...@@ -417,7 +417,7 @@ struct CustomContext { ...@@ -417,7 +417,7 @@ struct CustomContext {
bool called; bool called;
}; };
void format_value(fmt::Writer &, const Test &, CustomContext &ctx) { void format_value(fmt::writer &, const Test &, CustomContext &ctx) {
ctx.called = true; ctx.called = true;
} }
...@@ -690,7 +690,7 @@ TEST(UtilTest, UTF16ToUTF8Convert) { ...@@ -690,7 +690,7 @@ TEST(UtilTest, UTF16ToUTF8Convert) {
#endif // _WIN32 #endif // _WIN32
typedef void (*FormatErrorMessage)( typedef void (*FormatErrorMessage)(
fmt::Writer &out, int error_code, StringRef message); fmt::writer &out, int error_code, StringRef message);
template <typename Error> template <typename Error>
void check_throw_error(int error_code, FormatErrorMessage format) { void check_throw_error(int error_code, FormatErrorMessage format) {
......
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