1 // 2 // RowFormatter.h 3 // 4 // Library: Data 5 // Package: DataCore 6 // Module: SimpleRowFormatter 7 // 8 // Definition of the RowFormatter class. 9 // 10 // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. 11 // and Contributors. 12 // 13 // SPDX-License-Identifier: BSL-1.0 14 // 15 16 17 #ifndef Data_SimpleRowFormatter_INCLUDED 18 #define Data_SimpleRowFormatter_INCLUDED 19 20 21 #include "Poco/Data/Data.h" 22 #include "Poco/Data/RowFormatter.h" 23 24 25 namespace Poco { 26 namespace Data { 27 28 29 class Data_API SimpleRowFormatter: public RowFormatter 30 /// A simple row formatting class. 31 { 32 public: 33 //using NameVec = RowFormatter::NameVec; 34 //using NameVecPtr = RowFormatter::NameVecPtr; 35 //using ValueVec = RowFormatter::ValueVec; 36 37 static const int DEFAULT_COLUMN_WIDTH = 16; 38 static const int DEFAULT_SPACING = 1; 39 40 SimpleRowFormatter(std::streamsize columnWidth = DEFAULT_COLUMN_WIDTH, std::streamsize spacing = DEFAULT_SPACING); 41 /// Creates the SimpleRowFormatter and sets the column width to specified value. 42 43 SimpleRowFormatter(const SimpleRowFormatter& other); 44 /// Creates the copy of the supplied SimpleRowFormatter. 45 46 SimpleRowFormatter& operator = (const SimpleRowFormatter& row); 47 /// Assignment operator. 48 49 ~SimpleRowFormatter(); 50 /// Destroys the SimpleRowFormatter. 51 52 void swap(SimpleRowFormatter& other); 53 /// Swaps the row formatter with another one. 54 55 std::string& formatNames(const NameVecPtr pNames, std::string& formattedNames); 56 /// Formats the row field names. 57 58 std::string& formatValues(const ValueVec& vals, std::string& formattedValues); 59 /// Formats the row values. 60 61 int rowCount() const; 62 /// Returns row count. 63 64 void setColumnWidth(std::streamsize width); 65 /// Sets the column width. 66 67 std::streamsize getColumnWidth() const; 68 /// Returns the column width. 69 70 std::streamsize getSpacing() const; 71 /// Returns the spacing. 72 73 private: 74 std::streamsize _colWidth; 75 std::streamsize _spacing; 76 int _rowCount; 77 }; 78 79 80 /// 81 /// inlines 82 /// rowCount()83inline int SimpleRowFormatter::rowCount() const 84 { 85 return _rowCount; 86 } 87 88 setColumnWidth(std::streamsize columnWidth)89inline void SimpleRowFormatter::setColumnWidth(std::streamsize columnWidth) 90 { 91 _colWidth = columnWidth; 92 } 93 94 getColumnWidth()95inline std::streamsize SimpleRowFormatter::getColumnWidth() const 96 { 97 return _colWidth; 98 } 99 100 getSpacing()101inline std::streamsize SimpleRowFormatter::getSpacing() const 102 { 103 return _spacing; 104 } 105 106 107 } } // namespace Poco::Data 108 109 110 namespace std 111 { 112 template<> 113 inline void swap<Poco::Data::SimpleRowFormatter>(Poco::Data::SimpleRowFormatter& s1, 114 Poco::Data::SimpleRowFormatter& s2) 115 /// Full template specalization of std:::swap for SimpleRowFormatter 116 { 117 s1.swap(s2); 118 } 119 } 120 121 122 #endif // Data_SimpleRowFormatter_INCLUDED 123