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