From a1dccea9ba7a8f0c064cd110eb330ac465f2b062 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 21 Jan 2013 11:42:25 -0800 Subject: [PATCH] Use one namespace (fmt) instead of two (format and fmt). --- doc/conf.py | 4 ++-- doc/index.rst | 16 ++++++++-------- format.h | 25 +++++++++++-------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 6c04afae..e0acf5b5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -54,9 +54,9 @@ copyright = u'1990-2012, Python Software Foundation' # built documents. # # The short X.Y version. -version = '0.4' +version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.4' +release = '0.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/index.rst b/doc/index.rst index ace98460..4a226237 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -5,30 +5,30 @@ String Formatting API --------------------- -.. doxygenfunction:: format::Format(StringRef) +.. doxygenfunction:: fmt::Format(StringRef) -.. doxygenclass:: format::Formatter +.. doxygenclass:: fmt::Formatter :members: -.. doxygenclass:: format::TempFormatter +.. doxygenclass:: fmt::TempFormatter :members: -.. doxygenclass:: format::NoAction +.. doxygenclass:: fmt::NoAction :members: -.. doxygenclass:: format::StringRef +.. doxygenclass:: fmt::StringRef :members: -.. doxygenfunction:: format::str +.. doxygenfunction:: fmt::str -.. doxygenfunction:: format::c_str +.. doxygenfunction:: fmt::c_str .. _formatstrings: 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. Format strings contain "replacement fields" surrounded by curly braces ``{}``. diff --git a/format.h b/format.h index 7294c963..fafc6ed5 100644 --- a/format.h +++ b/format.h @@ -38,7 +38,7 @@ #include #include -namespace format { +namespace fmt { namespace internal { @@ -439,8 +439,7 @@ BasicFormatter &BasicFormatter::operator<<(const IntFormatter &f) { switch (f.type()) { case 0: case 'd': { unsigned num_digits = BasicFormatter::CountDigits(abs_value); - char *p = PrepareFilledBuffer(size + num_digits, f, sign) - - num_digits + 1; + char *p = PrepareFilledBuffer(size + num_digits, f, sign) - num_digits + 1; BasicFormatter::FormatDecimal(p, abs_value, num_digits); break; } @@ -497,7 +496,7 @@ void Format(BasicFormatter &f, const FormatSpec &spec, const T &value) { /** \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 `__. The output is stored in a memory buffer that grows dynamically. @@ -677,8 +676,8 @@ const char *c_str(internal::FormatterProxy p); namespace internal { -using format::str; -using format::c_str; +using fmt::str; +using fmt::c_str; class FormatterProxy { private: @@ -701,8 +700,8 @@ class ArgInserter { private: mutable Formatter *formatter_; - friend class format::Formatter; - friend class format::StringRef; + friend class fmt::Formatter; + friend class fmt::StringRef; // Do not implement. void operator=(const ArgInserter& other); @@ -821,8 +820,8 @@ class TempFormatter : public internal::ArgInserter { \rst Constructs a temporary formatter with a format string and an action. The action should be an unary function object that takes a const - reference to :cpp:class:`format::Formatter` as an argument. - See :cpp:class:`format::NoAction` and :cpp:class:`format::Write` for + reference to :cpp:class:`fmt::Formatter` as an argument. + See :cpp:class:`fmt::NoAction` and :cpp:class:`fmt::Write` for examples of action classes. \endrst */ @@ -864,8 +863,8 @@ class TempFormatter : public internal::ArgInserter { literal text and replacement fields surrounded by braces ``{}``. The formatter object replaces the fields with formatted arguments 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 - accessed as a C string with :cpp:func:`format::c_str()`. + be converted to ``std::string`` with :cpp:func:`fmt::str()` or + accessed as a C string with :cpp:func:`fmt::c_str()`. **Example**:: @@ -893,6 +892,4 @@ inline TempFormatter Print(StringRef format) { } } -namespace fmt = format; - #endif // FORMAT_H_