本文整理汇总了C++中PyList::SetItemString方法的典型用法代码示例。如果您正苦于以下问题:C++ PyList::SetItemString方法的具体用法?C++ PyList::SetItemString怎么用?C++ PyList::SetItemString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyList
的用法示例。
在下文中一共展示了PyList::SetItemString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
PyTuple *DBResultToRowList(DBQueryResult &result, const char *type) {
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->SetItem( 0, cols );
res->SetItem( 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)) {
//this could be more efficient by not building the column list each time, but cloning it instead.
PyObject *o = DBRowToRow(row, type);
reslist->items.push_back(o);
}
return res;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}