diff options
Diffstat (limited to 'src/shared/Database/DBCFileLoader.h')
-rw-r--r-- | src/shared/Database/DBCFileLoader.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/Database/DBCFileLoader.h b/src/shared/Database/DBCFileLoader.h index fd1f5539ee3..ef29af84bc1 100644 --- a/src/shared/Database/DBCFileLoader.h +++ b/src/shared/Database/DBCFileLoader.h @@ -15,11 +15,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef DBC_FILE_LOADER_H #define DBC_FILE_LOADER_H #include "Platform/Define.h" #include "Utilities/ByteConverter.h" #include <cassert> + enum { FT_NA='x', //not used or unknown, 4 byte size @@ -34,12 +36,15 @@ enum FT_SQL_PRESENT='p', //Used in sql format to mark column present in sql dbc FT_SQL_ABSENT='a' //Used in sql format to mark column absent in sql dbc }; + class DBCFileLoader { public: DBCFileLoader(); ~DBCFileLoader(); + bool Load(const char *filename, const char *fmt); + class Record { public: @@ -62,6 +67,7 @@ class DBCFileLoader assert(field < file.fieldCount); return *reinterpret_cast<uint8*>(offset+file.GetOffset(field)); } + const char *getString(size_t field) const { assert(field < file.fieldCount); @@ -69,15 +75,20 @@ class DBCFileLoader assert(stringOffset < file.stringSize); return reinterpret_cast<char*>(file.stringTable + stringOffset); } + private: Record(DBCFileLoader &file_, unsigned char *offset_): offset(offset_), file(file_) {} unsigned char *offset; DBCFileLoader &file; + friend class DBCFileLoader; + }; + // Get record by id Record getRecord(size_t id); /// Get begin iterator over records + uint32 GetNumRows() const { return recordCount;} uint32 GetRowSize() const { return recordSize;} uint32 GetCols() const { return fieldCount; } @@ -87,6 +98,7 @@ class DBCFileLoader char* AutoProduceStrings(const char* fmt, char* dataTable); static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL); private: + uint32 recordSize; uint32 recordCount; uint32 fieldCount; |