EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyDict Class Reference

Python's dictionary. More...

#include "PyRep.h"

Inheritance diagram for PyDict:
Collaboration diagram for PyDict:

Classes

class  _comp
 
class  _hash
 

Public Types

typedef std::unordered_map
< PyRep *, PyRep *, _hash,
_comp
storage_type
 
typedef storage_type::iterator iterator
 
typedef
storage_type::const_iterator 
const_iterator
 
- Public Types inherited from PyRep
enum  PyType {
  PyTypeMin = 0, PyTypeInt = 1, PyTypeLong = 2, PyTypeFloat = 3,
  PyTypeBool = 4, PyTypeBuffer = 5, PyTypeString = 6, PyTypeWString = 7,
  PyTypeToken = 8, PyTypeTuple = 9, PyTypeList = 10, PyTypeDict = 11,
  PyTypeNone = 12, PyTypeSubStruct = 13, PyTypeSubStream = 14, PyTypeChecksumedStream = 15,
  PyTypeObject = 16, PyTypeObjectEx = 17, PyTypePackedRow = 18, PyTypeError = 19
}
 Python wire object types. More...
 

Public Member Functions

 PyDict ()
 
 PyDict (const PyDict &oth)
 
 PyDict (PyDict &&oth)=delete
 
PyDictoperator= (const PyDict &oth)
 
PyDictoperator= (PyDict &&oth)=delete
 
PyRepClone () const
 Clones object. More...
 
bool visit (PyVisitor &v) const
 Visits object. More...
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size () const
 
bool empty () const
 
void clear ()
 
PyRepGetItem (PyRep *key) const
 Obtains a database entry based on given key object. More...
 
PyRepGetItemString (const char *key) const
 Obtains database entry based on given key string. More...
 
void SetItem (PyRep *key, PyRep *value)
 SetItem adds or sets a database entry. More...
 
void SetItem (const char *key, PyRep *value)
 
void SetItem (const char *key, const char *value)
 
void SetItemString (const char *key, PyRep *value)
 SetItemString adds or sets a database entry. More...
 
- Public Member Functions inherited from PyRep
PyType GetType () const
 
bool IsInt () const
 
bool IsLong () const
 
bool IsFloat () const
 
bool IsBool () const
 
bool IsBuffer () const
 
bool IsString () const
 
bool IsWString () const
 
bool IsToken () const
 
bool IsTuple () const
 
bool IsList () const
 
bool IsDict () const
 
bool IsNone () const
 
bool IsSubStruct () const
 
bool IsSubStream () const
 
bool IsChecksumedStream () const
 
bool IsObject () const
 
bool IsObjectEx () const
 
bool IsPackedRow () const
 
const char * TypeString () const
 
PyIntAsInt ()
 
const PyIntAsInt () const
 
PyLongAsLong ()
 
const PyLongAsLong () const
 
PyFloatAsFloat ()
 
const PyFloatAsFloat () const
 
PyBoolAsBool ()
 
const PyBoolAsBool () const
 
PyBufferAsBuffer ()
 
const PyBufferAsBuffer () const
 
PyStringAsString ()
 
const PyStringAsString () const
 
PyWStringAsWString ()
 
const PyWStringAsWString () const
 
PyTokenAsToken ()
 
const PyTokenAsToken () const
 
PyTupleAsTuple ()
 
const PyTupleAsTuple () const
 
PyListAsList ()
 
const PyListAsList () const
 
PyDictAsDict ()
 
const PyDictAsDict () const
 
PyNoneAsNone ()
 
const PyNoneAsNone () const
 
PySubStructAsSubStruct ()
 
const PySubStructAsSubStruct () const
 
PySubStreamAsSubStream ()
 
const PySubStreamAsSubStream () const
 
PyChecksumedStreamAsChecksumedStream ()
 
const PyChecksumedStreamAsChecksumedStream () const
 
PyObjectAsObject ()
 
const PyObjectAsObject () const
 
PyObjectExAsObjectEx ()
 
const PyObjectExAsObjectEx () const
 
PyPackedRowAsPackedRow ()
 
const PyPackedRowAsPackedRow () const
 
void Dump (FILE *into, const char *pfx) const
 Dumps object to file. More...
 
void Dump (LogType type, const char *pfx) const
 Dumps object to console. More...
 
virtual int32 hash () const
 virtual function to generate a hash value of a object. More...
 
- Public Member Functions inherited from RefObject
 RefObject (size_t initRefCount)
 Initializes reference count. More...
 
virtual ~RefObject ()
 Destructor; must be virtual. More...
 
size_t GetCount ()
 

Public Attributes

storage_type items
 

Protected Member Functions

virtual ~PyDict ()
 
- Protected Member Functions inherited from PyRep
 PyRep (PyType t)
 
 PyRep (const PyRep &oth)
 
 PyRep (PyRep &&oth)=delete
 
PyRepoperator= (const PyRep &oth)=default
 
PyRepoperator= (PyRep &&oth)=default
 
virtual ~PyRep ()
 
- Protected Member Functions inherited from RefObject
void IncRef () const
 Increments reference count of object by one. More...
 
void DecRef () const
 Decrements reference count of object by one. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PyRep
static std::string StringContent (PyRep *pRep)
 
static int64 IntegerValue (PyRep *pRep)
 
static uint32 IntegerValueU32 (PyRep *pRep)
 
- Protected Attributes inherited from PyRep
const PyType mType
 
- Protected Attributes inherited from RefObject
size_t mRefCount
 Reference count of instance. More...
 
bool mDeleted
 

Detailed Description

Python's dictionary.

Dictionary; completely mutable associative container.

Definition at line 719 of file PyRep.h.

Member Typedef Documentation

typedef storage_type::const_iterator PyDict::const_iterator

Definition at line 750 of file PyRep.h.

typedef storage_type::iterator PyDict::iterator

Definition at line 749 of file PyRep.h.

typedef std::unordered_map<PyRep*, PyRep*, _hash, _comp> PyDict::storage_type

Definition at line 748 of file PyRep.h.

Constructor & Destructor Documentation

PyDict::PyDict ( )

Definition at line 657 of file PyRep.cpp.

Referenced by Clone().

657 : PyRep( PyRep::PyTypeDict ), items() { }
storage_type items
Definition: PyRep.h:814
PyRep(PyType t)
Definition: PyRep.cpp:73

Here is the caller graph for this function:

PyDict::PyDict ( const PyDict oth)

Definition at line 658 of file PyRep.cpp.

658 : PyRep( PyRep::PyTypeDict ), items(oth.items) { }
storage_type items
Definition: PyRep.h:814
PyRep(PyType t)
Definition: PyRep.cpp:73
PyDict::PyDict ( PyDict &&  oth)
delete
PyDict::~PyDict ( )
protectedvirtual

Definition at line 660 of file PyRep.cpp.

661 {
662  /*
663  for (auto cur : items) {
664  PyDecRef(cur.first);
665  PySafeDecRef(cur.second);
666  }
667  */
668 }

Member Function Documentation

void PyDict::clear ( )

Definition at line 680 of file PyRep.cpp.

References items, PyDecRef, and PySafeDecRef.

Referenced by Colony::GetPins(), and operator=().

681 {
682  iterator cur = items.begin();
683  for (; cur != items.end(); ++cur) {
684  PyDecRef( cur->first );
685  PySafeDecRef( cur->second );
686  }
687 
688  items.clear();
689 }
storage_type::iterator iterator
Definition: PyRep.h:749
storage_type items
Definition: PyRep.h:814
#define PyDecRef(op)
Definition: PyRep.h:57
#define PySafeDecRef(op)
Definition: PyRep.h:61

Here is the caller graph for this function:

PyRep * PyDict::Clone ( ) const
virtual

Clones object.

Returns
Indentical copy of object.

Implements PyRep.

Definition at line 670 of file PyRep.cpp.

References PyDict().

Referenced by PyPacket::Clone(), and PyCallStream::Clone().

671 {
672  return new PyDict( *this );
673 }
PyDict()
Definition: PyRep.cpp:657

Here is the call graph for this function:

Here is the caller graph for this function:

bool PyDict::empty ( ) const
inline

Definition at line 770 of file PyRep.h.

References items.

Referenced by Scan::RequestScans(), PyDumpVisitor::VisitDict(), and PyDumpVisitor::VisitObjectEx().

770 { return items.empty(); }
storage_type items
Definition: PyRep.h:814

Here is the caller graph for this function:

PyRep * PyDict::GetItem ( PyRep key) const

Obtains a database entry based on given key object.

Parameters
[in]keyis the key object of the database entry.
Returns
Desired database entry.

Definition at line 691 of file PyRep.cpp.

References items.

Referenced by GetItemString(), CIndexedRowSet::GetRow(), and CFilterRowSet::GetRowset().

692 {
693  assert( key != nullptr );
694 
695  const_iterator res = items.find( key );
696  if (res == items.end() )
697  return nullptr;
698 
699  return res->second;
700 }
storage_type items
Definition: PyRep.h:814
storage_type::const_iterator const_iterator
Definition: PyRep.h:750

Here is the caller graph for this function:

PyRep * PyDict::GetItemString ( const char *  key) const

Obtains database entry based on given key string.

Parameters
[in]keyis the key string of the database entry.
Returns
Desired database entry.

Definition at line 702 of file PyRep.cpp.

References GetItem(), and PyDecRef.

Referenced by UserError::_GetDictKeywords(), ClientSession::_GetValueTuple(), CorporationDB::AddVoteCase(), CharacterAppearance::Build(), and CharacterPortrait::Build().

703 {
704  assert( key != nullptr );
705 
706  PyString* str = new PyString( key );
707  PyRep* res = GetItem( str );
708  PyDecRef( str );
709 
710  return res;
711 }
Base Python wire object.
Definition: PyRep.h:66
Python string.
Definition: PyRep.h:430
PyRep * GetItem(PyRep *key) const
Obtains a database entry based on given key object.
Definition: PyRep.cpp:691
#define PyDecRef(op)
Definition: PyRep.h:57
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr

Here is the call graph for this function:

Here is the caller graph for this function:

PyDict & PyDict::operator= ( const PyDict oth)

Definition at line 743 of file PyRep.cpp.

References begin(), clear(), end(), and SetItem().

744 {
745  clear();
746  const_iterator cur = oth.begin(), end = oth.end();
747  for (; cur != end; ++cur) {
748  if (cur->second == nullptr )
749  SetItem( cur->first->Clone(), nullptr );
750  else
751  SetItem( cur->first->Clone(), cur->second->Clone() );
752  }
753 
754  return *this;
755 }
void clear()
Definition: PyRep.cpp:680
const_iterator begin() const
Definition: PyRep.h:766
storage_type::const_iterator const_iterator
Definition: PyRep.h:750
const_iterator end() const
Definition: PyRep.h:767
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713

Here is the call graph for this function:

PyDict& PyDict::operator= ( PyDict &&  oth)
delete
void PyDict::SetItem ( PyRep key,
PyRep value 
)

SetItem adds or sets a database entry.

PyDict::SetItem handles the adding and setting of object in mapped and non mapped python dictionary's.

Parameters
[in]keycontains the key object which the value needs to be filed under.
[in]valueis the object that needs to be filed under key.

Definition at line 713 of file PyRep.cpp.

References PyRep::hash(), items, PyDecRef, PySafeDecRef, and PyStatic.

Referenced by TradeBound::CancelTrade(), DBResultToIndexRowset(), DBResultToIntIntDict(), DBResultToIntRowDict(), DBResultToPackedRowDict(), ClientSession::EncodeChanges(), ClientSession::EncodeInitialState(), FleetService::GetAvailableFleets(), ShipItem::GetChargeState(), Character::GetCharInfo(), Colony::GetColony(), MapDB::GetDynamicData(), PlanetSE::GetExtractorsForPlanet(), FactionWarMgrDB::GetFacWarSystems(), MailDB::GetJoinedMailingLists(), MailDB::GetLabels(), ShipItem::GetLinkedWeapons(), Colony::GetLinks(), MailDB::GetMailingListMembers(), Colony::GetPins(), PlanetSE::GetPlanetInfo(), PlanetSE::GetPlanetResourceInfo(), Character::GetRAMSkills(), Colony::GetRoutes(), ShipItem::GetShipInfo(), ShipItem::GetShipState(), CorporationDB::GetTitles(), FleetService::GetWings(), UnmarshalStream::LoadDict(), UnmarshalStream::LoadObjectEx(), MailDB::MailingListGetSettings(), WreckSE::MakeSlimItem(), CIndexedRowSet::NewRow(), CFilterRowSet::NewRowset(), operator=(), ServiceDB::PrimeOwners(), Scan::ProbeScanResult(), SearchDB::Query(), StaticDataMgr::SetBPMatlType(), SetItemString(), Scan::SystemScanStarted(), and ShipItem::UnlinkWeapon().

714 {
715  if ( key == nullptr )
716  return;
717 
718  /* note: add check if the key object is hashable
719  * if not ( it will return -1 ) return false;
720  */
721  if (key->hash() == -1)
722  return;
723 
724  /* check if we need to replace a dictionary entry */
725  iterator itr = items.find( key );
726  if (itr == items.end()) {
727  // Keep both key & value (make_pair makes copy of args passed)
728  items.insert( std::make_pair( key, value ) );
729  } else {
730  // We found 'key' in current dict, so use itr->first and decRef 'key'.
731  // is this right?
732  PyDecRef( key );
733  // Replace itr->second with new value.
734  PySafeDecRef( itr->second );
735  if (value == nullptr)
736  itr->second = PyStatic.NewNone();
737  else
738  itr->second = value;
739  }
740 }
storage_type::iterator iterator
Definition: PyRep.h:749
storage_type items
Definition: PyRep.h:814
#define PyStatic
Definition: PyRep.h:1209
virtual int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:96
#define PyDecRef(op)
Definition: PyRep.h:57
#define PySafeDecRef(op)
Definition: PyRep.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

void PyDict::SetItem ( const char *  key,
PyRep value 
)
inline

Definition at line 800 of file PyRep.h.

References SetItem().

Referenced by SetItem().

800 { SetItem(new PyString(key), value); }
Python string.
Definition: PyRep.h:430
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713

Here is the call graph for this function:

Here is the caller graph for this function:

void PyDict::SetItem ( const char *  key,
const char *  value 
)
inline

Definition at line 801 of file PyRep.h.

References SetItem().

Referenced by SetItem().

801 { SetItem(new PyString(key), new PyString(value)); }
Python string.
Definition: PyRep.h:430
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713

Here is the call graph for this function:

Here is the caller graph for this function:

void PyDict::SetItemString ( const char *  key,
PyRep value 
)
inline

SetItemString adds or sets a database entry.

PyDict::SetItemString handles the adding and setting of object in mapped and non mapped python dictionary's.

Parameters
[in]keycontains the key string which the value needs to be filed under.
[in]valueis the object that needs to be filed under key.

Definition at line 812 of file PyRep.h.

References SetItem().

Referenced by GPSTransportClosed::_CreateKeywords(), CRowSet::_CreateKeywords(), CIndexedRowSet::_CreateKeywords(), CFilterRowSet::_CreateKeywords(), UserError::_CreateKeywords(), ClientSession::_Set(), GPSTransportClosed::AddKeyword(), UserError::AddKeyword(), FleetService::AddMember(), SystemEntity::ApplyDamage(), PyServiceMgr::BindObject(), ClientSession::ClientSession(), DBResultToIndexRowset(), DBResultToRowset(), DBRowToKeyVal(), DBRowToRow(), MiningLaser::Depleted(), SovereigntyDataMgr::GetAllianceSystems(), BookmarkDB::GetBookmarks(), BookmarkDB::GetBookmarksInFolder(), SystemManager::GetCurrentEntities(), TowerSE::GetDeployFlags(), SystemBubble::GetDroneState(), CalendarDB::GetEventDetails(), CalendarDB::GetEventList(), FactionWarMgrDB::GetFacWarSystems(), BookmarkDB::GetFolders(), Agent::GetInfoServiceDetails(), MailDB::GetJoinedMailingLists(), Agent::GetLocationWrap(), MarketDB::GetMarketGroups(), AgentBound::GetMissionObjectiveInfo(), AgentBound::GetMissionObjectives(), CharacterDB::GetRespecInfo(), CalendarDB::GetResponsesForCharacter(), CalendarDB::GetResponsesToEvent(), CustomsSE::GetSettingsInfo(), SovereigntyDataMgr::GetSystemSovereignty(), CorporationDB::GetTitles(), TowerSE::GetUsageFlagList(), AccountDB::GetWalletDivisionsInfo(), PyServiceMgr::Initalize(), ObjCacheService::InsertCacheHints(), StationDataMgr::LoadStationPyData(), MailDB::MailingListGetSettings(), CustomsSE::MakeSlimItem(), StructureSE::MakeSlimItem(), WreckSE::MakeSlimItem(), SBUSE::MarkContested(), ServiceDB::ProcessIntChange(), ServiceDB::ProcessLongChange(), ServiceDB::ProcessRealChange(), ServiceDB::ProcessStringChange(), Prospector::SendFailure(), ProbeSE::SendNewProbe(), Client::SendNotification(), ProbeSE::SendSlimChange(), CustomsSE::SendSlimUpdate(), StructureSE::SendSlimUpdate(), StaticDataMgr::SetBPMatlType(), TCUSE::SetOnline(), ActiveModule::ShowEffect(), Colony::TransferCommodities(), DestinyManager::UpdateNewShip(), DestinyManager::UpdateOldShip(), and FleetService::UpdateOptions().

812 { SetItem( new PyString( key ), value ); }
Python string.
Definition: PyRep.h:430
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713

Here is the call graph for this function:

size_t PyDict::size ( ) const
inline

Definition at line 769 of file PyRep.h.

References items.

Referenced by CFilterRowSet::GetKeyCount(), Scan::RequestScans(), PyDumpVisitor::VisitDict(), and MarshalStream::VisitDict().

769 { return items.size(); }
storage_type items
Definition: PyRep.h:814

Here is the caller graph for this function:

bool PyDict::visit ( PyVisitor v) const
virtual

Visits object.

Parameters
[in]vVisitor to be used for visiting.
Return values
trueVisit successful.
falseError during visit.

Implements PyRep.

Definition at line 675 of file PyRep.cpp.

References PyVisitor::VisitDict().

Referenced by PyPacket::Dump(), and PyCallStream::Dump().

676 {
677  return v.VisitDict( this );
678 }
virtual bool VisitDict(const PyDict *rep)
Definition: PyVisitor.cpp:57

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

storage_type PyDict::items

Definition at line 814 of file PyRep.h.

Referenced by begin(), clear(), empty(), end(), GetItem(), SetItem(), and size().


The documentation for this class was generated from the following files: