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

Python wide string. More...

#include "PyRep.h"

Inheritance diagram for PyWString:
Collaboration diagram for PyWString:

Public Member Functions

 PyWString (const char *str, size_t len)
 
template<typename Iter >
 PyWString (Iter first, Iter last)
 
 PyWString (const std::string &str)
 
 PyWString (const PyString &str)
 
 PyWString (const PyWString &oth)
 
PyRepClone () const
 Clones object. More...
 
bool visit (PyVisitor &v) const
 Visits object. More...
 
const std::string & content () const
 Get the PyWString content. More...
 
size_t size () const
 Obtains length of string. 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 ~PyWString ()
 
- 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 wide string.

Stores the string encoded in UTF-8. We don't use UCS-2 because MySQL client doesn't support it.

Definition at line 475 of file PyRep.h.

Constructor & Destructor Documentation

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

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

Definition at line 476 of file PyRep.cpp.

Referenced by Clone().

477 : PyRep( PyRep::PyTypeWString ), mValue( str, len ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:514
const std::string mValue
Definition: PyRep.h:513
PyRep(PyType t)
Definition: PyRep.cpp:73

Here is the caller graph for this function:

template<typename Iter >
PyWString::PyWString ( Iter  first,
Iter  last 
)
inline

Calls std::string( Iter, Iter ).

Definition at line 1101 of file PyRep.h.

1101 : PyRep( PyRep::PyTypeWString ), mValue( first, last ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:514
const std::string mValue
Definition: PyRep.h:513
PyRep(PyType t)
Definition: PyRep.cpp:73
PyWString::PyWString ( const std::string &  str)

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

Definition at line 478 of file PyRep.cpp.

479 : PyRep( PyRep::PyTypeWString ), mValue( str ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:514
const std::string mValue
Definition: PyRep.h:513
PyRep(PyType t)
Definition: PyRep.cpp:73
PyWString::PyWString ( const PyString str)

Copy constructor.

Definition at line 481 of file PyRep.cpp.

482 : PyRep( PyRep::PyTypeWString ), mValue( str.content() ), mHashCache( -1 ) {}
int32 mHashCache
Definition: PyRep.h:514
const std::string mValue
Definition: PyRep.h:513
PyRep(PyType t)
Definition: PyRep.cpp:73
const std::string & content() const
Get the PyString content.
Definition: PyRep.h:458
PyWString::PyWString ( const PyWString oth)

Copy constructor.

Definition at line 483 of file PyRep.cpp.

int32 mHashCache
Definition: PyRep.h:514
const std::string mValue
Definition: PyRep.h:513
PyRep(PyType t)
Definition: PyRep.cpp:73
virtual PyWString::~PyWString ( )
inlineprotectedvirtual

Definition at line 512 of file PyRep.h.

512 { /* do we need to do anything here? */ }

Member Function Documentation

PyRep * PyWString::Clone ( ) const
virtual

Clones object.

Returns
Indentical copy of object.

Implements PyRep.

Definition at line 486 of file PyRep.cpp.

References PyWString().

487 {
488  return new PyWString( *this );
489 }
PyWString(const char *str, size_t len)
Definition: PyRep.cpp:476

Here is the call graph for this function:

const std::string& PyWString::content ( ) const
inline

Get the PyWString content.

Returns
the std::string reference.

Definition at line 499 of file PyRep.h.

References mValue.

Referenced by IsPrintable(), size(), PyRep::StringContent(), PyDumpVisitor::VisitWString(), and MarshalStream::VisitWString().

499 { return mValue; }
const std::string mValue
Definition: PyRep.h:513

Here is the caller graph for this function:

int32 PyWString::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 501 of file PyRep.cpp.

References mHashCache, and mValue.

502 {
503  if (mHashCache != -1 )
504  return mHashCache;
505 
506  if (mValue.length() > 0)
507  mHashCache = std::hash<std::string>{} (mValue);
508  else
509  mHashCache = 0;
510 
511  return mHashCache;
512 }
int32 mHashCache
Definition: PyRep.h:514
const std::string mValue
Definition: PyRep.h:513
size_t PyWString::size ( ) const

Obtains length of string.

Returns
Length of string in UTF-8 characters.

Definition at line 496 of file PyRep.cpp.

References content().

497 {
498  return utf8::distance( content().begin(), content().end() );
499 }
const std::string & content() const
Get the PyWString content.
Definition: PyRep.h:499

Here is the call graph for this function:

bool PyWString::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 491 of file PyRep.cpp.

References PyVisitor::VisitWString().

492 {
493  return v.VisitWString( this );
494 }
virtual bool VisitWString(const PyWString *rep)
Definition: PyVisitor.h:62

Here is the call graph for this function:

Member Data Documentation

int32 PyWString::mHashCache
mutableprotected

Definition at line 514 of file PyRep.h.

Referenced by hash().

const std::string PyWString::mValue
protected

Definition at line 513 of file PyRep.h.

Referenced by content(), and hash().


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