本文整理汇总了C++中Row::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Row::append方法的具体用法?C++ Row::append怎么用?C++ Row::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Row
的用法示例。
在下文中一共展示了Row::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RangeException
Row& RecordSet::row(std::size_t pos)
{
std::size_t rowCnt = rowCount();
if (0 == rowCnt || pos > rowCnt - 1)
throw RangeException("Invalid recordset row requested.");
RowMap::const_iterator it = _rowMap.find(pos);
Row* pRow = 0;
std::size_t columns = columnCount();
if (it == _rowMap.end())
{
if (_rowMap.size())
{
//reuse first row column names and sorting fields to save some memory
pRow = new Row(_rowMap.begin()->second->names(),
_rowMap.begin()->second->getSortMap(),
getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->set(col, value(col, pos));
}
else
{
pRow = new Row;
pRow->setFormatter(getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->append(metaColumn(static_cast<UInt32>(col)).name(), value(col, pos));
}
_rowMap.insert(RowMap::value_type(pos, pRow));
}
else
{
pRow = it->second;
poco_check_ptr (pRow);
}
return *pRow;
}
示例2: testRow
void DataTest::testRow()
{
Row row;
row.append("field0", 0);
row.append("field1", 1);
row.append("field2", 2);
row.append("field3", 3);
row.append("field4", 4);
assert (row["field0"] == 0);
assert (row["field1"] == 1);
assert (row["field2"] == 2);
assert (row["field3"] == 3);
assert (row["field4"] == 4);
assert (row[0] == 0);
assert (row[1] == 1);
assert (row[2] == 2);
assert (row[3] == 3);
assert (row[4] == 4);
try
{
int i; i = row[5]; // to silence gcc
fail ("must fail");
}catch (RangeException&) {}
try
{
int i; i = row["a bad name"]; // to silence gcc
fail ("must fail");
}catch (NotFoundException&) {}
assert (5 == row.fieldCount());
assert (row[0] == 0);
assert (row["field0"] == 0);
assert (row[1] == 1);
assert (row["field1"] == 1);
assert (row[2] == 2);
assert (row["field2"] == 2);
assert (row[3] == 3);
assert (row["field3"] == 3);
assert (row[4] == 4);
assert (row["field4"] == 4);
Row row2;
row2.append("field0", 5);
row2.append("field1", 4);
row2.append("field2", 3);
row2.append("field3", 2);
row2.append("field4", 1);
assert (row != row2);
Row row3;
row3.append("field0", 0);
row3.append("field1", 1);
row3.append("field2", 2);
row3.append("field3", 3);
row3.append("field4", 4);
assert (row3 == row);
assert (!(row < row3 | row3 < row));
Row row4(row3.names());
try
{
row4.set("badfieldname", 0);
fail ("must fail");
}catch (NotFoundException&) {}
row4.set("field0", 0);
row4.set("field1", 1);
row4.set("field2", 2);
row4.set("field3", 3);
row4.set("field4", 4);
assert (row3 == row4);
try
{
row4.set(5, 0);
fail ("must fail");
}catch (RangeException&) {}
row4.set("field0", 1);
assert (row3 != row4);
assert (row3 < row4);
}