-/* $Id$
-
-This file is part of libmspstrings
-Copyright © 2006-2008 Mikko Rasa
-Distributed under the LGPL
-*/
-
-#include <msp/core/except.h>
#include "fmt.h"
using namespace std;
namespace Msp {
-void Fmt::parse(const char *f)
+void Fmt::parse(const char *s)
{
+ const char *f = s;
if(*f=='%') ++f;
for(; *f; ++f)
break;
}
+ if(align==LEFT)
+ fillc = ' ';
+
wd = 0;
for(; *f; ++f)
{
else if(*f=='i')
base = AUTOBASE;
else
- throw InvalidParameterValue("Invalid conversion specifier");
+ throw format_error(s);
if(*f=='E' || *f=='F' || *f=='G' || *f=='X' || *f=='P')
ucase = true;
++f;
if(*f)
- throw InvalidParameterValue("Extra characters in conversion specification");
+ throw format_error(s);
}
Fmt &Fmt::reset()
{
- wd = 0;
- prec = 6;
- spos = false;
- fillc = ' ';
- base = DEC;
- sbase = false;
- fmode = AUTOFLT;
- spoint = false;
- align = RIGHT;
- ucase = false;
- type = STR;
-
- return *this;
+ return *this = Fmt();
}
void Fmt::apply(ostream &out) const