mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
BasicFormatter -> basic_formatter
This commit is contained in:
@ -362,9 +362,10 @@ FMT_FUNC void internal::format_windows_error(
|
|||||||
buffer.resize(INLINE_BUFFER_SIZE);
|
buffer.resize(INLINE_BUFFER_SIZE);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
wchar_t *system_message = &buffer[0];
|
wchar_t *system_message = &buffer[0];
|
||||||
int result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
int result = FormatMessageW(
|
||||||
0, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
system_message, static_cast<uint32_t>(buffer.size()), 0);
|
0, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
system_message, static_cast<uint32_t>(buffer.size()), 0);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
UTF16ToUTF8 utf8_message;
|
UTF16ToUTF8 utf8_message;
|
||||||
if (utf8_message.convert(system_message) == ERROR_SUCCESS) {
|
if (utf8_message.convert(system_message) == ERROR_SUCCESS) {
|
||||||
|
59
fmt/format.h
59
fmt/format.h
@ -379,7 +379,7 @@ class BasicPrintfArgFormatter;
|
|||||||
|
|
||||||
template <typename CharType,
|
template <typename CharType,
|
||||||
typename ArgFormatter = fmt::ArgFormatter<CharType> >
|
typename ArgFormatter = fmt::ArgFormatter<CharType> >
|
||||||
class BasicFormatter;
|
class basic_formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
@ -1405,7 +1405,7 @@ struct NamedArg : Arg {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
NamedArg(BasicStringRef<Char> argname, const T &value)
|
NamedArg(BasicStringRef<Char> argname, const T &value)
|
||||||
: Arg(MakeArg< BasicFormatter<Char> >(value)), name(argname) {}
|
: Arg(MakeArg< basic_formatter<Char> >(value)), name(argname) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RuntimeError : public std::runtime_error {
|
class RuntimeError : public std::runtime_error {
|
||||||
@ -1526,8 +1526,8 @@ class basic_format_args {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef basic_format_args<BasicFormatter<char>> format_args;
|
typedef basic_format_args<basic_formatter<char>> format_args;
|
||||||
typedef basic_format_args<BasicFormatter<wchar_t>> wformat_args;
|
typedef basic_format_args<basic_formatter<wchar_t>> wformat_args;
|
||||||
|
|
||||||
#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call
|
#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call
|
||||||
|
|
||||||
@ -2160,7 +2160,7 @@ private:
|
|||||||
template <typename Impl, typename Char>
|
template <typename Impl, typename Char>
|
||||||
class BasicArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
|
class BasicArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
|
||||||
private:
|
private:
|
||||||
BasicFormatter<Char, Impl> &formatter_;
|
basic_formatter<Char, Impl> &formatter_;
|
||||||
const Char *format_;
|
const Char *format_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -2172,7 +2172,7 @@ class BasicArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
|
|||||||
to the part of the format string being parsed for custom argument types.
|
to the part of the format string being parsed for custom argument types.
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
BasicArgFormatter(BasicFormatter<Char, Impl> &formatter,
|
BasicArgFormatter(basic_formatter<Char, Impl> &formatter,
|
||||||
FormatSpec &spec, const Char *fmt)
|
FormatSpec &spec, const Char *fmt)
|
||||||
: internal::ArgFormatterBase<Impl, Char>(formatter.writer(), spec),
|
: internal::ArgFormatterBase<Impl, Char>(formatter.writer(), spec),
|
||||||
formatter_(formatter), format_(fmt) {}
|
formatter_(formatter), format_(fmt) {}
|
||||||
@ -2188,15 +2188,15 @@ template <typename Char>
|
|||||||
class ArgFormatter : public BasicArgFormatter<ArgFormatter<Char>, Char> {
|
class ArgFormatter : public BasicArgFormatter<ArgFormatter<Char>, Char> {
|
||||||
public:
|
public:
|
||||||
/** Constructs an argument formatter object. */
|
/** Constructs an argument formatter object. */
|
||||||
ArgFormatter(BasicFormatter<Char> &formatter,
|
ArgFormatter(basic_formatter<Char> &formatter,
|
||||||
FormatSpec &spec, const Char *fmt)
|
FormatSpec &spec, const Char *fmt)
|
||||||
: BasicArgFormatter<ArgFormatter<Char>, Char>(formatter, spec, fmt) {}
|
: BasicArgFormatter<ArgFormatter<Char>, Char>(formatter, spec, fmt) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This template formats data and writes the output to a writer. */
|
/** This template formats data and writes the output to a writer. */
|
||||||
template <typename CharType, typename ArgFormatter>
|
template <typename CharType, typename ArgFormatter>
|
||||||
class BasicFormatter :
|
class basic_formatter :
|
||||||
private internal::FormatterBase<BasicFormatter<CharType, ArgFormatter>> {
|
private internal::FormatterBase<basic_formatter<CharType, ArgFormatter>> {
|
||||||
public:
|
public:
|
||||||
/** The character type for the output. */
|
/** The character type for the output. */
|
||||||
typedef CharType Char;
|
typedef CharType Char;
|
||||||
@ -2205,9 +2205,9 @@ class BasicFormatter :
|
|||||||
BasicWriter<Char> &writer_;
|
BasicWriter<Char> &writer_;
|
||||||
internal::ArgMap<Char> map_;
|
internal::ArgMap<Char> map_;
|
||||||
|
|
||||||
FMT_DISALLOW_COPY_AND_ASSIGN(BasicFormatter);
|
FMT_DISALLOW_COPY_AND_ASSIGN(basic_formatter);
|
||||||
|
|
||||||
typedef internal::FormatterBase<BasicFormatter> Base;
|
typedef internal::FormatterBase<basic_formatter> Base;
|
||||||
using Base::get_arg;
|
using Base::get_arg;
|
||||||
|
|
||||||
// Checks if manual indexing is used and returns the argument with
|
// Checks if manual indexing is used and returns the argument with
|
||||||
@ -2223,12 +2223,12 @@ class BasicFormatter :
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
Constructs a ``BasicFormatter`` object. References to the arguments and
|
Constructs a ``basic_formatter`` object. References to the arguments and
|
||||||
the writer are stored in the formatter object so make sure they have
|
the writer are stored in the formatter object so make sure they have
|
||||||
appropriate lifetimes.
|
appropriate lifetimes.
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
BasicFormatter(basic_format_args<BasicFormatter> args, BasicWriter<Char> &w)
|
basic_formatter(basic_format_args<basic_formatter> args, BasicWriter<Char> &w)
|
||||||
: Base(args), writer_(w) {}
|
: Base(args), writer_(w) {}
|
||||||
|
|
||||||
/** Returns a reference to the writer associated with this formatter. */
|
/** Returns a reference to the writer associated with this formatter. */
|
||||||
@ -2275,7 +2275,7 @@ class SystemError : public internal::RuntimeError {
|
|||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
SystemError(int error_code, CStringRef message, const Args & ... args) {
|
SystemError(int error_code, CStringRef message, const Args & ... args) {
|
||||||
init(error_code, message, make_format_args<BasicFormatter<char>>(args...));
|
init(error_code, message, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
~SystemError() throw();
|
~SystemError() throw();
|
||||||
@ -2470,8 +2470,8 @@ class BasicWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vwrite(BasicCStringRef<Char> format,
|
void vwrite(BasicCStringRef<Char> format,
|
||||||
basic_format_args<BasicFormatter<Char>> args) {
|
basic_format_args<basic_formatter<Char>> args) {
|
||||||
BasicFormatter<Char>(args, *this).format(format);
|
basic_formatter<Char>(args, *this).format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2501,7 +2501,7 @@ class BasicWriter {
|
|||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void write(BasicCStringRef<Char> format, const Args & ... args) {
|
void write(BasicCStringRef<Char> format, const Args & ... args) {
|
||||||
vwrite(format, make_format_args<fmt::BasicFormatter<Char>>(args...));
|
vwrite(format, make_format_args<fmt::basic_formatter<Char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicWriter &operator<<(int value) {
|
BasicWriter &operator<<(int value) {
|
||||||
@ -3129,7 +3129,7 @@ class WindowsError : public SystemError {
|
|||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
WindowsError(int error_code, CStringRef message, const Args & ... args) {
|
WindowsError(int error_code, CStringRef message, const Args & ... args) {
|
||||||
init(error_code, message, make_format_args<BasicFormatter<char>>(args...));
|
init(error_code, message, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3154,7 +3154,7 @@ template <typename... Args>
|
|||||||
inline void print_colored(Color c, CStringRef format_str,
|
inline void print_colored(Color c, CStringRef format_str,
|
||||||
const Args & ... args) {
|
const Args & ... args) {
|
||||||
vprint_colored(c, format_str,
|
vprint_colored(c, format_str,
|
||||||
make_format_args<BasicFormatter<char>>(args...));
|
make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string vformat(CStringRef format_str, format_args args) {
|
inline std::string vformat(CStringRef format_str, format_args args) {
|
||||||
@ -3174,7 +3174,7 @@ inline std::string vformat(CStringRef format_str, format_args args) {
|
|||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline std::string format(CStringRef format_str, const Args & ... args) {
|
inline std::string format(CStringRef format_str, const Args & ... args) {
|
||||||
return vformat(format_str, make_format_args<BasicFormatter<char>>(args...));
|
return vformat(format_str, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::wstring vformat(WCStringRef format_str, wformat_args args) {
|
inline std::wstring vformat(WCStringRef format_str, wformat_args args) {
|
||||||
@ -3185,7 +3185,7 @@ inline std::wstring vformat(WCStringRef format_str, wformat_args args) {
|
|||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline std::wstring format(WCStringRef format_str, const Args & ... args) {
|
inline std::wstring format(WCStringRef format_str, const Args & ... args) {
|
||||||
auto vargs = make_format_args<BasicFormatter<wchar_t>>(args...);
|
auto vargs = make_format_args<basic_formatter<wchar_t>>(args...);
|
||||||
return vformat(format_str, vargs);
|
return vformat(format_str, vargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3202,7 +3202,7 @@ FMT_API void vprint(std::FILE *f, CStringRef format_str, format_args args);
|
|||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline void print(std::FILE *f, CStringRef format_str, const Args & ... args) {
|
inline void print(std::FILE *f, CStringRef format_str, const Args & ... args) {
|
||||||
vprint(f, format_str, make_format_args<BasicFormatter<char>>(args...));
|
vprint(f, format_str, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_API void vprint(CStringRef format_str, format_args args);
|
FMT_API void vprint(CStringRef format_str, format_args args);
|
||||||
@ -3218,7 +3218,7 @@ FMT_API void vprint(CStringRef format_str, format_args args);
|
|||||||
*/
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline void print(CStringRef format_str, const Args & ... args) {
|
inline void print(CStringRef format_str, const Args & ... args) {
|
||||||
vprint(format_str, make_format_args<BasicFormatter<char>>(args...));
|
vprint(format_str, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3412,7 +3412,7 @@ void check_sign(const Char *&s, const Arg &arg) {
|
|||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <typename Char, typename AF>
|
template <typename Char, typename AF>
|
||||||
inline internal::Arg BasicFormatter<Char, AF>::get_arg(
|
inline internal::Arg basic_formatter<Char, AF>::get_arg(
|
||||||
BasicStringRef<Char> arg_name, const char *&error) {
|
BasicStringRef<Char> arg_name, const char *&error) {
|
||||||
if (this->check_no_auto_index(error)) {
|
if (this->check_no_auto_index(error)) {
|
||||||
map_.init(this->args());
|
map_.init(this->args());
|
||||||
@ -3425,10 +3425,11 @@ inline internal::Arg BasicFormatter<Char, AF>::get_arg(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename AF>
|
template <typename Char, typename AF>
|
||||||
inline internal::Arg BasicFormatter<Char, AF>::parse_arg_index(const Char *&s) {
|
inline internal::Arg basic_formatter<Char, AF>::parse_arg_index(
|
||||||
|
const Char *&s) {
|
||||||
const char *error = 0;
|
const char *error = 0;
|
||||||
internal::Arg arg = *s < '0' || *s > '9' ?
|
internal::Arg arg = *s < '0' || *s > '9' ?
|
||||||
this->next_arg(error) : get_arg(internal::parse_nonnegative_int(s), error);
|
this->next_arg(error) : get_arg(internal::parse_nonnegative_int(s), error);
|
||||||
if (error) {
|
if (error) {
|
||||||
FMT_THROW(format_error(
|
FMT_THROW(format_error(
|
||||||
*s != '}' && *s != ':' ? "invalid format string" : error));
|
*s != '}' && *s != ':' ? "invalid format string" : error));
|
||||||
@ -3437,7 +3438,7 @@ inline internal::Arg BasicFormatter<Char, AF>::parse_arg_index(const Char *&s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename AF>
|
template <typename Char, typename AF>
|
||||||
inline internal::Arg BasicFormatter<Char, AF>::parse_arg_name(const Char *&s) {
|
inline internal::Arg basic_formatter<Char, AF>::parse_arg_name(const Char *&s) {
|
||||||
assert(internal::is_name_start(*s));
|
assert(internal::is_name_start(*s));
|
||||||
const Char *start = s;
|
const Char *start = s;
|
||||||
Char c;
|
Char c;
|
||||||
@ -3452,7 +3453,7 @@ inline internal::Arg BasicFormatter<Char, AF>::parse_arg_name(const Char *&s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename ArgFormatter>
|
template <typename Char, typename ArgFormatter>
|
||||||
const Char *BasicFormatter<Char, ArgFormatter>::format(
|
const Char *basic_formatter<Char, ArgFormatter>::format(
|
||||||
const Char *&format_str, const internal::Arg &arg) {
|
const Char *&format_str, const internal::Arg &arg) {
|
||||||
using internal::Arg;
|
using internal::Arg;
|
||||||
const Char *s = format_str;
|
const Char *s = format_str;
|
||||||
@ -3622,7 +3623,7 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename AF>
|
template <typename Char, typename AF>
|
||||||
void BasicFormatter<Char, AF>::format(BasicCStringRef<Char> format_str) {
|
void basic_formatter<Char, AF>::format(BasicCStringRef<Char> format_str) {
|
||||||
const Char *s = format_str.c_str();
|
const Char *s = format_str.c_str();
|
||||||
const Char *start = s;
|
const Char *start = s;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
|
@ -83,11 +83,11 @@ BasicStringRef<Char> format_value(
|
|||||||
|
|
||||||
// Formats a value.
|
// Formats a value.
|
||||||
template <typename Char, typename ArgFormatter, typename T>
|
template <typename Char, typename ArgFormatter, typename T>
|
||||||
void format_value(BasicFormatter<Char, ArgFormatter> &f,
|
void format_value(basic_formatter<Char, ArgFormatter> &f,
|
||||||
const Char *&format_str, const T &value) {
|
const Char *&format_str, const T &value) {
|
||||||
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);
|
||||||
typedef internal::MakeArg< BasicFormatter<Char> > MakeArg;
|
typedef internal::MakeArg< basic_formatter<Char> > MakeArg;
|
||||||
format_str = f.format(format_str, MakeArg(str));
|
format_str = f.format(format_str, MakeArg(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ FMT_API void vprint(std::ostream &os, CStringRef format_str, format_args args);
|
|||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline void print(std::ostream &os, CStringRef format_str,
|
inline void print(std::ostream &os, CStringRef format_str,
|
||||||
const Args & ... args) {
|
const Args & ... args) {
|
||||||
vprint(os, format_str, make_format_args<BasicFormatter<char>>(args...));
|
vprint(os, format_str, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
} // namespace fmt
|
} // namespace fmt
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public:
|
|||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline void print(CStringRef format_str, const Args & ... args) {
|
inline void print(CStringRef format_str, const Args & ... args) {
|
||||||
vprint(format_str, make_format_args<BasicFormatter<char>>(args...));
|
vprint(format_str, make_format_args<basic_formatter<char>>(args...));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ class BasicPrintfArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
|
|||||||
|
|
||||||
/** Formats an argument of a custom (user-defined) type. */
|
/** Formats an argument of a custom (user-defined) type. */
|
||||||
void visit_custom(internal::Arg::CustomValue c) {
|
void visit_custom(internal::Arg::CustomValue c) {
|
||||||
BasicFormatter<Char> formatter(basic_format_args<BasicFormatter<Char>>(),
|
basic_formatter<Char> formatter(basic_format_args<basic_formatter<Char>>(),
|
||||||
this->writer());
|
this->writer());
|
||||||
const Char format_str[] = {'}', 0};
|
const Char format_str[] = {'}', 0};
|
||||||
const Char *format = format_str;
|
const Char *format = format_str;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace fmt {
|
namespace fmt {
|
||||||
template <typename ArgFormatter>
|
template <typename ArgFormatter>
|
||||||
void format_value(BasicFormatter<char, ArgFormatter> &f,
|
void format_value(basic_formatter<char, ArgFormatter> &f,
|
||||||
const char *&format_str, const std::tm &tm) {
|
const char *&format_str, const std::tm &tm) {
|
||||||
if (*format_str == ':')
|
if (*format_str == ':')
|
||||||
++format_str;
|
++format_str;
|
||||||
|
@ -17,7 +17,7 @@ using fmt::BasicPrintfArgFormatter;
|
|||||||
class CustomArgFormatter
|
class CustomArgFormatter
|
||||||
: public fmt::BasicArgFormatter<CustomArgFormatter, char> {
|
: public fmt::BasicArgFormatter<CustomArgFormatter, char> {
|
||||||
public:
|
public:
|
||||||
CustomArgFormatter(fmt::BasicFormatter<char, CustomArgFormatter> &f,
|
CustomArgFormatter(fmt::basic_formatter<char, CustomArgFormatter> &f,
|
||||||
fmt::FormatSpec &s, const char *fmt)
|
fmt::FormatSpec &s, const char *fmt)
|
||||||
: fmt::BasicArgFormatter<CustomArgFormatter, char>(f, s, fmt) {}
|
: fmt::BasicArgFormatter<CustomArgFormatter, char>(f, s, fmt) {}
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ class CustomPrintfArgFormatter :
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef fmt::BasicFormatter<char, CustomArgFormatter> CustomFormatter;
|
typedef fmt::basic_formatter<char, CustomArgFormatter> CustomFormatter;
|
||||||
|
|
||||||
std::string custom_vformat(const char *format_str,
|
std::string custom_vformat(const char *format_str,
|
||||||
fmt::basic_format_args<CustomFormatter> args) {
|
fmt::basic_format_args<CustomFormatter> args) {
|
||||||
fmt::MemoryWriter writer;
|
fmt::MemoryWriter writer;
|
||||||
// Pass custom argument formatter as a template arg to BasicFormatter.
|
// Pass custom argument formatter as a template arg to basic_formatter.
|
||||||
CustomFormatter formatter(args, writer);
|
CustomFormatter formatter(args, writer);
|
||||||
formatter.format(format_str);
|
formatter.format(format_str);
|
||||||
return writer.str();
|
return writer.str();
|
||||||
|
@ -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::BasicFormatter<char> &f, const char *, const Date &d) {
|
void format_value(fmt::basic_formatter<char> &f, const char *, const Date &d) {
|
||||||
f.writer() << d.year() << '-' << d.month() << '-' << d.day();
|
f.writer() << d.year() << '-' << d.month() << '-' << d.day();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1368,7 +1368,7 @@ TEST(FormatterTest, FormatCustom) {
|
|||||||
class Answer {};
|
class Answer {};
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
void format_value(fmt::BasicFormatter<Char> &f, const Char *, Answer) {
|
void format_value(fmt::basic_formatter<Char> &f, const Char *, Answer) {
|
||||||
f.writer() << "42";
|
f.writer() << "42";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1559,7 +1559,7 @@ std::string vformat_message(int id, const char *format, fmt::format_args args) {
|
|||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
std::string format_message(int id, const char *format, const Args & ... args) {
|
std::string format_message(int id, const char *format, const Args & ... args) {
|
||||||
auto va = fmt::make_format_args<fmt::BasicFormatter<char>>(args...);
|
auto va = fmt::make_format_args<fmt::basic_formatter<char>>(args...);
|
||||||
return vformat_message(id, format, va);
|
return vformat_message(id, format, va);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1624,7 +1624,7 @@ class MockArgFormatter :
|
|||||||
public:
|
public:
|
||||||
typedef fmt::internal::ArgFormatterBase<MockArgFormatter, char> Base;
|
typedef fmt::internal::ArgFormatterBase<MockArgFormatter, char> Base;
|
||||||
|
|
||||||
MockArgFormatter(fmt::BasicFormatter<char, MockArgFormatter> &f,
|
MockArgFormatter(fmt::basic_formatter<char, MockArgFormatter> &f,
|
||||||
fmt::FormatSpec &s, const char *)
|
fmt::FormatSpec &s, const char *)
|
||||||
: fmt::internal::ArgFormatterBase<MockArgFormatter, char>(f.writer(), s) {
|
: fmt::internal::ArgFormatterBase<MockArgFormatter, char>(f.writer(), s) {
|
||||||
EXPECT_CALL(*this, visit_int(42));
|
EXPECT_CALL(*this, visit_int(42));
|
||||||
@ -1633,7 +1633,7 @@ class MockArgFormatter :
|
|||||||
MOCK_METHOD1(visit_int, void (int value));
|
MOCK_METHOD1(visit_int, void (int value));
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef fmt::BasicFormatter<char, MockArgFormatter> CustomFormatter;
|
typedef fmt::basic_formatter<char, MockArgFormatter> CustomFormatter;
|
||||||
|
|
||||||
void custom_vformat(const char *format_str,
|
void custom_vformat(const char *format_str,
|
||||||
fmt::basic_format_args<CustomFormatter> args) {
|
fmt::basic_format_args<CustomFormatter> args) {
|
||||||
|
@ -59,14 +59,14 @@ TEST(OStreamTest, Enum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct TestArgFormatter : fmt::BasicArgFormatter<TestArgFormatter, char> {
|
struct TestArgFormatter : fmt::BasicArgFormatter<TestArgFormatter, char> {
|
||||||
TestArgFormatter(fmt::BasicFormatter<char, TestArgFormatter> &f,
|
TestArgFormatter(fmt::basic_formatter<char, TestArgFormatter> &f,
|
||||||
fmt::FormatSpec &s, const char *fmt)
|
fmt::FormatSpec &s, const char *fmt)
|
||||||
: fmt::BasicArgFormatter<TestArgFormatter, char>(f, s, fmt) {}
|
: fmt::BasicArgFormatter<TestArgFormatter, char>(f, s, fmt) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(OStreamTest, CustomArg) {
|
TEST(OStreamTest, CustomArg) {
|
||||||
fmt::MemoryWriter writer;
|
fmt::MemoryWriter writer;
|
||||||
typedef fmt::BasicFormatter<char, TestArgFormatter> Formatter;
|
typedef fmt::basic_formatter<char, TestArgFormatter> Formatter;
|
||||||
Formatter formatter(fmt::basic_format_args<Formatter>(), writer);
|
Formatter formatter(fmt::basic_format_args<Formatter>(), writer);
|
||||||
fmt::FormatSpec spec;
|
fmt::FormatSpec spec;
|
||||||
TestArgFormatter af(formatter, spec, "}");
|
TestArgFormatter af(formatter, spec, "}");
|
||||||
|
@ -64,13 +64,13 @@ namespace {
|
|||||||
struct Test {};
|
struct Test {};
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
void format_value(fmt::BasicFormatter<Char> &f, const Char *, Test) {
|
void format_value(fmt::basic_formatter<Char> &f, const Char *, Test) {
|
||||||
f.writer() << "test";
|
f.writer() << "test";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename T>
|
template <typename Char, typename T>
|
||||||
Arg make_arg(const T &value) {
|
Arg make_arg(const T &value) {
|
||||||
typedef fmt::internal::MakeValue< fmt::BasicFormatter<Char> > MakeValue;
|
typedef fmt::internal::MakeValue< fmt::basic_formatter<Char> > MakeValue;
|
||||||
Arg arg = MakeValue(value);
|
Arg arg = MakeValue(value);
|
||||||
arg.type = fmt::internal::type<T>();
|
arg.type = fmt::internal::type<T>();
|
||||||
return arg;
|
return arg;
|
||||||
@ -566,7 +566,7 @@ TEST(ArgTest, MakeArg) {
|
|||||||
EXPECT_EQ(fmt::internal::Arg::CUSTOM, arg.type);
|
EXPECT_EQ(fmt::internal::Arg::CUSTOM, arg.type);
|
||||||
EXPECT_EQ(&t, arg.custom.value);
|
EXPECT_EQ(&t, arg.custom.value);
|
||||||
fmt::MemoryWriter w;
|
fmt::MemoryWriter w;
|
||||||
fmt::BasicFormatter<char> formatter(fmt::format_args(), w);
|
fmt::basic_formatter<char> formatter(fmt::format_args(), w);
|
||||||
const char *s = "}";
|
const char *s = "}";
|
||||||
arg.custom.format(&formatter, &t, &s);
|
arg.custom.format(&formatter, &t, &s);
|
||||||
EXPECT_EQ("test", w.str());
|
EXPECT_EQ("test", w.str());
|
||||||
|
Reference in New Issue
Block a user