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

#include <loadlib.h>

Public Member Functions

 FileChunk (uint8 *data_, uint32 size_)
 
 ~FileChunk ()
 
template<class T >
T * As ()
 
void parseSubChunks ()
 
FileChunkGetSubChunk (std::string const &name)
 

Public Attributes

uint8data
 
uint32 size
 
std::multimap< std::string,
FileChunk * > 
subchunks
 

Constructor & Destructor Documentation

FileChunk::FileChunk ( uint8 data_,
uint32  size_ 
)
inline
67 : data(data_), size(size_) { }
uint8 * data
Definition: loadlib.h:70
uint32 size
Definition: loadlib.h:71

+ Here is the caller graph for this function:

FileChunk::~FileChunk ( )
150 {
151  for (auto subchunk : subchunks)
152  delete subchunk.second;
153 
154  subchunks.clear();
155 }
std::multimap< std::string, FileChunk * > subchunks
Definition: loadlib.h:76

Member Function Documentation

template<class T >
T* FileChunk::As ( )
inline
74 { return (T*)data; }
uint8 * data
Definition: loadlib.h:70

+ Here is the caller graph for this function:

FileChunk * FileChunk::GetSubChunk ( std::string const name)
185 {
186  auto range = subchunks.equal_range(name);
187  if (std::distance(range.first, range.second) == 1)
188  return range.first->second;
189 
190  return NULL;
191 }
arena_t NULL
Definition: jemalloc_internal.h:624
double distance(double x, double y)
Definition: g3dmath.h:731
std::multimap< std::string, FileChunk * > subchunks
Definition: loadlib.h:76

+ Here is the call graph for this function:

void FileChunk::parseSubChunks ( )
158 {
159  uint8* ptr = data + 8; // skip self
160  while (ptr < data + size)
161  {
162  u_map_fcc header = *(u_map_fcc*)ptr;
163  if (IsInterestingChunk(header))
164  {
165  uint32 subsize = *(uint32*)(ptr + 4);
166  if (subsize < size)
167  {
168  std::swap(header.fcc_txt[0], header.fcc_txt[3]);
169  std::swap(header.fcc_txt[1], header.fcc_txt[2]);
170 
171  FileChunk* chunk = new FileChunk(ptr, subsize);
172  chunk->parseSubChunks();
173  subchunks.insert({ std::string(header.fcc_txt, 4), chunk });
174  }
175 
176  // move to next chunk
177  ptr += subsize + 8;
178  }
179  else
180  ++ptr;
181  }
182 }
Definition: loadlib.h:38
bool IsInterestingChunk(u_map_fcc const &fcc)
Definition: loadlib.cpp:103
Definition: adtfile.h:57
void parseSubChunks()
Definition: loadlib.cpp:157
uint32_t uint32
Definition: Define.h:150
uint8 * data
Definition: loadlib.h:70
Definition: loadlib.h:64
std::multimap< std::string, FileChunk * > subchunks
Definition: loadlib.h:76
uint32 size
Definition: loadlib.h:71
uint8_t uint8
Definition: Define.h:152
FileChunk(uint8 *data_, uint32 size_)
Definition: loadlib.h:67
char fcc_txt[4]
Definition: loadlib.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint8* FileChunk::data
uint32 FileChunk::size
std::multimap<std::string, FileChunk*> FileChunk::subchunks

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