From 4a7eaceea8faaad11c12d7450d080321074dbed3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 30 Dec 2016 18:26:34 +0000 Subject: Add doxygen comments for compile time formatter --- libadhocutil/compileTimeFormatter.h | 59 ++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h index aeff488..631b0f7 100644 --- a/libadhocutil/compileTimeFormatter.h +++ b/libadhocutil/compileTimeFormatter.h @@ -4,6 +4,7 @@ #include namespace AdHoc { + /// @cond constexpr int WRAP_AT = 120; template struct Buffer { }; @@ -169,28 +170,46 @@ namespace AdHoc { template struct Parser : public ParserBase{ }; + /// @endcond + /** + * Compile time string formatter. + * @param S the format string. + */ template - struct Formatter { - template - static std::string get(const Pn & ... pn) - { - std::stringstream s; - return run(Parser::parse(), s, pn...).str(); - } - - template - static stream & write(stream & s, const Pn & ... pn) - { - return run(Parser::parse(), s, pn...); - } - - template class ParserBuffer, typename ... Pn> - static stream & run(const ParserBuffer &, stream & s, const Pn & ... pn) - { - StreamWriter::write(s, pn...); - return s; - } + class Formatter { + public: + /** + * Get a string containing the result of formatting. + * @param pn the format arguments. + * @return the formatted string. + */ + template + static std::string get(const Pn & ... pn) + { + std::stringstream s; + return run(Parser::parse(), s, pn...).str(); + } + + /** + * Write the result of formatting to the given stream. + * @param s the stream to write to. + * @param pn the format arguments. + * @return the stream. + */ + template + static stream & write(stream & s, const Pn & ... pn) + { + return run(Parser::parse(), s, pn...); + } + + private: + template class ParserBuffer, typename ... Pn> + static stream & run(const ParserBuffer &, stream & s, const Pn & ... pn) + { + StreamWriter::write(s, pn...); + return s; + } }; } -- cgit v1.2.3