#ifndef BASE_GRID_LAYOUT_H #define BASE_GRID_LAYOUT_H #include #include #include #include #include //---------------------------------------------------------------- namespace base { class grid_layout { public: typedef std::list row; typedef std::list grid; grid_layout(); void render(std::ostream &out) const; void new_row(); template void field(T const &t) { push_field(boost::lexical_cast(t)); } private: row ¤t_row(); row const ¤t_row() const; void push_field(std::string const &s); void calc_field_widths(std::vector &widths) const; std::string justify(unsigned width, std::string const &txt) const; grid grid_; unsigned nr_fields_; }; } //---------------------------------------------------------------- #endif