Add CPropertyPageImpl that allows us to make property pages object oriented
[reactos.git] / sdk / tools / xml2sdb / xml2sdb.h
1 /*
2 * PROJECT: xml2sdb
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: .
5 * COPYRIGHT: Copyright 2016,2017 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8 #pragma once
9
10 #include <string>
11 #include <list>
12 #include <vector>
13 #include <map>
14
15 #include <typedefs.h>
16 #include <guiddef.h>
17 #include "sdbtypes.h"
18 #include "sdbwrite.h"
19 #include "sdbtagid.h"
20
21 namespace tinyxml2
22 {
23 class XMLHandle;
24 }
25 using tinyxml2::XMLHandle;
26
27 typedef std::basic_string<WCHAR> sdbstring;
28
29 struct Database;
30
31 struct InExclude
32 {
33 InExclude() : Include(false) { ; }
34 bool fromXml(XMLHandle dbNode);
35 bool toSdb(PDB pdb, Database& db);
36
37 std::string Module;
38 bool Include;
39 };
40
41 struct ShimRef
42 {
43 ShimRef() : ShimTagid(0) { ; }
44
45 bool fromXml(XMLHandle dbNode);
46 bool toSdb(PDB pdb, Database& db);
47
48 std::string Name;
49 std::string CommandLine;
50 TAGID ShimTagid;
51 std::list<InExclude> InExcludes;
52 };
53
54 struct Shim
55 {
56 Shim() : Tagid(0) { ; }
57
58 bool fromXml(XMLHandle dbNode);
59 bool toSdb(PDB pdb, Database& db);
60
61 std::string Name;
62 std::string DllFile;
63 GUID FixID;
64 TAGID Tagid;
65 std::list<InExclude> InExcludes;
66 };
67
68 struct Layer
69 {
70 Layer() : Tagid(0) { ; }
71
72 bool fromXml(XMLHandle dbNode);
73 bool toSdb(PDB pdb, Database& db);
74
75 std::string Name;
76 TAGID Tagid;
77 std::list<ShimRef> ShimRefs;
78 };
79
80 struct MatchingFile
81 {
82 MatchingFile() : Size(0), Checksum(0) {;}
83
84 bool fromXml(XMLHandle dbNode);
85 bool toSdb(PDB pdb, Database& db);
86
87 std::string Name;
88 DWORD Size;
89 DWORD Checksum;
90 std::string CompanyName;
91 std::string InternalName;
92 std::string ProductName;
93 std::string ProductVersion;
94 std::string FileVersion;
95 std::string BinFileVersion;
96 std::string LinkDate;
97 std::string VerLanguage;
98 std::string FileDescription;
99 std::string OriginalFilename;
100 std::string UptoBinFileVersion;
101 std::string LinkerVersion;
102 };
103
104 struct Exe
105 {
106 Exe() : Tagid(0) { ; }
107
108 bool fromXml(XMLHandle dbNode);
109 bool toSdb(PDB pdb, Database& db);
110
111 std::string Name;
112 GUID ExeID;
113 std::string AppName;
114 std::string Vendor;
115 TAGID Tagid;
116 std::list<MatchingFile> MatchingFiles;
117 std::list<ShimRef> ShimRefs;
118 };
119
120 struct Library
121 {
122 std::list<InExclude> InExcludes;
123 std::list<Shim> Shims;
124 };
125
126 struct Database
127 {
128
129 bool fromXml(const char* fileName);
130 bool fromXml(XMLHandle dbNode);
131 bool toSdb(LPCWSTR path);
132
133 void WriteString(PDB pdb, TAG tag, const sdbstring& str, bool always = false);
134 void WriteString(PDB pdb, TAG tag, const std::string& str, bool always = false);
135 void WriteBinary(PDB pdb, TAG tag, const GUID& guid, bool always = false);
136 void WriteBinary(PDB pdb, TAG tag, const std::vector<BYTE>& data, bool always = false);
137 void WriteDWord(PDB pdb, TAG tag, DWORD value, bool always = false);
138 TAGID BeginWriteListTag(PDB pdb, TAG tag);
139 BOOL EndWriteListTag(PDB pdb, TAGID tagid);
140
141 void InsertShimTagid(const sdbstring& name, TAGID tagid);
142 inline void InsertShimTagid(const std::string& name, TAGID tagid)
143 {
144 InsertShimTagid(sdbstring(name.begin(), name.end()), tagid);
145 }
146 TAGID FindShimTagid(const sdbstring& name);
147 inline TAGID FindShimTagid(const std::string& name)
148 {
149 return FindShimTagid(sdbstring(name.begin(), name.end()));
150 }
151
152
153 void InsertPatchTagid(const sdbstring& name, TAGID tagid);
154 inline void InsertPatchTagid(const std::string& name, TAGID tagid)
155 {
156 InsertPatchTagid(sdbstring(name.begin(), name.end()), tagid);
157 }
158 TAGID FindPatchTagid(const sdbstring& name);
159 inline TAGID FindPatchTagid(const std::string& name)
160 {
161 return FindPatchTagid(sdbstring(name.begin(), name.end()));
162 }
163
164 std::string Name;
165 GUID ID;
166
167 struct Library Library;
168 std::list<Layer> Layers;
169 std::list<Exe> Exes;
170
171 private:
172 std::map<sdbstring, TAGID> KnownShims;
173 std::map<sdbstring, TAGID> KnownPatches;
174 };
175