From e5c0576f354d2b5ecddbc1a6b94ec1bcc91cecda Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 27 Mar 2009 10:00:42 -0600 Subject: *Add and remove files. --HG-- branch : trunk --- src/shared/Database/dbcfile.h | 110 ------------------------------------------ 1 file changed, 110 deletions(-) delete mode 100644 src/shared/Database/dbcfile.h (limited to 'src/shared/Database/dbcfile.h') diff --git a/src/shared/Database/dbcfile.h b/src/shared/Database/dbcfile.h deleted file mode 100644 index e94417b4371..00000000000 --- a/src/shared/Database/dbcfile.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2005-2009 MaNGOS - * - * Copyright (C) 2008-2009 Trinity - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DBCFILE_H -#define DBCFILE_H -#include "Platform/Define.h" -#include "Utilities/ByteConverter.h" -#include - -enum -{ - FT_NA='x', //not used or unknown, 4 byte size - FT_NA_BYTE='X', //not used or unknown, byte - FT_STRING='s', //char* - FT_FLOAT='f', //float - FT_INT='i', //uint32 - FT_BYTE='b', //uint8 - FT_SORT='d', //sorted by this field, field is not included - FT_IND='n', //the same,but parsed to data - FT_LOGIC='l' //Logical (boolean) -}; - -class DBCFile -{ - public: - DBCFile(); - ~DBCFile(); - - bool Load(const char *filename, const char *fmt); - - class Record - { - public: - float getFloat(size_t field) const - { - assert(field < file.fieldCount); - float val = *reinterpret_cast(offset+file.GetOffset(field)); - EndianConvert(val); - return val; - } - uint32 getUInt(size_t field) const - { - assert(field < file.fieldCount); - uint32 val = *reinterpret_cast(offset+file.GetOffset(field)); - EndianConvert(val); - return val; - } - uint8 getUInt8(size_t field) const - { - assert(field < file.fieldCount); - return *reinterpret_cast(offset+file.GetOffset(field)); - } - - const char *getString(size_t field) const - { - assert(field < file.fieldCount); - size_t stringOffset = getUInt(field); - assert(stringOffset < file.stringSize); - return reinterpret_cast(file.stringTable + stringOffset); - } - - private: - Record(DBCFile &file_, unsigned char *offset_): offset(offset_), file(file_) {} - unsigned char *offset; - DBCFile &file; - - friend class DBCFile; - - }; - - // Get record by id - Record getRecord(size_t id); - /// Get begin iterator over records - - uint32 GetNumRows() const { return recordCount;} - uint32 GetCols() const { return fieldCount; } - uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; } - bool IsLoaded() {return (data!=NULL);} - char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable); - char* AutoProduceStrings(const char* fmt, char* dataTable); - static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL); - private: - - uint32 recordSize; - uint32 recordCount; - uint32 fieldCount; - uint32 stringSize; - uint32 *fieldsOffset; - unsigned char *data; - unsigned char *stringTable; -}; -#endif - -- cgit v1.2.3