|
1 | | -#ifndef ESPFILE_H |
2 | | -#define ESPFILE_H |
3 | | - |
4 | | -#include "record.h" |
5 | | -#include "tes3record.h" |
6 | | -#include <fstream> |
7 | | -#include <set> |
8 | | -#include <string> |
9 | | - |
10 | | -namespace ESP |
11 | | -{ |
12 | | - |
13 | | -class SubRecord; |
14 | | - |
15 | | -class File |
16 | | -{ |
17 | | -public: |
18 | | - File(const std::string& fileName); |
19 | | - File(const std::wstring& fileName); |
20 | | - |
21 | | - Record readRecord(); |
22 | | - |
23 | | - bool isMaster() const; |
24 | | - bool isLight(bool overlaySupport = false) const; |
25 | | - bool isMedium() const; |
26 | | - bool isOverlay() const; |
27 | | - bool isBlueprint() const; |
28 | | - bool isDummy() const; |
29 | | - uint16_t formVersion() const { return m_MainRecord.formVersion(); }; |
30 | | - float headerVersion() const { return m_Header.version; } |
31 | | - std::string author() const { return m_Author; } |
32 | | - std::string description() const { return m_Description; } |
33 | | - std::set<std::string> masters() const { return m_Masters; } |
34 | | - |
35 | | -private: |
36 | | - void init(); |
37 | | - |
38 | | - void onHEDR(const SubRecord& rec); |
39 | | - void onMAST(const SubRecord& rec); |
40 | | - void onCNAM(const SubRecord& rec); |
41 | | - void onSNAM(const SubRecord& rec); |
42 | | - |
43 | | -private: |
44 | | - std::ifstream m_File; |
45 | | - |
46 | | - struct |
47 | | - { |
48 | | - float version; |
49 | | - int32_t numRecords; |
50 | | - uint32_t nextObjectId; |
51 | | - } m_Header; |
52 | | - |
53 | | - struct |
54 | | - { |
55 | | - float version; |
56 | | - uint32_t unknown; |
57 | | - char author[32]; |
58 | | - char description[256]; |
59 | | - uint32_t numRecords; |
60 | | - } m_TES3Header; |
61 | | - |
62 | | - Record m_MainRecord; |
63 | | - |
64 | | - std::string m_Author; |
65 | | - std::string m_Description; |
66 | | - |
67 | | - std::set<std::string> m_Masters; |
68 | | -}; |
69 | | - |
70 | | -} // namespace ESP |
71 | | - |
72 | | -#endif // ESPFILE_H |
| 1 | +#ifndef ESPFILE_H |
| 2 | +#define ESPFILE_H |
| 3 | + |
| 4 | +#include "record.h" |
| 5 | +#include "tes3record.h" |
| 6 | +#include <fstream> |
| 7 | +#include <set> |
| 8 | +#include <string> |
| 9 | + |
| 10 | +namespace ESP |
| 11 | +{ |
| 12 | + |
| 13 | +class SubRecord; |
| 14 | + |
| 15 | +class File |
| 16 | +{ |
| 17 | +public: |
| 18 | + File(const std::string& fileName); |
| 19 | + File(const std::wstring& fileName); |
| 20 | + |
| 21 | + Record readRecord(); |
| 22 | + |
| 23 | + bool isMaster() const; |
| 24 | + bool isLight(bool overlaySupport = false) const; |
| 25 | + bool isMedium() const; |
| 26 | + bool isOverlay() const; |
| 27 | + bool isBlueprint() const; |
| 28 | + bool isDummy() const; |
| 29 | + uint16_t formVersion() const { return m_MainRecord.formVersion(); }; |
| 30 | + float headerVersion() const { return m_Header.version; } |
| 31 | + std::string author() const { return m_Author; } |
| 32 | + std::string description() const { return m_Description; } |
| 33 | + std::set<std::string> masters() const { return m_Masters; } |
| 34 | + |
| 35 | +private: |
| 36 | + void init(); |
| 37 | + |
| 38 | + void onHEDR(const SubRecord& rec); |
| 39 | + void onMAST(const SubRecord& rec); |
| 40 | + void onCNAM(const SubRecord& rec); |
| 41 | + void onSNAM(const SubRecord& rec); |
| 42 | + |
| 43 | +private: |
| 44 | + std::ifstream m_File; |
| 45 | + |
| 46 | + struct |
| 47 | + { |
| 48 | + float version; |
| 49 | + int32_t numRecords; |
| 50 | + uint32_t nextObjectId; |
| 51 | + } m_Header; |
| 52 | + |
| 53 | + struct |
| 54 | + { |
| 55 | + float version; |
| 56 | + uint32_t unknown; |
| 57 | + char author[32]; |
| 58 | + char description[256]; |
| 59 | + uint32_t numRecords; |
| 60 | + } m_TES3Header; |
| 61 | + |
| 62 | + Record m_MainRecord; |
| 63 | + |
| 64 | + std::string m_Author; |
| 65 | + std::string m_Description; |
| 66 | + |
| 67 | + std::set<std::string> m_Masters; |
| 68 | +}; |
| 69 | + |
| 70 | +} // namespace ESP |
| 71 | + |
| 72 | +#endif // ESPFILE_H |
0 commit comments