X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstrings%2Ffmt.h;h=ee84911bcec06fcd0fc34402ef8975133235b3ce;hp=ba75958802b7760b6f6b352827e4f313048e717f;hb=71be32fe7248a7d2df7dea4e18c5ebd30fd73d4b;hpb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd diff --git a/source/strings/fmt.h b/source/strings/fmt.h index ba75958..ee84911 100644 --- a/source/strings/fmt.h +++ b/source/strings/fmt.h @@ -1,18 +1,20 @@ -/* $Id$ - -This file is part of libmspstrings -Copyright © 2006-2008 Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_STRINGS_FMT_H_ #define MSP_STRINGS_FMT_H_ #include +#include #include namespace Msp { +class format_error: public std::logic_error +{ +public: + format_error(const std::string &w): std::logic_error(w) { } + virtual ~format_error() throw() { } +}; + + /** Stores formatting information for converting variables into strings. Can be applied to an std::ostream or fed to lexical_cast. Also used internally by @@ -89,19 +91,20 @@ private: public: Fmt &width(unsigned w) { wd = w; return *this; } Fmt &precision(unsigned p) { prec = p; return *this; } - Fmt &showpos(bool s=true) { spos = s; return *this; } + Fmt &showpos(bool s = true) { spos = s; return *this; } Fmt &fill(wchar_t f) { fillc = f; return *this; } Fmt &fixed() { fmode = FIXED; return *this; } Fmt &scientific() { fmode = SCI; return *this; } - Fmt &showpoint(bool s=true) { spoint = s; return *this; } - Fmt &showbase(bool s=true) { sbase = s; return *this; } + Fmt &showpoint(bool s = true) { spoint = s; return *this; } + Fmt &showbase(bool s = true) { sbase = s; return *this; } Fmt &left() { align = LEFT; return *this; } Fmt &right() { align = RIGHT; return *this; } Fmt &dec() { base = DEC; return *this; } Fmt &hex() { base = HEX; return *this; } Fmt &oct() { base = OCT; return *this; } Fmt &bin() { base = BIN; return *this; } - Fmt &uppercase(bool u=true) { ucase = u; return *this; } + Fmt &autobase() { base = AUTOBASE; return *this; } + Fmt &uppercase(bool u = true) { ucase = u; return *this; } Fmt &numeric() { type = NUM; return *this; } Fmt &character() { type = CHAR; return *this; } Fmt &string() { type = STR; return *this; }