EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyDumpVisitor.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur, mmcs
24 */
25 
26 #ifndef __PYDUMPVISITOR_H_INCL__
27 #define __PYDUMPVISITOR_H_INCL__
28 
29 #include "python/PyVisitor.h"
30 
32 {
33 public:
34  PyDumpVisitor( const char* pfx = "", bool full_nested = false );
35 
36  bool fullNested() const { return mFullNested; }
37 
38 protected:
39  // Output functions
40  virtual void _print( const char* fmt, ... ) = 0;
41  virtual void _dump( const char* pfx, const uint8* data, size_t len ) = 0;
42 
44  bool VisitInteger( const PyInt* rep );
45  bool VisitLong( const PyLong* rep );
46  bool VisitReal( const PyFloat* rep );
47  bool VisitBoolean( const PyBool* rep );
48  bool VisitNone( const PyNone* rep );
49  bool VisitBuffer( const PyBuffer* rep );
50  bool VisitString( const PyString* rep );
51  bool VisitWString( const PyWString* rep );
52  bool VisitToken( const PyToken* rep );
53 
55  bool VisitTuple( const PyTuple* rep );
56  bool VisitList( const PyList* rep );
57  bool VisitDict( const PyDict* rep );
58 
60  bool VisitObject( const PyObject* rep );
61  bool VisitObjectEx( const PyObjectEx* rep );
63  bool VisitPackedRow( const PyPackedRow* rep );
65  bool VisitSubStruct( const PySubStruct* rep );
66  bool VisitSubStream( const PySubStream* rep );
67  bool VisitChecksumedStream( const PyChecksumedStream* rep );
68 
69 private:
70  const bool mFullNested;
71 };
72 
74 {
75 public:
76  PyLogDumpVisitor( LogType log_type, LogType log_hex_type, const char* pfx = "", bool full_nested = false, bool full_hex = false );
77 
78  bool fullHex() const { return mFullHex; }
79 
80  LogType logType() const { return mLogType; }
81  LogType logHexType() const { return mLogHexType; }
82 
83 protected:
84  void _print( const char* fmt, ... );
85  void _dump( const char* pfx, const uint8* data, size_t len );
86 
87 private:
88  const bool mFullHex;
89 
92 };
93 
95 {
96 public:
97  PyFileDumpVisitor( FILE* _file, const char* pfx = "", bool full_nested = false, bool full_hex = false );
98 
99  bool fullHex() const { return mFullHex; }
100 
101  FILE* file() const { return mFile; }
102 
103 protected:
104  void _print( const char* fmt, ... );
105  void _dump( const char* pfx, const uint8* data, size_t len );
106 
107 private:
108  const bool mFullHex;
109 
110  FILE* const mFile;
111 };
112 
113 #endif
114 
115 
116 
unsigned __int8 uint8
Definition: eve-compat.h:46
PyLogDumpVisitor(LogType log_type, LogType log_hex_type, const char *pfx="", bool full_nested=false, bool full_hex=false)
const bool mFullNested
Definition: PyDumpVisitor.h:70
bool VisitLong(const PyLong *rep)
bool VisitString(const PyString *rep)
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
bool fullHex() const
Definition: PyDumpVisitor.h:99
bool fullHex() const
Definition: PyDumpVisitor.h:78
bool VisitTuple(const PyTuple *rep)
the nested types Visitor
void _dump(const char *pfx, const uint8 *data, size_t len)
Python floating point number.
Definition: PyRep.h:292
Python wide string.
Definition: PyRep.h:475
bool VisitWString(const PyWString *rep)
bool VisitInteger(const PyInt *rep)
primitive data visitors
bool VisitList(const PyList *rep)
void _print(const char *fmt,...)
Python tuple.
Definition: PyRep.h:567
PyDumpVisitor(const char *pfx="", bool full_nested=false)
Python boolean.
Definition: PyRep.h:323
PyFileDumpVisitor(FILE *_file, const char *pfx="", bool full_nested=false, bool full_hex=false)
Python extended object.
Definition: PyRep.h:861
bool VisitBoolean(const PyBool *rep)
Python object.
Definition: PyRep.h:826
Python's "none".
Definition: PyRep.h:352
const LogType mLogType
Definition: PyDumpVisitor.h:90
virtual void _dump(const char *pfx, const uint8 *data, size_t len)=0
bool VisitDict(const PyDict *rep)
Python integer.
Definition: PyRep.h:231
bool VisitToken(const PyToken *rep)
bool VisitPackedRow(const PyPackedRow *rep)
PackedRow type visitor.
bool VisitNone(const PyNone *rep)
bool fullNested() const
Definition: PyDumpVisitor.h:36
void _print(const char *fmt,...)
bool VisitReal(const PyFloat *rep)
const LogType mLogHexType
Definition: PyDumpVisitor.h:91
bool VisitObjectEx(const PyObjectEx *rep)
Python token (eg. class name).
Definition: PyRep.h:522
LogType logType() const
Definition: PyDumpVisitor.h:80
LogType
Definition: logsys.h:59
const bool mFullHex
Definition: PyDumpVisitor.h:88
FILE * file() const
bool VisitSubStream(const PySubStream *rep)
Python buffer.
Definition: PyRep.h:382
Packed row.
Definition: PyRep.h:961
bool VisitChecksumedStream(const PyChecksumedStream *rep)
LogType logHexType() const
Definition: PyDumpVisitor.h:81
bool VisitObject(const PyObject *rep)
Object type visitor.
virtual void _print(const char *fmt,...)=0
bool VisitBuffer(const PyBuffer *rep)
void _dump(const char *pfx, const uint8 *data, size_t len)
const bool mFullHex
Python list.
Definition: PyRep.h:639
FILE *const mFile
bool VisitSubStruct(const PySubStruct *rep)
wrapper types Visitor
Python long integer.
Definition: PyRep.h:261