X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fformatter.h;h=cde508bac9740aaf9c0064166436b38354a3d7f4;hp=02cd470c6563787bfa32ca5656086509c4859f48;hb=5b1368cb791cab043f0435628cacbaff36e39b7b;hpb=58384e355b4a78730d69243f1092e47591f2f384 diff --git a/source/formatter.h b/source/formatter.h index 02cd470..cde508b 100644 --- a/source/formatter.h +++ b/source/formatter.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspstrings +Copyright © 2006-2007 Mikko Rasa +Distributed under the LGPL +*/ + #ifndef MSP_STRINGS_FORMATTER_H_ #define MSP_STRINGS_FORMATTER_H_ @@ -11,29 +18,28 @@ Printf-like string formatter class. */ class Formatter { +private: + std::string fmt; + std::string::iterator pos; + std::string result; + public: Formatter(const std::string &); - /** - Extracts the next conversion from the format string and formats the given - value with it. Will throw if no more conversions are found. - */ + /** Extracts the next conversion from the format string and formats the + given value with it. Will throw if no more conversions are found. */ template Formatter &operator()(const T &a) { - result+=lexical_cast(a, get_conversion()); + result += lexical_cast(a, get_conversion()); advance(); return *this; } const std::string &str() const; private: - std::string fmt; - std::string::iterator pos; - std::string result; - void advance(); - Fmt get_conversion(); + Fmt get_conversion(); }; inline Formatter format(const std::string &f)