Revise docs

This commit is contained in:
vitaut 2016-04-21 06:50:54 -07:00
parent bfdca8b576
commit 125bb0f19a

View File

@ -1385,7 +1385,9 @@ class ArgList {
/** /**
\rst \rst
An argument visitor. An argument visitor based on the `curiously recurring template pattern
<http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern>`_.
To use `~fmt::ArgVisitor` define a subclass that implements some or all of the To use `~fmt::ArgVisitor` define a subclass that implements some or all of the
visit methods with the same signatures as the methods in `~fmt::ArgVisitor`, visit methods with the same signatures as the methods in `~fmt::ArgVisitor`,
for example, `visit_int(int)`. for example, `visit_int(int)`.
@ -1403,9 +1405,6 @@ class ArgList {
void visit_int(int value) { fmt::print("{}", value); } void visit_int(int value) { fmt::print("{}", value); }
void visit_double(double value) { fmt::print("{}", value ); } void visit_double(double value) { fmt::print("{}", value ); }
}; };
`~fmt::ArgVisitor` uses the `curiously recurring template pattern
<http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern>`_.
\endrst \endrst
*/ */
template <typename Impl, typename Result> template <typename Impl, typename Result>
@ -1918,7 +1917,9 @@ class PrintfFormatter : private FormatterBase {
/** /**
\rst \rst
An argument formatter. An argument formatter based on the `curiously recurring template pattern
<http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern>`_.
To use `~fmt::BasicArgFormatter` define a subclass that implements some or To use `~fmt::BasicArgFormatter` define a subclass that implements some or
all of the visit methods with the same signatures as the methods in all of the visit methods with the same signatures as the methods in
`~fmt::ArgVisitor`, for example, `visit_int(int)`. `~fmt::ArgVisitor`, for example, `visit_int(int)`.
@ -1942,8 +1943,7 @@ class PrintfFormatter : private FormatterBase {
: fmt::BasicArgFormatter<CustomArgFormatter, char>(f, s, fmt) {} : fmt::BasicArgFormatter<CustomArgFormatter, char>(f, s, fmt) {}
void visit_int(int value) { void visit_int(int value) {
fmt::FormatSpec &spec = this->spec(); if (spec().type() == 'x')
if (spec.type() == 'x')
visit_uint(value); // convert to unsigned and format visit_uint(value); // convert to unsigned and format
else else
fmt::BasicArgFormatter<CustomArgFormatter, char>::visit_int(value); fmt::BasicArgFormatter<CustomArgFormatter, char>::visit_int(value);
@ -1952,7 +1952,7 @@ class PrintfFormatter : private FormatterBase {
std::string custom_format(const char *format_str, fmt::ArgList args) { std::string custom_format(const char *format_str, fmt::ArgList args) {
fmt::MemoryWriter writer; fmt::MemoryWriter writer;
// Pass custom argument formatter to BasicFormatter. // Pass custom argument formatter as a template arg to BasicFormatter.
fmt::BasicFormatter<char, CustomArgFormatter> formatter(args, writer); fmt::BasicFormatter<char, CustomArgFormatter> formatter(args, writer);
formatter.format(format_str); formatter.format(format_str);
return writer.str(); return writer.str();
@ -1960,9 +1960,6 @@ class PrintfFormatter : private FormatterBase {
FMT_VARIADIC(std::string, custom_format, const char *) FMT_VARIADIC(std::string, custom_format, const char *)
std::string s = custom_format("{:x}", -42); // s == "ffffffd6" std::string s = custom_format("{:x}", -42); // s == "ffffffd6"
`~fmt::BasicArgFormatter` uses the `curiously recurring template pattern
<http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern>`_.
\endrst \endrst
*/ */
template <typename Impl, typename Char> template <typename Impl, typename Char>
@ -1975,15 +1972,15 @@ class BasicArgFormatter : public internal::ArgFormatterBase<Impl, Char> {
/** /**
\rst \rst
Constructs an argument formatter object. Constructs an argument formatter object.
*f* is a reference to the main formatter object, *s* contains format *formatter* is a reference to the main formatter object, *spec* contains
specifier information for standard argument types, and *fmt* points to format specifier information for standard argument types, and *fmt* points
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> &f, BasicArgFormatter(BasicFormatter<Char, Impl> &formatter,
FormatSpec &s, const Char *fmt) FormatSpec &spec, const Char *fmt)
: internal::ArgFormatterBase<Impl, Char>(f.writer(), s), : internal::ArgFormatterBase<Impl, Char>(formatter.writer(), spec),
formatter_(f), format_(fmt) {} formatter_(formatter), format_(fmt) {}
/** Formats argument of a custom (user-defined) type. */ /** Formats argument of a custom (user-defined) type. */
void visit_custom(internal::Arg::CustomValue c) { void visit_custom(internal::Arg::CustomValue c) {
@ -1996,8 +1993,9 @@ 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> &f, FormatSpec &s, const Char *fmt) ArgFormatter(BasicFormatter<Char> &formatter,
: BasicArgFormatter<ArgFormatter<Char>, Char>(f, s, fmt) {} FormatSpec &spec, const Char *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. */