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

Python string. More...

#include "PyRep.h"

Inheritance diagram for PyString:
Collaboration diagram for PyString:

Public Member Functions

 PyString (const char *str)
 
 PyString (const char *str, size_t len)
 
template<typename Iter >
 PyString (Iter first, Iter last)
 
 PyString (const std::string &str)
 
 PyString (const PyBuffer &buf)
 
 PyString (const PyToken &token)
 
 PyString (const PyString &oth)
 
PyRepClone () const
 Clones object. More...
 
bool visit (PyVisitor &v) const
 Visits object. More...
 
const std::string & content () const
 Get the PyString content. More...
 
int32 hash () const
 virtual function to generate a hash value of a object. 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...
 
- Public Member Functions inherited from RefObject
 RefObject (size_t initRefCount)
 Initializes reference count. More...
 
virtual ~RefObject ()
 Destructor; must be virtual. More...
 
size_t GetCount ()
 

Protected Member Functions

virtual ~PyString ()
 
- 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...
 

Protected Attributes

const std::string mValue
 
int32 mHashCache
 
- Protected Attributes inherited from PyRep
const PyType mType
 
- Protected Attributes inherited from RefObject
size_t mRefCount
 Reference count of instance. More...
 
bool mDeleted
 

Additional Inherited Members

- 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...
 
- Static Public Member Functions inherited from PyRep
static std::string StringContent (PyRep *pRep)
 
static int64 IntegerValue (PyRep *pRep)
 
static uint32 IntegerValueU32 (PyRep *pRep)
 

Detailed Description

Python string.

Usual string.

Definition at line 430 of file PyRep.h.

Constructor & Destructor Documentation

PyString::PyString ( const char *  str)

Calls std::string( const char* ).

Definition at line 430 of file PyRep.cpp.

Referenced by Clone().

431 : PyRep( PyRep::PyTypeString ), mValue( str ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
PyRep(PyType t)
Definition: PyRep.cpp:73

Here is the caller graph for this function:

PyString::PyString ( const char *  str,
size_t  len 
)

Calls std::string( const char*, size_t ).

Definition at line 432 of file PyRep.cpp.

433 : PyRep( PyRep::PyTypeString ), mValue( str, len ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
PyRep(PyType t)
Definition: PyRep.cpp:73
template<typename Iter >
PyString::PyString ( Iter  first,
Iter  last 
)
inline

Calls std::string( Iter, Iter ).

Definition at line 1099 of file PyRep.h.

1099 : PyRep( PyRep::PyTypeString ), mValue( first, last ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
PyRep(PyType t)
Definition: PyRep.cpp:73
PyString::PyString ( const std::string &  str)

Calls std::string( const std::string& ).

Definition at line 434 of file PyRep.cpp.

435 : PyRep( PyRep::PyTypeString ), mValue( str ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
PyRep(PyType t)
Definition: PyRep.cpp:73
PyString::PyString ( const PyBuffer buf)

Copy constructor.

Definition at line 437 of file PyRep.cpp.

438 : PyRep( PyRep::PyTypeString ), mValue( (const char *) &buf.content()[0], buf.content().size() ), mHashCache( -1 ) {}
const Buffer & content() const
Get the const PyBuffer content.
Definition: PyRep.h:407
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
size_type size() const
Definition: Buffer.h:610
PyRep(PyType t)
Definition: PyRep.cpp:73
PyString::PyString ( const PyToken token)

Copy constructor.

Definition at line 439 of file PyRep.cpp.

440 : PyRep( PyRep::PyTypeString ), mValue( token.content() ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
const std::string & content() const
Obtain token.
Definition: PyRep.h:555
PyRep(PyType t)
Definition: PyRep.cpp:73
PyString::PyString ( const PyString oth)

Copy constructor.

Definition at line 441 of file PyRep.cpp.

int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465
PyRep(PyType t)
Definition: PyRep.cpp:73
PyString::~PyString ( )
protectedvirtual

Definition at line 444 of file PyRep.cpp.

445 {
446  // how do we determine whether to `delete` a const char* or just clear a `std::string&`?
447  // either way, valgrind shows this leaking on most calls, probably after Clone().
448 }

Member Function Documentation

PyRep * PyString::Clone ( ) const
virtual

Clones object.

Returns
Indentical copy of object.

Implements PyRep.

Definition at line 450 of file PyRep.cpp.

References PyString().

451 {
452  return new PyString( *this );
453 }
PyString(const char *str)
Definition: PyRep.cpp:430

Here is the call graph for this function:

const std::string& PyString::content ( ) const
inline
int32 PyString::hash ( ) const
virtual

virtual function to generate a hash value of a object.

virtual function to generate a hash value of a object to facilitate the various maps and checks.

Returns
returns a uint32 containing a hash function that represents the object.

Reimplemented from PyRep.

Definition at line 460 of file PyRep.cpp.

References mHashCache, and mValue.

Referenced by DBRowDescriptor::FindColumn().

461 {
462  if (mHashCache != -1 )
463  return mHashCache;
464 
465  if (mValue.length() > 0)
466  mHashCache = std::hash<std::string>{} (mValue);
467  else
468  mHashCache = 0;
469 
470  return mHashCache;
471 }
int32 mHashCache
Definition: PyRep.h:466
const std::string mValue
Definition: PyRep.h:465

Here is the caller graph for this function:

bool PyString::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 455 of file PyRep.cpp.

References PyVisitor::VisitString().

Referenced by PyDumpVisitor::VisitObject(), and PyVisitor::VisitObject().

456 {
457  return v.VisitString( this );
458 }
virtual bool VisitString(const PyString *rep)
Definition: PyVisitor.h:61

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

int32 PyString::mHashCache
mutableprotected

Definition at line 466 of file PyRep.h.

Referenced by hash().

const std::string PyString::mValue
protected

Definition at line 465 of file PyRep.h.

Referenced by content(), and hash().


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