本文整理汇总了C++中PyList::SetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ PyList::SetItem方法的具体用法?C++ PyList::SetItem怎么用?C++ PyList::SetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyList
的用法示例。
在下文中一共展示了PyList::SetItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyDict
PyObject *DBRowToRow(DBResultRow &row, const char *type)
{
PyDict *args = new PyDict();
PyObject *res = new PyObject( type, args );
//list off the column names:
uint32 cc = row.ColumnCount();
PyList *header = new PyList(cc);
args->SetItemString("header", header);
for(uint32 r = 0; r < cc; r++) {
header->SetItemString(r, row.ColumnName(r));
}
//lines:
PyList *rowlist = new PyList(cc);
args->SetItemString("line", rowlist);
//add a line entry for the row:
for(uint32 r = 0; r < cc; r++) {
rowlist->SetItem(r, DBColumnToPyRep(row, r));
}
return res;
}
示例2: PyTuple
PyTuple *DBResultToTupleSet(DBQueryResult &result) {
uint32 cc = result.ColumnCount();
if(cc == 0)
return new PyTuple(0);
uint32 r;
PyTuple *res = new PyTuple(2);
PyList *cols = new PyList(cc);
PyList *reslist = new PyList();
res->items[0] = cols;
res->items[1] = reslist;
//list off the column names:
for(r = 0; r < cc; r++) {
cols->SetItemString(r, result.ColumnName(r));
}
//add a line entry for each result row:
DBResultRow row;
while(result.GetRow(row)) {
PyList *linedata = new PyList(cc);
reslist->items.push_back(linedata);
for(r = 0; r < cc; r++) {
linedata->SetItem(r, DBColumnToPyRep(row, r));
}
}
return res;
}
示例3: _CreateKeywords
PyDict* CRowSet::_CreateKeywords(DBRowDescriptor* rowDesc)
{
assert( rowDesc );
PyDict* keywords = new PyDict;
keywords->SetItemString( "header", rowDesc );
uint32 cc = rowDesc->ColumnCount();
PyList* columns = new PyList( cc );
for( uint32 i = 0; i < cc; i++ )
columns->SetItem( i, new PyString( *rowDesc->GetColumnName( i ) ) );
keywords->SetItemString( "columns", columns );
return keywords;
}
示例4: DBRowDescriptor
PyList *DBResultToPackedRowList( DBQueryResult &result )
{
DBRowDescriptor *header = new DBRowDescriptor( result );
PyList *res = new PyList( result.GetRowCount() );
DBResultRow row;
for( uint32 i = 0; result.GetRow( row ); i++ )
{
res->SetItem( i, CreatePackedRow( row, header ) );
PyIncRef( header );
}
PyDecRef( header );
return res;
}
示例5: PyString
PyObject *DBResultToIndexRowset(DBQueryResult &result, uint32 key_index) {
uint32 cc = result.ColumnCount();
//start building the IndexRowset
PyDict *args = new PyDict();
PyObject *res = new PyObject(
new PyString( "util.IndexRowset" ), args
);
if(cc == 0 || cc < key_index)
return res;
//list off the column names:
PyList *header = new PyList(cc);
args->SetItemString("header", header);
for(uint32 i = 0; i < cc; i++)
header->SetItemString(i, result.ColumnName(i));
//RowClass:
args->SetItemString("RowClass", new PyToken("util.Row"));
//idName:
args->SetItemString("idName", new PyString( result.ColumnName(key_index) ));
//items:
PyDict *items = new PyDict();
args->SetItemString("items", items);
//add a line entry for each result row:
DBResultRow row;
while(result.GetRow(row)) {
PyRep *key = DBColumnToPyRep(row, key_index);
PyList *line = new PyList(cc);
for(uint32 i = 0; i < cc; i++)
line->SetItem(i, DBColumnToPyRep(row, i));
items->SetItem(key, line);
}
return res;
}