mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 02:06:04 +02:00
clang build
This commit is contained in:
@@ -10,7 +10,7 @@ include $(POCO_BASE)/build/rules/global
|
|||||||
|
|
||||||
objects = AbstractBinder AbstractBinding AbstractExtraction AbstractExtractor \
|
objects = AbstractBinder AbstractBinding AbstractExtraction AbstractExtractor \
|
||||||
AbstractPreparation AbstractPreparator ArchiveStrategy Transaction \
|
AbstractPreparation AbstractPreparator ArchiveStrategy Transaction \
|
||||||
Bulk Connector DataException Date DynamicLOB Limit JSONFormatter \
|
Bulk Connector DataException Date DynamicLOB Limit JSONRowFormatter \
|
||||||
MetaColumn PooledSessionHolder PooledSessionImpl Position \
|
MetaColumn PooledSessionHolder PooledSessionImpl Position \
|
||||||
Range RecordSet Row RowFilter RowFormatter RowIterator \
|
Range RecordSet Row RowFilter RowFormatter RowIterator \
|
||||||
SimpleRowFormatter Session SessionFactory SessionImpl \
|
SimpleRowFormatter Session SessionFactory SessionImpl \
|
||||||
|
|||||||
@@ -29,6 +29,51 @@ namespace Data {
|
|||||||
|
|
||||||
class Data_API JSONRowFormatter: public Poco::Data::RowFormatter
|
class Data_API JSONRowFormatter: public Poco::Data::RowFormatter
|
||||||
/// Class for JSON formatting of data rows.
|
/// Class for JSON formatting of data rows.
|
||||||
|
///
|
||||||
|
/// Formatter can be configured to operate in four modes (and
|
||||||
|
/// certain combinations thereof) :
|
||||||
|
///
|
||||||
|
/// - small (condensed mode, only array of values)
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// {
|
||||||
|
/// [["Simpson", "Bart", "Springfield", 12],
|
||||||
|
/// ["Simpson", "Lisa", "Springfield", 10]]
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// - row count (total row count provided)
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// {
|
||||||
|
/// "count":2,
|
||||||
|
/// [["Simpson", "Bart", "Springfield", 12],
|
||||||
|
/// ["Simpson", "Lisa", "Springfield", 10]]
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// - column names (column names provided as a string array)
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// {
|
||||||
|
/// "names":["LastName", "FirstName", "Address", "Age"],
|
||||||
|
/// [["Simpson", "Bart", "Springfield", 12],
|
||||||
|
/// ["Simpson", "Lisa", "Springfield", 10]]
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// - full (total row count, column names provided in every row of data)
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// {
|
||||||
|
/// "count":2,
|
||||||
|
/// [
|
||||||
|
/// {"LastName": "Simpson", "FirstName": "Bart", "Address": "Springfield", "Age": 12},
|
||||||
|
/// {"LastName": "Simpson", "FirstName": "Lisa", "Address": "Springfield", "Age": 10}
|
||||||
|
/// ]
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// Total row count will be specified by the Poco::DataRecordSet. Note, however, that this is
|
||||||
|
/// not possible to do accurately in case of result set paging. For those cases, there is
|
||||||
|
/// setTotalRowCount() member function, which allows to explicitly set the total row count.
|
||||||
|
/// If the total row count is preset on the formatter, the Data framework shall not interfere.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const int JSON_FMT_MODE_SMALL = 1;
|
static const int JSON_FMT_MODE_SMALL = 1;
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ class Data_API SimpleRowFormatter: public RowFormatter
|
|||||||
/// A simple row formatting class.
|
/// A simple row formatting class.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//typedef RowFormatter::NameVec NameVec;
|
|
||||||
//typedef RowFormatter::NameVecPtr NameVecPtr;
|
|
||||||
//typedef RowFormatter::ValueVec ValueVec;
|
|
||||||
|
|
||||||
static const int DEFAULT_COLUMN_WIDTH = 16;
|
static const int DEFAULT_COLUMN_WIDTH = 16;
|
||||||
static const int DEFAULT_SPACING = 1;
|
static const int DEFAULT_SPACING = 1;
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ namespace Poco {
|
|||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
|
const int JSONRowFormatter::JSON_FMT_MODE_SMALL;
|
||||||
|
const int JSONRowFormatter::JSON_FMT_MODE_ROW_COUNT;
|
||||||
|
const int JSONRowFormatter::JSON_FMT_MODE_COLUMN_NAMES;
|
||||||
|
const int JSONRowFormatter::JSON_FMT_MODE_FULL;
|
||||||
|
|
||||||
|
|
||||||
JSONRowFormatter::JSONRowFormatter(int mode) : RowFormatter("{", "]}"),
|
JSONRowFormatter::JSONRowFormatter(int mode) : RowFormatter("{", "]}"),
|
||||||
_firstTime(true)
|
_firstTime(true)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -301,11 +301,18 @@ bool RecordSet::moveLast()
|
|||||||
|
|
||||||
void RecordSet::setRowFormatter(RowFormatter::Ptr pRowFormatter)
|
void RecordSet::setRowFormatter(RowFormatter::Ptr pRowFormatter)
|
||||||
{
|
{
|
||||||
pRowFormatter->setTotalRowCount(static_cast<int>(getTotalRowCount()));
|
if (pRowFormatter)
|
||||||
Statement::setRowFormatter(pRowFormatter);
|
{
|
||||||
RowMap::iterator it = _rowMap.begin();
|
if (pRowFormatter->getTotalRowCount() == RowFormatter::INVALID_ROW_COUNT)
|
||||||
RowMap::iterator end = _rowMap.end();
|
pRowFormatter->setTotalRowCount(static_cast<int>(getTotalRowCount()));
|
||||||
for (; it != end; ++it) it->second->setFormatter(getRowFormatter());
|
|
||||||
|
Statement::setRowFormatter(pRowFormatter);
|
||||||
|
RowMap::iterator it = _rowMap.begin();
|
||||||
|
RowMap::iterator end = _rowMap.end();
|
||||||
|
for (; it != end; ++it) it->second->setFormatter(getRowFormatter());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw NullPointerException("Null RowFormatter in RecordSet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1232,7 +1232,6 @@ void DataTest::testJSONRowFormatter()
|
|||||||
row1.setFormatter(new JSONRowFormatter(JSONRowFormatter::JSON_FMT_MODE_SMALL));
|
row1.setFormatter(new JSONRowFormatter(JSONRowFormatter::JSON_FMT_MODE_SMALL));
|
||||||
assert(row1.getFormatter().getMode() == RowFormatter::FORMAT_PROGRESSIVE);
|
assert(row1.getFormatter().getMode() == RowFormatter::FORMAT_PROGRESSIVE);
|
||||||
assert(row1.namesToString() == "");
|
assert(row1.namesToString() == "");
|
||||||
//std::cout << row1.valuesToString() << std::endl;
|
|
||||||
assert(row1.valuesToString() == "[[0,\"1\",\"2007-03-13T08:12:15Z\",null,4]");
|
assert(row1.valuesToString() == "[[0,\"1\",\"2007-03-13T08:12:15Z\",null,4]");
|
||||||
assert(row1.valuesToString() == ",[0,\"1\",\"2007-03-13T08:12:15Z\",null,4]");
|
assert(row1.valuesToString() == ",[0,\"1\",\"2007-03-13T08:12:15Z\",null,4]");
|
||||||
|
|
||||||
@@ -1240,7 +1239,6 @@ void DataTest::testJSONRowFormatter()
|
|||||||
assert(row1.getFormatter().prefix() == "{\"count\":0,[");
|
assert(row1.getFormatter().prefix() == "{\"count\":0,[");
|
||||||
assert(row1.getFormatter().postfix() == "]}");
|
assert(row1.getFormatter().postfix() == "]}");
|
||||||
assert(row1.getFormatter().getMode() == RowFormatter::FORMAT_PROGRESSIVE);
|
assert(row1.getFormatter().getMode() == RowFormatter::FORMAT_PROGRESSIVE);
|
||||||
std::cout << row1.namesToString() << std::endl;
|
|
||||||
assert(row1.namesToString() == "");
|
assert(row1.namesToString() == "");
|
||||||
assert(row1.valuesToString() == "{\"field0\":0,\"field1\":\"1\",\"field2\":\"2007-03-13T08:12:15Z\",\"field3\":null,\"field4\":4}");
|
assert(row1.valuesToString() == "{\"field0\":0,\"field1\":\"1\",\"field2\":\"2007-03-13T08:12:15Z\",\"field3\":null,\"field4\":4}");
|
||||||
assert(row1.valuesToString() == ",{\"field0\":0,\"field1\":\"1\",\"field2\":\"2007-03-13T08:12:15Z\",\"field3\":null,\"field4\":4}");
|
assert(row1.valuesToString() == ",{\"field0\":0,\"field1\":\"1\",\"field2\":\"2007-03-13T08:12:15Z\",\"field3\":null,\"field4\":4}");
|
||||||
|
|||||||
Reference in New Issue
Block a user