X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstrings%2Ffmt.h;h=45ae91749c5e3b51ae19b1ebc4dbec8d1627f4d5;hp=8633324b5c0d323d272a194d5e9c68716093b671;hb=991fabc1956b73a4007859058fb44171000b452e;hpb=02df44f46e4aaa3989d0ee9c9e2e25f8a808e0ec diff --git a/source/strings/fmt.h b/source/strings/fmt.h index 8633324..45ae917 100644 --- a/source/strings/fmt.h +++ b/source/strings/fmt.h @@ -1,10 +1,3 @@ -/* $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_ @@ -18,7 +11,7 @@ class format_error: public std::logic_error { public: format_error(const std::string &w): std::logic_error(w) { } - virtual ~format_error() throw() { } + ~format_error() throw() override = default; }; @@ -75,22 +68,22 @@ public: }; private: - unsigned wd; - unsigned prec; - bool spos; - wchar_t fillc; - Base base; - bool sbase; - FloatMode fmode; - bool spoint; - Align align; - bool ucase; - Type type; + unsigned wd = 0; + unsigned prec = 6; + bool spos = false; + wchar_t fillc = ' '; + Base base = DEC; + bool sbase = false; + FloatMode fmode = AUTOFLT; + bool spoint = false; + Align align = RIGHT; + bool ucase = false; + Type type = STR; public: - Fmt() { reset(); } - Fmt(const char *f) { reset(); parse(f); } - Fmt(const std::string &f) { reset(); parse(f.c_str()); } + Fmt() = default; + Fmt(const char *f) { parse(f); } + Fmt(const std::string &f) { parse(f.c_str()); } private: void parse(const char *); @@ -98,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; }