本文整理汇总了C++中PyList类的典型用法代码示例。如果您正苦于以下问题:C++ PyList类的具体用法?C++ PyList怎么用?C++ PyList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PyList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Handle_DeleteBookmarks
PyResult BookmarkService::Handle_DeleteBookmarks(PyCallArgs &call)
{
if ( !(call.tuple->GetItem( 0 )->IsList()) )
{
sLog.Error( "BookmarkService::Handle_DeleteBookmarks()", "%s: call.tuple is of the wrong type: '%s'. Expected PyList type.", call.client->GetName(), call.tuple->TypeString() );
return NULL;
}
PyList *list = call.tuple->GetItem( 0 )->AsList();
uint32 i;
uint32 bookmarkID;
std::vector<unsigned long> bookmarkIDs;
if( list->size() > 0 )
{
for(i=0; i<(list->size()); i++)
{
bookmarkID = call.tuple->GetItem( 0 )->AsList()->GetItem(i)->AsInt()->value();
bookmarkIDs.push_back( bookmarkID );
}
m_db.DeleteBookmarksFromDatabase( call.client->GetCharacterID(),&bookmarkIDs );
}
else
{
sLog.Error( "BookmarkService::Handle_DeleteBookmarks()", "%s: call.tuple->GetItem( 0 )->AsList()->size() == 0. Expected size >= 1.", call.client->GetName() );
return NULL;
}
return(new PyNone());
}
示例2: lock
void XBPython::Process()
{
if (m_bInitialized)
{
PyList tmpvec;
CSingleLock lock(m_vecPyList);
for (PyList::iterator it = m_vecPyList.begin(); it != m_vecPyList.end();)
{
if (it->bDone)
{
tmpvec.push_back(*it);
it = m_vecPyList.erase(it);
m_vecPyList.hadSomethingRemoved = true;
}
else
++it;
}
lock.Leave();
//delete scripts which are done
tmpvec.clear(); // boost releases the XBPyThreads which, if deleted, calls OnScriptFinalized
CSingleLock l2(m_critSection);
if(m_iDllScriptCounter == 0 && (XbmcThreads::SystemClockMillis() - m_endtime) > 10000 )
{
Finalize();
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: PyList
PyPackedRow* InventoryItem::GetItemRow() const
{
PyList *keywords = new PyList();
keywords->AddItem(new_tuple(new PyString("stacksize"), new PyToken("util.StackSize")));
keywords->AddItem(new_tuple(new PyString("singleton"), new PyToken("util.Singleton")));
DBRowDescriptor* header = new DBRowDescriptor(keywords);
header->AddColumn( "itemID", DBTYPE_I8 );
header->AddColumn( "typeID", DBTYPE_I4 );
header->AddColumn( "ownerID", DBTYPE_I4 );
header->AddColumn( "locationID", DBTYPE_I8 );
header->AddColumn( "flagID", DBTYPE_I2 );
header->AddColumn( "quantity", DBTYPE_I4 );
header->AddColumn( "groupID", DBTYPE_I2 );
header->AddColumn( "categoryID", DBTYPE_I4 );
header->AddColumn( "customInfo", DBTYPE_STR );
//header->AddColumn( "singleton", DBTYPE_BOOL );
//header->AddColumn( "stacksize" , DBTYPE_I4 );
PyPackedRow* row = new PyPackedRow( header );
GetItemRow( row );
return row;
}
示例7: PyGet
void ItemAttributeMgr::Clear(Attr attr) {
PyRep *oldValue = NULL;
if(GetNotify() == true && !IsRechargable(attr)) {
// get old value
oldValue = PyGet(attr);
}
// clear the attribute
EVEAdvancedAttributeMgr::Clear(attr);
// delete the attribute from DB (no matter if it really is there)
if(GetSave() == true) {
m_factory.db().EraseAttribute(m_item.itemID(), attr);
}
if(GetNotify() == true) {
std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr);
if(i != m_tauCap.end()) {
// build the special list for rechargables
PyList *l = new PyList;
l->AddItem( PyGet( attr ) );
l->AddItemLong( Win32TimeNow() );
l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) );
l->AddItem( PyGet( i->second.cap ) );
oldValue = l;
}
// send change
_SendAttributeChange(attr, oldValue, new PyFloat(GetReal(attr)));
}
}
示例8: DBResultToIntIntlistDict
/**
* this function isn't used.
*/
void DBResultToIntIntlistDict( DBQueryResult &result, std::map<int32, PyRep *> &into ) {
/* this builds a map from the int in result[0], to a list of each result[1]
* which is has the same result[0]. This function assumes the result is
* ORDER BY result[0]
*/
uint32 last_key = 0xFFFFFFFF;
PyList *l = NULL;
DBResultRow row;
while( result.GetRow( row ) )
{
uint32 k = row.GetUInt(0);
if( k != last_key )
{
//watch for overwrite, no guarantee we are dealing with a key.
std::map<int32, PyRep *>::iterator res = into.find(k);
if( res != into.end() )
//log an error or warning?
PyDecRef( res->second );
into[k] = l = new PyList();
last_key = k;
}
l->AddItemInt( row.GetInt( 1 ) );
}
}
示例9: PyTuple
PyTuple *Character::GetSkillQueue() {
// return skills from skill queue
PyList *list = new PyList;
SkillQueue::iterator cur, end;
cur = m_skillQueue.begin();
end = m_skillQueue.end();
for(; cur != end; cur++)
{
SkillQueue_Element el;
el.typeID = cur->typeID;
el.level = cur->level;
list->AddItem( el.Encode() );
}
// now encapsulate it in a tuple with the free points
PyTuple *tuple = new PyTuple(2);
tuple->SetItem(0, list);
// sending 0, as done on retail, doesn't fuck up calculation for some reason
// so we can take the same shortcut here
tuple->SetItem(1, new PyInt(0));
return tuple;
}
示例10: Win32TimeNow
void Webifier::StopCycle(bool abort)
{
double timeLeft = m_AMPC->GetRemainingCycleTimeMS();
timeLeft /= 100;
// Create Special Effect:
m_Ship->GetPilot()->GetShipSE()->DestinyMgr()->SendSpecialEffect
(
m_Ship,
m_Item->itemID(),
m_Item->typeID(),
m_targetID,
0,
"effect.decreaseTargetSpeed",
0,
0,
0,
timeLeft,
0
);
// Create Destiny Updates:
GodmaOther go;
go.shipID = m_Ship->itemID();
go.slotID = m_Item->flag();
go.chargeTypeID = 0;
GodmaEnvironment ge;
ge.selfID = m_Item->itemID();
ge.charID = m_Ship->ownerID();
ge.shipID = go.shipID;
ge.targetID = m_targetID;
ge.other = go.Encode();
ge.area = new PyList;
ge.effectID = effectDecreaseTargetSpeed;
Notify_OnGodmaShipEffect shipEff;
shipEff.itemID = ge.selfID;
shipEff.effectID = ge.effectID;
shipEff.timeNow = Win32TimeNow();
shipEff.start = 0;
shipEff.active = 0;
shipEff.environment = ge.Encode();
shipEff.startTime = (shipEff.timeNow - (timeLeft * Win32Time_Second));
shipEff.duration = timeLeft;
shipEff.repeat = 0;
shipEff.error = new PyNone;
PyList* events = new PyList;
events->AddItem(shipEff.Encode());
Notify_OnMultiEvent multi;
multi.events = events;
PyTuple* tmp2 = multi.Encode();
m_Ship->GetPilot()->SendNotification("OnMultiEvent", "clientID", &tmp2);
}
示例11: Win32TimeNow
void EnergyTurret::Deactivate()
{
Notify_OnGodmaShipEffect shipEff;
shipEff.itemID = m_Item->itemID();
shipEff.effectID = 10;
shipEff.when = Win32TimeNow();
shipEff.start = 0;
shipEff.active = 0;
PyList* env = new PyList;
env->AddItem(new PyInt(shipEff.itemID));
env->AddItem(new PyInt(m_Ship->ownerID()));
env->AddItem(new PyInt(m_Ship->itemID()));
env->AddItem(new PyInt(targetID));
env->AddItem(new PyNone);
env->AddItem(new PyNone);
env->AddItem(new PyInt(10));
shipEff.environment = env;
shipEff.startTime = shipEff.when;
shipEff.duration = 1584;
shipEff.repeat = new PyInt(0);
shipEff.randomSeed = new PyNone;
shipEff.error = new PyNone;
PyList* events = new PyList;
events->AddItem(shipEff.Encode());
Notify_OnMultiEvent multi;
multi.events = events;
PyTuple* tmp = multi.Encode();
m_Ship->GetOperator()->SendDogmaNotification("OnMultiEvent", "clientID", &tmp);
}
示例12: PyList
PyList *TargetManager::GetTargeters() const {
PyList *result = new PyList();
std::map<SystemEntity *, TargetedByEntry *>::const_iterator cur, end;
cur = m_targetedBy.begin();
end = m_targetedBy.end();
for(; cur != end; cur++)
result->AddItemInt( cur->first->GetID() );
return result;
}
示例13: DoCycle
void MissileLauncher::StopCycle(bool abort)
{
// Do one last cycle:
DoCycle();
Notify_OnGodmaShipEffect shipEff;
shipEff.itemID = m_Item->itemID();
shipEff.effectID = effectMissileLaunching;
shipEff.when = Win32TimeNow();
shipEff.start = 0;
shipEff.active = 0;
PyList* env = new PyList;
env->AddItem(new PyInt(shipEff.itemID));
env->AddItem(new PyInt(m_Ship->ownerID()));
env->AddItem(new PyInt(m_Ship->itemID()));
env->AddItem(new PyInt(m_targetID));
env->AddItem(new PyNone);
env->AddItem(new PyNone);
env->AddItem(new PyInt(shipEff.effectID));
shipEff.environment = env;
shipEff.startTime = shipEff.when;
shipEff.duration = 1.0; //m_ActiveModuleProc->GetRemainingCycleTimeMS(); // At least, I'm assuming this is the remaining time left in the cycle
shipEff.repeat = new PyInt(0);
shipEff.randomSeed = new PyNone;
shipEff.error = new PyNone;
PyList* events = new PyList;
events->AddItem(shipEff.Encode());
Notify_OnMultiEvent multi;
multi.events = events;
PyTuple* tmp = multi.Encode();
m_Ship->GetOperator()->SendDogmaNotification("OnMultiEvent", "clientID", &tmp);
// Create Special Effect:
m_Ship->GetOperator()->GetDestiny()->SendSpecialEffect
(
m_Ship,
m_Item->itemID(),
m_Item->typeID(),
m_targetID,
m_chargeRef->itemID(),
"effects.MissileDeployment",
1,
0,
0,
1.0,
0
);
m_ActiveModuleProc->DeactivateCycle();
}
示例14: assert
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;
}
示例15: 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;
}