ConsoleTable.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef __CONSOLE_TABLE_H
  18. #define __CONSOLE_TABLE_H
  19. #include <kopano/zcdefs.h>
  20. #include <string>
  21. #include <vector>
  22. #include <kopano/charset/convert.h>
  23. namespace KC {
  24. class _kc_export ConsoleTable _kc_final {
  25. public:
  26. ConsoleTable(size_t rows, size_t columns);
  27. _kc_hidden void Clear(void);
  28. void Resize(size_t rows, size_t columns);
  29. bool SetHeader(size_t col, const std::string& entry);
  30. bool AddColumn(size_t col, const std::string& entry);
  31. bool SetColumn(size_t row, size_t col, const std::string& entry);
  32. void PrintTable();
  33. void DumpTable();
  34. private:
  35. size_t m_nRow;
  36. size_t m_iRows;
  37. size_t m_iColumns;
  38. std::vector<std::wstring> m_vHeader;
  39. std::vector<std::vector<std::wstring> > m_vTable;
  40. std::vector<size_t> m_vMaxLengths;
  41. convert_context m_converter;
  42. bool bHaveHeader;
  43. _kc_hidden void PrintRow(const std::vector<std::wstring> &row);
  44. _kc_hidden void DumpRow(const std::vector<std::wstring> &row);
  45. };
  46. } /* namespace */
  47. #endif