Skip to content

Commit e1d27fe

Browse files
committed
RowFormatter redesign, sample and some other minor changes
1 parent 76079f5 commit e1d27fe

21 files changed

Lines changed: 1084 additions & 280 deletions

File tree

‎Data/SQLite/testsuite/src/SQLiteTest.cpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,16 +1580,16 @@ void SQLiteTest::testInternalExtraction()
15801580

15811581
typedef std::deque<Int64> IntDeq;
15821582

1583-
const Column<Int64>& col = rset.column<Int64, IntDeq>(0);
1583+
const Column<IntDeq>& col = rset.column<IntDeq>(0);
15841584
assert (col[0] == 1);
15851585

1586-
try { rset.column<Int64, IntDeq>(100); fail ("must fail"); }
1586+
try { rset.column<IntDeq>(100); fail ("must fail"); }
15871587
catch (RangeException&) { }
15881588

1589-
const Column<Int64>& col1 = rset.column<Int64, IntDeq>(0);
1589+
const Column<IntDeq>& col1 = rset.column<IntDeq>(0);
15901590
assert ("int0" == col1.name());
1591-
Column<Int64>::Iterator it = col1.begin();
1592-
Column<Int64>::Iterator itEnd = col1.end();
1591+
Column<IntDeq>::Iterator it = col1.begin();
1592+
Column<IntDeq>::Iterator itEnd = col1.end();
15931593
int counter = 1;
15941594
for (; it != itEnd; ++it, ++counter)
15951595
assert (counter == *it);
@@ -1601,7 +1601,7 @@ void SQLiteTest::testInternalExtraction()
16011601
stmt = (tmp << "DELETE FROM Vectors", now);
16021602
rset = stmt;
16031603

1604-
try { rset.column<Int64, IntDeq>(0); fail ("must fail"); }
1604+
try { rset.column<IntDeq>(0); fail ("must fail"); }
16051605
catch (RangeException&) { }
16061606
}
16071607

@@ -1723,8 +1723,8 @@ void SQLiteTest::testRowIterator()
17231723
RecordSet rset(ses, "SELECT * FROM Vectors");
17241724

17251725
std::ostringstream osLoop;
1726-
RecordSet::Iterator it = rset.begin();
1727-
RecordSet::Iterator end = rset.end();
1726+
RecordSet::ConstIterator it = rset.begin();
1727+
RecordSet::ConstIterator end = rset.end();
17281728
for (int i = 1; it != end; ++it, ++i)
17291729
{
17301730
assert (it->get(0) == i);

‎Data/include/Poco/Data/Column.h‎

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,30 @@ namespace Data {
5555
template <class C>
5656
class Column
5757
/// Column class is column data container.
58-
/// Data (a pointer to container) is assigned to the class
59-
/// through either constructor or set() member function.
60-
/// Construction with null pointer is not allowed.
58+
/// Data (a pointer to underlying STL container) is assigned to the class
59+
/// at construction time. Construction with null pointer is not allowed.
6160
/// This class owns the data assigned to it and deletes the storage on destruction.
6261
{
6362
public:
64-
typedef C Container;
65-
typedef typename Container::const_iterator Iterator;
66-
typedef typename Container::const_reverse_iterator RIterator;
67-
typedef typename Container::size_type Size;
68-
typedef typename Container::value_type Type;
63+
typedef C Container;
64+
typedef Poco::SharedPtr<C> ContainerPtr;
65+
typedef typename C::const_iterator Iterator;
66+
typedef typename C::const_reverse_iterator RIterator;
67+
typedef typename C::size_type Size;
68+
typedef typename C::value_type Type;
6969

70-
Column(const MetaColumn& metaColumn, Container* pData): _metaColumn(metaColumn), _pData(pData)
70+
Column(const MetaColumn& metaColumn, Container* pData):
71+
_metaColumn(metaColumn),
72+
_pData(pData)
7173
/// Creates the Column.
7274
{
73-
poco_check_ptr (_pData);
75+
if (!_pData)
76+
throw NullPointerException("Container pointer must point to valid storage.");
7477
}
7578

76-
Column(const Column& col): _metaColumn(col._metaColumn), _pData(col._pData)
79+
Column(const Column& col):
80+
_metaColumn(col._metaColumn),
81+
_pData(col._pData)
7782
/// Creates the Column.
7883
{
7984
}
@@ -182,8 +187,8 @@ class Column
182187
private:
183188
Column();
184189

185-
MetaColumn _metaColumn;
186-
Poco::SharedPtr<Container> _pData;
190+
MetaColumn _metaColumn;
191+
ContainerPtr _pData;
187192
};
188193

189194

@@ -202,10 +207,11 @@ class Column<std::vector<bool> >
202207
/// column data.
203208
{
204209
public:
205-
typedef std::vector<bool> Container;
206-
typedef Container::const_iterator Iterator;
210+
typedef std::vector<bool> Container;
211+
typedef Poco::SharedPtr<Container> ContainerPtr;
212+
typedef Container::const_iterator Iterator;
207213
typedef Container::const_reverse_iterator RIterator;
208-
typedef Container::size_type Size;
214+
typedef Container::size_type Size;
209215

210216
Column(const MetaColumn& metaColumn, Container* pData):
211217
_metaColumn(metaColumn),
@@ -333,8 +339,8 @@ class Column<std::vector<bool> >
333339
private:
334340
Column();
335341

336-
MetaColumn _metaColumn;
337-
Poco::SharedPtr<Container> _pData;
342+
MetaColumn _metaColumn;
343+
ContainerPtr _pData;
338344
mutable std::deque<bool> _deque;
339345
};
340346

@@ -344,18 +350,23 @@ class Column<std::list<T> >
344350
/// Column specialization for std::list
345351
{
346352
public:
347-
typedef std::list<T> List;
348-
typedef typename List::const_iterator Iterator;
349-
typedef typename List::const_reverse_iterator RIterator;
350-
typedef typename List::size_type Size;
353+
typedef std::list<T> Container;
354+
typedef Poco::SharedPtr<Container> ContainerPtr;
355+
typedef typename Container::const_iterator Iterator;
356+
typedef typename Container::const_reverse_iterator RIterator;
357+
typedef typename Container::size_type Size;
351358

352-
Column(const MetaColumn& metaColumn, std::list<T>* pData): _metaColumn(metaColumn), _pData(pData)
359+
Column(const MetaColumn& metaColumn, std::list<T>* pData):
360+
_metaColumn(metaColumn),
361+
_pData(pData)
353362
/// Creates the Column.
354363
{
355364
poco_check_ptr (_pData);
356365
}
357366

358-
Column(const Column& col): _metaColumn(col._metaColumn), _pData(col._pData)
367+
Column(const Column& col):
368+
_metaColumn(col._metaColumn),
369+
_pData(col._pData)
359370
/// Creates the Column.
360371
{
361372
}
@@ -381,7 +392,7 @@ class Column<std::list<T> >
381392
swap(_pData, other._pData);
382393
}
383394

384-
List& data()
395+
Container& data()
385396
/// Returns reference to contained data.
386397
{
387398
return *_pData;
@@ -481,8 +492,8 @@ class Column<std::list<T> >
481492
private:
482493
Column();
483494

484-
MetaColumn _metaColumn;
485-
Poco::SharedPtr<List> _pData;
495+
MetaColumn _metaColumn;
496+
ContainerPtr _pData;
486497
};
487498

488499

0 commit comments

Comments
 (0)