mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-27 15:35:18 +00:00
Document the API.
This commit is contained in:
parent
00830b99b3
commit
8e158d74cd
@ -10,6 +10,9 @@ String Formatting
|
|||||||
.. doxygenclass:: format::Formatter
|
.. doxygenclass:: format::Formatter
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
.. doxygenclass:: format::StringRef
|
||||||
|
:members:
|
||||||
|
|
||||||
.. ifconfig:: False
|
.. ifconfig:: False
|
||||||
|
|
||||||
.. class:: Formatter
|
.. class:: Formatter
|
||||||
|
55
format.h
55
format.h
@ -117,14 +117,15 @@ void Array<T, SIZE>::append(const T *begin, const T *end) {
|
|||||||
class ArgInserter;
|
class ArgInserter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A reference to a string. It can be constructed from a C string,
|
/**
|
||||||
// std::string or as a result of a formatting operation. It is most useful
|
\rst
|
||||||
// as a parameter type to allow passing different types of strings in a
|
A string reference. It can be constructed from a C string, ``std::string``
|
||||||
// function, for example:
|
or as a result of a formatting operation. It is most useful as a parameter
|
||||||
// void SetName(StringRef s) {
|
type to allow passing different types of strings in a function, for example::
|
||||||
// std::string name = s;
|
|
||||||
// ...
|
TempFormatter<> Format(StringRef format);
|
||||||
// }
|
\endrst
|
||||||
|
*/
|
||||||
class StringRef {
|
class StringRef {
|
||||||
private:
|
private:
|
||||||
const char *data_;
|
const char *data_;
|
||||||
@ -354,18 +355,50 @@ class Formatter : public BasicFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
\rst
|
||||||
|
Constructs a formatter with an empty output buffer.
|
||||||
|
\endrst
|
||||||
|
*/
|
||||||
Formatter() : format_(0) { buffer_[0] = 0; }
|
Formatter() : format_(0) { buffer_[0] = 0; }
|
||||||
|
|
||||||
/// Formats a string appending the output to the internal buffer.
|
/**
|
||||||
/// Arguments are accepted through the returned ArgInserter object
|
\rst
|
||||||
/// using inserter operator<<.
|
Formats a string appending the output to the internal buffer.
|
||||||
|
Arguments are accepted through the returned ``ArgInserter`` object
|
||||||
|
using inserter operator ``<<``.
|
||||||
|
\endrst
|
||||||
|
*/
|
||||||
internal::ArgInserter operator()(StringRef format);
|
internal::ArgInserter operator()(StringRef format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
\rst
|
||||||
|
Returns the number of characters written to the output buffer.
|
||||||
|
\endrst
|
||||||
|
*/
|
||||||
std::size_t size() const { return buffer_.size(); }
|
std::size_t size() const { return buffer_.size(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
\rst
|
||||||
|
Returns a pointer to the output buffer content. No terminating null
|
||||||
|
character is appended.
|
||||||
|
\endrst
|
||||||
|
*/
|
||||||
const char *data() const { return &buffer_[0]; }
|
const char *data() const { return &buffer_[0]; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
\rst
|
||||||
|
Returns a pointer to the output buffer content with terminating null
|
||||||
|
character appended.
|
||||||
|
\endrst
|
||||||
|
*/
|
||||||
const char *c_str() const { return &buffer_[0]; }
|
const char *c_str() const { return &buffer_[0]; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
\rst
|
||||||
|
Returns the content of the output buffer as an ``std::string``.
|
||||||
|
\endrst
|
||||||
|
*/
|
||||||
std::string str() const { return std::string(&buffer_[0], buffer_.size()); }
|
std::string str() const { return std::string(&buffer_[0], buffer_.size()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user