#ifndef __TwoDArrayWriter_h_ #define __TwoDArrayWriter_h_ #include #include #include #include #include #include class TwoDArrayWriter { public: typedef std::vector< std::string > StringList; private: std::ofstream _stream; std::map< std::string, int > _colsByName; std::set< std::string> _rowNamesInUse; StringList _currentRow; StringList _headerRow; bool _headersFull; bool _rowInUse; int addCol(std::string colName); void flushRow(); void writeLine(StringList strings); public: TwoDArrayWriter(const std::string &filename, StringList colNames); TwoDArrayWriter(const std::string &filename); ~TwoDArrayWriter(); void addCols(StringList colNames); bool headersEmpty(); bool headersFull(); void add(std::string const &colHeader, std::string const &rowHeader, std::string const &value); }; #endif