diff --git a/doc/api.rst b/doc/api.rst index 807b31e4..5270a68d 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -34,8 +34,6 @@ arguments in the resulting string. .. doxygenfunction:: print(std::FILE *, CStringRef, ArgList) -.. doxygenfunction:: print(std::ostream&, CStringRef, ArgList) - .. doxygenclass:: fmt::BasicFormatter :members: @@ -54,6 +52,31 @@ date and time formatting:: The format string syntax is described in the documentation of `strftime `_. +``std::ostream`` support +------------------------ + +The header ``fmt/ostream.h`` provides ``std::ostream`` support including +formatting of user-defined types that have overloaded ``operator<<``:: + + #include "fmt/ostream.h" + + class Date { + int year_, month_, day_; + public: + Date(int year, int month, int day) : year_(year), month_(month), day_(day) {} + + friend std::ostream &operator<<(std::ostream &os, const Date &d) { + return os << d.year_ << '-' << d.month_ << '-' << d.day_; + } + }; + + std::string s = fmt::format("The date is {}", Date(2012, 12, 9)); + // s == "The date is 2012-12-9" + +.. doxygenfunction:: print(std::ostream&, CStringRef, ArgList) + +.. doxygenfunction:: fprintf(std::ostream&, CStringRef, ArgList) + Argument formatters ------------------- @@ -108,8 +131,6 @@ a POSIX extension for positional arguments. .. doxygenfunction:: fprintf(std::FILE *, CStringRef, ArgList) -.. doxygenfunction:: fprintf(std::ostream&, CStringRef, ArgList) - .. doxygenfunction:: sprintf(CStringRef, ArgList) Write API diff --git a/doc/build.py b/doc/build.py index b7992587..9721e298 100755 --- a/doc/build.py +++ b/doc/build.py @@ -60,7 +60,7 @@ def build_docs(version='dev'): GENERATE_MAN = NO GENERATE_RTF = NO CASE_SENSE_NAMES = NO - INPUT = {0}/format.h + INPUT = {0}/format.h {0}/ostream.h QUIET = YES JAVADOC_AUTOBRIEF = YES AUTOLINK_SUPPORT = NO