From e585187b248f48b3c6e9247b49fa07c6565d65e5 Mon Sep 17 00:00:00 2001 From: maximius Date: Sat, 17 Oct 2009 15:51:44 -0700 Subject: *Backed out changeset 3be01fb200a5 --HG-- branch : trunk --- src/shared/Database/DBCFileLoader.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/shared/Database/DBCFileLoader.h') 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 + 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(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(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; -- cgit v1.2.3