TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Tokenizer Class Reference

#include <Util.h>

Public Types

typedef std::vector< char const * > StorageType
 
typedef StorageType::size_type size_type
 
typedef StorageType::const_iterator const_iterator
 
typedef StorageType::reference reference
 
typedef
StorageType::const_reference 
const_reference
 

Public Member Functions

 Tokenizer (const std::string &src, char const sep, uint32 vectorReserve=0)
 
 ~Tokenizer ()
 
const_iterator begin () const
 
const_iterator end () const
 
size_type size () const
 
reference operator[] (size_type i)
 
const_reference operator[] (size_type i) const
 

Private Attributes

char * m_str
 
StorageType m_storage
 

Member Typedef Documentation

typedef StorageType::const_iterator Tokenizer::const_iterator
typedef StorageType::const_reference Tokenizer::const_reference
typedef StorageType::reference Tokenizer::reference
typedef StorageType::size_type Tokenizer::size_type
typedef std::vector<char const*> Tokenizer::StorageType

Constructor & Destructor Documentation

Tokenizer::Tokenizer ( const std::string &  src,
char const  sep,
uint32  vectorReserve = 0 
)
34 {
35  m_str = new char[src.length() + 1];
36  memcpy(m_str, src.c_str(), src.length() + 1);
37 
38  if (vectorReserve)
39  m_storage.reserve(vectorReserve);
40 
41  char* posold = m_str;
42  char* posnew = m_str;
43 
44  for (;;)
45  {
46  if (*posnew == sep)
47  {
48  m_storage.push_back(posold);
49  posold = posnew + 1;
50 
51  *posnew = '\0';
52  }
53  else if (*posnew == '\0')
54  {
55  // Hack like, but the old code accepted these kind of broken strings,
56  // so changing it would break other things
57  if (posold != posnew)
58  m_storage.push_back(posold);
59 
60  break;
61  }
62 
63  ++posnew;
64  }
65 }
char * m_str
Definition: Util.h:69
StorageType m_storage
Definition: Util.h:70
Tokenizer::~Tokenizer ( )
inline
58 { delete[] m_str; }
char * m_str
Definition: Util.h:69

Member Function Documentation

const_iterator Tokenizer::begin ( ) const
inline
60 { return m_storage.begin(); }
StorageType m_storage
Definition: Util.h:70

+ Here is the caller graph for this function:

const_iterator Tokenizer::end ( ) const
inline
61 { return m_storage.end(); }
StorageType m_storage
Definition: Util.h:70

+ Here is the caller graph for this function:

reference Tokenizer::operator[] ( size_type  i)
inline
65 { return m_storage[i]; }
StorageType m_storage
Definition: Util.h:70
const_reference Tokenizer::operator[] ( size_type  i) const
inline
66 { return m_storage[i]; }
StorageType m_storage
Definition: Util.h:70
size_type Tokenizer::size ( ) const
inline
63 { return m_storage.size(); }
StorageType m_storage
Definition: Util.h:70

+ Here is the caller graph for this function:

Member Data Documentation

StorageType Tokenizer::m_storage
private
char* Tokenizer::m_str
private

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