void LexicalConverter::result(const string &s)
{
+ filled = true;
if(s.size()<fmt.get_width())
{
if(fmt.get_align()==Fmt::RIGHT)
buf = s;
}
+const string &LexicalConverter::get() const
+{
+ if(!filled)
+ throw lexical_error("conversion not performed");
+ return buf;
+}
+
/*** operator<< ***/
{
private:
Fmt fmt;
+ bool filled;
std::string buf;
public:
- LexicalConverter(const Fmt &f): fmt(f) { }
- LexicalConverter(const std::string &s, const Fmt &f): fmt(f), buf(s) { }
+ LexicalConverter(const Fmt &f): fmt(f), filled(false) { }
+ LexicalConverter(const std::string &s, const Fmt &f): fmt(f), filled(true), buf(s) { }
const Fmt &get_fmt() const { return fmt; }
- const std::string &get() const { return buf; }
+ const std::string &get() const;
void result(const std::string &);
};