WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
GameDatabase.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <unordered_map>
6#include "DBDFile.h"
7
8class GameFile;
9
10namespace core
11{
14 {
15 public:
17 isKey(false),
18 needIndex(false),
19 arraySize(1),
20 id(0)
21 {
22 }
23
25 {
26 }
27
28 std::string name;
29 std::string type;
30 bool isKey;
32 unsigned int arraySize;
33 int id;
34 };
35
38 {
39 public:
41
42 virtual ~TableStructure();
43
44 std::string name;
45 std::string file;
46 std::vector<FieldStructure*> fields;
47 };
48
50 {
51 public:
53
54 bool initFromDBD(const std::string& dbdDir, const std::string& buildVersion);
55 bool initFromDBD(const std::string& dbdDir, const std::string& buildVersion,
56 const std::vector<std::string>& tableNames);
57
58 void setFastMode() { m_fastMode = true; }
59 void setCachePath(const std::string& path) { m_cachePath = path; }
60 void setDbdBaseUrl(const std::string& url) { m_dbdBaseUrl = url; }
61 void setManifestUrl(const std::string& url) { m_manifestUrl = url; }
62
63 // Download and parse the DBD manifest.json to populate tableName -> fileDataID map.
64 // Call this before initFromDBD() so file data IDs are available for CASC lookups.
66
67 // Returns the db2 file data ID for a given table name, or 0 if not found.
68 int getFileDataIdForTable(const std::string& tableName) const;
69
70 virtual ~GameDatabase();
71
74
78 virtual void setFieldPos(core::FieldStructure*, int pos) = 0;
79
80 // Get the layout hash from the actual DB2 file for a given table name.
81 virtual std::string getLayoutHashForTable(const std::string& tableName) { return ""; }
82
83 protected:
84 // Build a TableStructure from a table name by parsing its DBD definition.
85 // Returns nullptr on failure.
86 core::TableStructure* buildTableStructure(const std::string& tableName);
87
88 private:
89 // Stored from initFromDBD for lazy per-table use.
90 std::string m_dbdDir;
92
94 std::string m_cachePath;
95 std::string m_dbdBaseUrl;
96 std::string m_manifestUrl;
97 std::unordered_map<std::string, int> m_tableFileDataIds;
98 };
99}
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
Describes a single field (column) in a database table.
unsigned int arraySize
virtual ~FieldStructure()
bool initFromDBD(const std::string &dbdDir, const std::string &buildVersion)
core::DBDBuild m_build
std::unordered_map< std::string, int > m_tableFileDataIds
std::string m_dbdBaseUrl
virtual core::TableStructure * createTableStructure()=0
int getFileDataIdForTable(const std::string &tableName) const
virtual core::FieldStructure * createFieldStructure()=0
virtual std::string getLayoutHashForTable(const std::string &tableName)
core::TableStructure * buildTableStructure(const std::string &tableName)
virtual void readSpecificFieldAttributesFromDBD(const core::DBDVersionField &, const core::DBDColumnDef &, core::FieldStructure *)=0
void setManifestUrl(const std::string &url)
std::string m_dbdDir
void setDbdBaseUrl(const std::string &url)
bool downloadAndParseManifest()
virtual void setFieldPos(core::FieldStructure *, int pos)=0
std::string m_manifestUrl
std::string m_cachePath
virtual void readSpecificTableAttributesFromDBD(const core::DBDVersionDef &, core::TableStructure *)=0
void setCachePath(const std::string &path)
Describes the schema of a database table (name, file path, fields).
std::vector< FieldStructure * > fields
Common string utility functions (split, case-insensitive search, etc.).
Definition GameLoader.h:11