|
|
@@ -0,0 +1,103 @@
|
|
|
+//
|
|
|
+// RowFormatter.h
|
|
|
+//
|
|
|
+// $Id: //poco/Main/Data/include/Poco/Data/RowFormatter.h#1 $
|
|
|
+//
|
|
|
+// Library: Data
|
|
|
+// Package: DataCore
|
|
|
+// Module: RowFormatter
|
|
|
+//
|
|
|
+// Definition of the RowFormatter class.
|
|
|
+//
|
|
|
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
|
|
+// and Contributors.
|
|
|
+//
|
|
|
+// Permission is hereby granted, free of charge, to any person or organization
|
|
|
+// obtaining a copy of the software and accompanying documentation covered by
|
|
|
+// this license (the "Software") to use, reproduce, display, distribute,
|
|
|
+// execute, and transmit the Software, and to prepare derivative works of the
|
|
|
+// Software, and to permit third-parties to whom the Software is furnished to
|
|
|
+// do so, all subject to the following:
|
|
|
+//
|
|
|
+// The copyright notices in the Software and this entire statement, including
|
|
|
+// the above license grant, this restriction and the following disclaimer,
|
|
|
+// must be included in all copies of the Software, in whole or in part, and
|
|
|
+// all derivative works of the Software, unless such copies or derivative
|
|
|
+// works are solely in the form of machine-executable object code generated by
|
|
|
+// a source language processor.
|
|
|
+//
|
|
|
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
|
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
|
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
|
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
+// DEALINGS IN THE SOFTWARE.
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
+#ifndef Data_RowFormatter_INCLUDED
|
|
|
+#define Data_RowFormatter_INCLUDED
|
|
|
+
|
|
|
+
|
|
|
+#include "Poco/Data/Data.h"
|
|
|
+
|
|
|
+
|
|
|
+namespace Poco {
|
|
|
+namespace Data {
|
|
|
+
|
|
|
+
|
|
|
+class Row;
|
|
|
+
|
|
|
+
|
|
|
+class Data_API RowFormatter
|
|
|
+ /// Row formatter is a rudimentary formatting class providing
|
|
|
+ /// basic row formatting. This class will separate field names and
|
|
|
+ /// filed values by a tab ('\t') and append the platform specific
|
|
|
+ /// end of line at the end of each row. For custom formatting
|
|
|
+ /// strategies, inherit from this class and override formatNames()
|
|
|
+ /// and formaValues() member functions.
|
|
|
+{
|
|
|
+public:
|
|
|
+ static const std::string EOL;
|
|
|
+
|
|
|
+ RowFormatter(Row* pRow = 0);
|
|
|
+ /// Creates the RowFormatter.
|
|
|
+
|
|
|
+ virtual ~RowFormatter();
|
|
|
+ /// Destroys the RowFormatter.
|
|
|
+
|
|
|
+ void setRow(Row* pRow);
|
|
|
+ /// Assigns the row to this formatter.
|
|
|
+
|
|
|
+ virtual std::string& formatNames(std::string& names);
|
|
|
+ /// Formats the row field names.
|
|
|
+
|
|
|
+ virtual std::string& formatValues(std::string& values);
|
|
|
+ /// Formats the row values.
|
|
|
+
|
|
|
+private:
|
|
|
+ RowFormatter(const RowFormatter&);
|
|
|
+ RowFormatter& operator = (const RowFormatter&);
|
|
|
+
|
|
|
+ Row* _pRow;
|
|
|
+ std::string _separator;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+///
|
|
|
+/// inlines
|
|
|
+///
|
|
|
+
|
|
|
+
|
|
|
+inline void RowFormatter::setRow(Row* pRow)
|
|
|
+{
|
|
|
+ poco_check_ptr (pRow);
|
|
|
+ _pRow = pRow;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+} } // namespace Poco::Data
|
|
|
+
|
|
|
+
|
|
|
+#endif // Data_RowFormatter_INCLUDED
|