X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstrings%2Fformat.h;h=65d10dffa585bb6e272db7d1d20a71a07b6a0a42;hp=db74bf9560788f3bbce4b0673cd5f7b3076ba2fc;hb=42ff7c629b2aa7411963bdcc2259a06b1d1de6d3;hpb=3a965c87750250c8facc9dbff02aeb3a88e19f05 diff --git a/source/strings/format.h b/source/strings/format.h index db74bf9..65d10df 100644 --- a/source/strings/format.h +++ b/source/strings/format.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspstrings -Copyright © 2006-2007 Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_STRINGS_FORMAT_H_ #define MSP_STRINGS_FORMAT_H_ @@ -31,14 +24,23 @@ public: template Formatter &operator()(const T &a) { - result += lexical_cast(a, get_conversion()); + result += lexical_cast(a, get_conversion()); advance(); return *this; } + /** Returns the result of the formatting operation. Will throw if not + enough values have been fed to the formatter. */ const std::string &str() const; + private: + /** Advances the iterator to the next conversion, adding literal characters + to the result. The iterator is left at the second character of the + conversion (i.e. after the %). */ void advance(); + + /** Reads the next conversion from the format string and returns a + corresponding Fmt object. */ Fmt get_conversion(); };