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

#include "PyLookupDump.h"

Collaboration diagram for PyLookupResolver:

Public Member Functions

bool LoadIntFile (const char *file)
 
bool LoadStringFile (const char *file)
 
const char * LookupInt (int64 value) const
 
const char * LookupString (const char *value) const
 

Protected Attributes

std::map< uint32, std::string > m_intRecords
 
std::map< std::string,
std::string > 
m_strRecords
 
std::string m_dateBuffer
 

Detailed Description

Definition at line 31 of file PyLookupDump.h.

Member Function Documentation

bool PyLookupResolver::LoadIntFile ( const char *  file)

Definition at line 65 of file PyLookupDump.cpp.

References m_intRecords, and MIN_RESOLVABLE_INT.

Referenced by main().

65  {
66  FILE *f = fopen(file, "r");
67  if(f == NULL)
68  return false;
69  char *buf = new char[10240];
70  while(fgets(buf, 10240, f)) {
71  //kill empty lines
72  if(*buf == '\n' || *buf == '\r' || *buf == '\0' || *buf == '|')
73  continue;
74  //find the first delimiter
75  char *p = buf;
76  while(*p != '|' && *p != '\0' && *p != '\n' && *p != '\r') {
77  p++;
78  }
79  if(*p == '\0' || *p == '\n' || *p == '\r')
80  continue; //didnt find it
81  *p = '\0';
82  p++;
83  if(*p == '\n' || *p == '\r' || *p == '\0')
84  continue; //skip empty values
85  //strip newline
86  char *e = p;
87  while(*e != '\0' && *e != '\n' && *e != '\r') {
88  e++;
89  }
90  *e = '\0';
91  uint32 v = strtoul(buf, NULL, 10);
92  if(v < MIN_RESOLVABLE_INT)
93  continue;
94  m_intRecords[v] = p;
95  }
96  delete[] buf;
97  fclose(f);
98  return true;
99 }
std::map< uint32, std::string > m_intRecords
Definition: PyLookupDump.h:41
static const uint32 MIN_RESOLVABLE_INT
unsigned __int32 uint32
Definition: eve-compat.h:50

Here is the caller graph for this function:

bool PyLookupResolver::LoadStringFile ( const char *  file)

Definition at line 101 of file PyLookupDump.cpp.

References m_strRecords.

Referenced by main().

101  {
102  FILE *f = fopen(file, "r");
103  if(f == NULL)
104  return false;
105  char *buf = new char[10240];
106  while(fgets(buf, 10240, f)) {
107  //kill empty lines
108  if(*buf == '\n' || *buf == '\r' || *buf == '\0' || *buf == '|')
109  continue;
110  //find the first delimiter
111  char *p = buf;
112  while(*p != '|' && *p != '\0' && *p != '\n' && *p != '\r') {
113  p++;
114  }
115  if(*p == '\0' || *p == '\n' || *p == '\r')
116  continue; //didnt find it
117  *p = '\0';
118  p++;
119  if(*p == '\n' || *p == '\r' || *p == '\0')
120  continue; //skip empty values
121  //strip newline
122  char *e = p;
123  while(*e != '\0' && *e != '\n' && *e != '\r') {
124  e++;
125  }
126  *e = '\0';
127 
128  m_strRecords[buf] = p;
129  }
130  delete[] buf;
131  fclose(f);
132  return true;
133 }
std::map< std::string, std::string > m_strRecords
Definition: PyLookupDump.h:42

Here is the caller graph for this function:

const char * PyLookupResolver::LookupInt ( int64  value) const

Definition at line 135 of file PyLookupDump.cpp.

References m_dateBuffer, m_intRecords, MIN_RESOLVABLE_INT, and Win32TimeToString().

Referenced by PyLookupDumpVisitor::VisitInteger().

135  {
136  //hackish check for win32 time looking things...
137  if(value > 127900000000000000LL && value < 130000000000000000LL) {
138  //this is not thread safe or reentrant..
140  return(m_dateBuffer.c_str());
141  }
142 
143  if(value > 0xFFFFFFFFLL || value < MIN_RESOLVABLE_INT)
144  return NULL;
145  std::map<uint32, std::string>::const_iterator res;
146  res = m_intRecords.find(uint32(value));
147  if(res == m_intRecords.end())
148  return NULL;
149  return(res->second.c_str());
150 }
std::map< uint32, std::string > m_intRecords
Definition: PyLookupDump.h:41
static const uint32 MIN_RESOLVABLE_INT
unsigned __int32 uint32
Definition: eve-compat.h:50
std::string Win32TimeToString(int64 win32t)
Definition: utils_time.cpp:59
std::string m_dateBuffer
Definition: PyLookupDump.h:43

Here is the call graph for this function:

Here is the caller graph for this function:

const char * PyLookupResolver::LookupString ( const char *  value) const

Definition at line 152 of file PyLookupDump.cpp.

References m_strRecords.

Referenced by PyLookupDumpVisitor::VisitString().

152  {
153  if(*value == '\0')
154  return NULL;
155  std::map<std::string, std::string>::const_iterator res;
156  res = m_strRecords.find(value);
157  if(res == m_strRecords.end())
158  return NULL;
159  return(res->second.c_str());
160 }
std::map< std::string, std::string > m_strRecords
Definition: PyLookupDump.h:42

Here is the caller graph for this function:

Member Data Documentation

std::string PyLookupResolver::m_dateBuffer
mutableprotected

Definition at line 43 of file PyLookupDump.h.

Referenced by LookupInt().

std::map<uint32, std::string> PyLookupResolver::m_intRecords
protected

Definition at line 41 of file PyLookupDump.h.

Referenced by LoadIntFile(), and LookupInt().

std::map<std::string, std::string> PyLookupResolver::m_strRecords
protected

Definition at line 42 of file PyLookupDump.h.

Referenced by LoadStringFile(), and LookupString().


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