Use one namespace (fmt) instead of two (format and fmt).

This commit is contained in:
Victor Zverovich 2013-01-21 11:42:25 -08:00
parent 1b3ac76019
commit a1dccea9ba
3 changed files with 21 additions and 24 deletions

View File

@ -54,9 +54,9 @@ copyright = u'1990-2012, Python Software Foundation'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.4' version = '0.5'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.4' release = '0.5'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -5,30 +5,30 @@
String Formatting API String Formatting API
--------------------- ---------------------
.. doxygenfunction:: format::Format(StringRef) .. doxygenfunction:: fmt::Format(StringRef)
.. doxygenclass:: format::Formatter .. doxygenclass:: fmt::Formatter
:members: :members:
.. doxygenclass:: format::TempFormatter .. doxygenclass:: fmt::TempFormatter
:members: :members:
.. doxygenclass:: format::NoAction .. doxygenclass:: fmt::NoAction
:members: :members:
.. doxygenclass:: format::StringRef .. doxygenclass:: fmt::StringRef
:members: :members:
.. doxygenfunction:: format::str .. doxygenfunction:: fmt::str
.. doxygenfunction:: format::c_str .. doxygenfunction:: fmt::c_str
.. _formatstrings: .. _formatstrings:
Format String Syntax Format String Syntax
-------------------- --------------------
The :cpp:func:`format::Format()` function and the :cpp:class:`format::Formatter` The :cpp:func:`fmt::Format()` function and the :cpp:class:`fmt::Formatter`
class share the same syntax for format strings. class share the same syntax for format strings.
Format strings contain "replacement fields" surrounded by curly braces ``{}``. Format strings contain "replacement fields" surrounded by curly braces ``{}``.

View File

@ -38,7 +38,7 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
namespace format { namespace fmt {
namespace internal { namespace internal {
@ -439,8 +439,7 @@ BasicFormatter &BasicFormatter::operator<<(const IntFormatter<T, Spec> &f) {
switch (f.type()) { switch (f.type()) {
case 0: case 'd': { case 0: case 'd': {
unsigned num_digits = BasicFormatter::CountDigits(abs_value); unsigned num_digits = BasicFormatter::CountDigits(abs_value);
char *p = PrepareFilledBuffer(size + num_digits, f, sign) char *p = PrepareFilledBuffer(size + num_digits, f, sign) - num_digits + 1;
- num_digits + 1;
BasicFormatter::FormatDecimal(p, abs_value, num_digits); BasicFormatter::FormatDecimal(p, abs_value, num_digits);
break; break;
} }
@ -497,7 +496,7 @@ void Format(BasicFormatter &f, const FormatSpec &spec, const T &value) {
/** /**
\rst \rst
The :cpp:class:`format::Formatter` class provides string formatting The :cpp:class:`fmt::Formatter` class provides string formatting
functionality similar to Python's `str.format functionality similar to Python's `str.format
<http://docs.python.org/3/library/stdtypes.html#str.format>`__. <http://docs.python.org/3/library/stdtypes.html#str.format>`__.
The output is stored in a memory buffer that grows dynamically. The output is stored in a memory buffer that grows dynamically.
@ -677,8 +676,8 @@ const char *c_str(internal::FormatterProxy p);
namespace internal { namespace internal {
using format::str; using fmt::str;
using format::c_str; using fmt::c_str;
class FormatterProxy { class FormatterProxy {
private: private:
@ -701,8 +700,8 @@ class ArgInserter {
private: private:
mutable Formatter *formatter_; mutable Formatter *formatter_;
friend class format::Formatter; friend class fmt::Formatter;
friend class format::StringRef; friend class fmt::StringRef;
// Do not implement. // Do not implement.
void operator=(const ArgInserter& other); void operator=(const ArgInserter& other);
@ -821,8 +820,8 @@ class TempFormatter : public internal::ArgInserter {
\rst \rst
Constructs a temporary formatter with a format string and an action. Constructs a temporary formatter with a format string and an action.
The action should be an unary function object that takes a const The action should be an unary function object that takes a const
reference to :cpp:class:`format::Formatter` as an argument. reference to :cpp:class:`fmt::Formatter` as an argument.
See :cpp:class:`format::NoAction` and :cpp:class:`format::Write` for See :cpp:class:`fmt::NoAction` and :cpp:class:`fmt::Write` for
examples of action classes. examples of action classes.
\endrst \endrst
*/ */
@ -864,8 +863,8 @@ class TempFormatter : public internal::ArgInserter {
literal text and replacement fields surrounded by braces ``{}``. literal text and replacement fields surrounded by braces ``{}``.
The formatter object replaces the fields with formatted arguments The formatter object replaces the fields with formatted arguments
and stores the output in a memory buffer. The content of the buffer can and stores the output in a memory buffer. The content of the buffer can
be converted to ``std::string`` with :cpp:func:`format::str()` or be converted to ``std::string`` with :cpp:func:`fmt::str()` or
accessed as a C string with :cpp:func:`format::c_str()`. accessed as a C string with :cpp:func:`fmt::c_str()`.
**Example**:: **Example**::
@ -893,6 +892,4 @@ inline TempFormatter<Write> Print(StringRef format) {
} }
} }
namespace fmt = format;
#endif // FORMAT_H_ #endif // FORMAT_H_