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

a singleton data container for communication string lookup. More...

#include "EVEMarshalStringTable.h"

Inheritance diagram for MarshalStringTable:
Collaboration diagram for MarshalStringTable:

Public Member Functions

 MarshalStringTable ()
 
uint8 LookupIndex (const std::string &str)
 lookup a index nr using a string More...
 
uint8 LookupIndex (const char *str)
 lookup a index nr using a string More...
 
const char * LookupString (uint8 index)
 lookup a string using a index More...
 
- Public Member Functions inherited from Singleton< MarshalStringTable >
 Singleton ()
 Primary constructor. More...
 

Private Types

typedef std::unordered_map
< uint32, uint8
StringTableMap
 
typedef StringTableMap::iterator StringTableMapItr
 
typedef
StringTableMap::const_iterator 
StringTableMapConstItr
 

Private Member Functions

uint32 hash (const char *str)
 djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 

Private Attributes

StringTableMap mStringTableMap
 

Static Private Attributes

static const char *const s_mStringTable []
 
static const size_t s_mStringTableSize = sizeof( MarshalStringTable::s_mStringTable ) / sizeof( const char* )
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< MarshalStringTable >
static MarshalStringTableget ()
 
- Static Protected Attributes inherited from Singleton< MarshalStringTable >
static std::shared_ptr
< MarshalStringTable
mInstance
 

Detailed Description

a singleton data container for communication string lookup.

this class is a data container for communication string lookup. eventually this class should be available to every thread the unmarshal's. so only until we have solved the entire mess.. this is a singleton with mutex locks.

Todo:
when the object puzzle is solved this class should be available to every thread. it doesn't take much mem. So it means the mutexes can be removed when every thread has its own resource.
Author
Captnoord
Date
December 2008

Definition at line 47 of file EVEMarshalStringTable.h.

Member Typedef Documentation

typedef std::unordered_map<uint32, uint8> MarshalStringTable::StringTableMap
private

Definition at line 99 of file EVEMarshalStringTable.h.

typedef StringTableMap::const_iterator MarshalStringTable::StringTableMapConstItr
private

Definition at line 101 of file EVEMarshalStringTable.h.

typedef StringTableMap::iterator MarshalStringTable::StringTableMapItr
private

Definition at line 100 of file EVEMarshalStringTable.h.

Constructor & Destructor Documentation

MarshalStringTable::MarshalStringTable ( )

Definition at line 290 of file EVEMarshalStringTable.cpp.

References hash(), LookupString(), mStringTableMap, and s_mStringTableSize.

291 {
292  for( uint8 i = 1; i <= s_mStringTableSize; i++ )
293  mStringTableMap.insert( std::make_pair( hash( LookupString( i ) ), i ) );
294 }
unsigned __int8 uint8
Definition: eve-compat.h:46
static const size_t s_mStringTableSize
StringTableMap mStringTableMap
const char * LookupString(uint8 index)
lookup a string using a index
uint32 hash(const char *str)
djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified ...

Here is the call graph for this function:

Member Function Documentation

uint32 MarshalStringTable::hash ( const char *  str)
inlineprivate

djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
djb2 has of the string.

Definition at line 88 of file EVEMarshalStringTable.h.

Referenced by LookupIndex(), and MarshalStringTable().

89  {
90  uint32 hash = 5381;
91  int c;
92 
93  while( ( c = *str++ ) )
94  hash = ( ( hash << 5 ) + hash ) + c; /* hash * 33 + c */
95 
96  return hash;
97  }
unsigned __int32 uint32
Definition: eve-compat.h:50
uint32 hash(const char *str)
djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified ...

Here is the caller graph for this function:

uint8 MarshalStringTable::LookupIndex ( const std::string &  str)

lookup a index nr using a string

Parameters
[in]stringthat needs a lookup for a index nr.
Returns
the index number of the string that was given; STRING_TABLE_ERROR if string is not found.

Definition at line 297 of file EVEMarshalStringTable.cpp.

298 {
299  return LookupIndex( str.c_str() );
300 }
uint8 LookupIndex(const std::string &str)
lookup a index nr using a string
uint8 MarshalStringTable::LookupIndex ( const char *  str)

lookup a index nr using a string

Parameters
[in]stringthat needs a lookup for a index nr.
Returns
the index number of the string that was given; STRING_TABLE_ERROR if string is not found.

Definition at line 303 of file EVEMarshalStringTable.cpp.

References hash(), mStringTableMap, and STRING_TABLE_ERROR.

304 {
305  StringTableMapConstItr res = mStringTableMap.find( hash( str ) );
306  if( mStringTableMap.end() == res )
307  return STRING_TABLE_ERROR;
308 
309  return res->second;
310 }
StringTableMap::const_iterator StringTableMapConstItr
StringTableMap mStringTableMap
#define STRING_TABLE_ERROR
uint32 hash(const char *str)
djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified ...

Here is the call graph for this function:

const char * MarshalStringTable::LookupString ( uint8  index)

lookup a string using a index

Parameters
[in]indexis the index of the string that needs to be looked up.
Returns
if succeeds returns pointer to static string; if fails returns NULL.

Definition at line 312 of file EVEMarshalStringTable.cpp.

References s_mStringTable, and s_mStringTableSize.

Referenced by MarshalStringTable().

313 {
314  if( --index < s_mStringTableSize )
315  return s_mStringTable[ index ];
316  else
317  return nullptr;
318 }
static const size_t s_mStringTableSize
static const char *const s_mStringTable[]

Here is the caller graph for this function:

Member Data Documentation

StringTableMap MarshalStringTable::mStringTableMap
private

Definition at line 103 of file EVEMarshalStringTable.h.

Referenced by LookupIndex(), and MarshalStringTable().

const char *const MarshalStringTable::s_mStringTable
staticprivate
Note
this list should only be updated by running the following script within client context (thanks comet0)
import blue values = sorted(blue.marshal.stringTable, key=blue.marshal.stringTable.get) for i in values:

print ' "%s", ' % (i)

Definition at line 106 of file EVEMarshalStringTable.h.

Referenced by LookupString().

const size_t MarshalStringTable::s_mStringTableSize = sizeof( MarshalStringTable::s_mStringTable ) / sizeof( const char* )
staticprivate

Definition at line 109 of file EVEMarshalStringTable.h.

Referenced by LookupString(), and MarshalStringTable().


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