diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2008-07-11 16:51:25 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2008-07-11 16:51:25 +0000 |
commit | ca5bb76d2b8f65aa97e50b633f828c1deb241526 (patch) | |
tree | 453a1b2de3a0dc0d0b2f7080d10d033bf8fbcdf1 /utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h | |
parent | 141774be48940d56e3ad4dbf451d245b61d4f8b2 (diff) | |
download | rockbox-ca5bb76d2b8f65aa97e50b633f828c1deb241526.tar.gz rockbox-ca5bb76d2b8f65aa97e50b633f828c1deb241526.zip |
Delete the svn:executable property and set svn:eol-style to native for all those text files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18012 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h')
-rw-r--r--[-rwxr-xr-x] | utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h | 1470 |
1 files changed, 735 insertions, 735 deletions
diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h b/utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h index a0bba4c9b3..6a3dc3caef 100755..100644 --- a/utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h +++ b/utils/zenutils/libraries/pelib-0.9/pelib/ResourceDirectory.h | |||
@@ -1,735 +1,735 @@ | |||
1 | /* | 1 | /* |
2 | * ResourceDirectory.cpp - Part of the PeLib library. | 2 | * ResourceDirectory.cpp - Part of the PeLib library. |
3 | * | 3 | * |
4 | * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) | 4 | * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) |
5 | * All rights reserved. | 5 | * All rights reserved. |
6 | * | 6 | * |
7 | * This software is licensed under the zlib/libpng License. | 7 | * This software is licensed under the zlib/libpng License. |
8 | * For more details see http://www.opensource.org/licenses/zlib-license.php | 8 | * For more details see http://www.opensource.org/licenses/zlib-license.php |
9 | * or the license information file (license.htm) in the root directory | 9 | * or the license information file (license.htm) in the root directory |
10 | * of PeLib. | 10 | * of PeLib. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #ifndef RESOURCEDIRECTORY_H | 13 | #ifndef RESOURCEDIRECTORY_H |
14 | #define RESOURCEDIRECTORY_H | 14 | #define RESOURCEDIRECTORY_H |
15 | 15 | ||
16 | #include "PeLibInc.h" | 16 | #include "PeLibInc.h" |
17 | 17 | ||
18 | namespace PeLib | 18 | namespace PeLib |
19 | { | 19 | { |
20 | class ResourceElement; | 20 | class ResourceElement; |
21 | 21 | ||
22 | /// The class ResourceChild is used to store information about a resource node. | 22 | /// The class ResourceChild is used to store information about a resource node. |
23 | class ResourceChild | 23 | class ResourceChild |
24 | { | 24 | { |
25 | friend class ResourceElement; | 25 | friend class ResourceElement; |
26 | friend class ResourceDirectory; | 26 | friend class ResourceDirectory; |
27 | friend class ResourceNode; | 27 | friend class ResourceNode; |
28 | friend class ResourceLeaf; | 28 | friend class ResourceLeaf; |
29 | 29 | ||
30 | /// Stores name and offset of a resource node. | 30 | /// Stores name and offset of a resource node. |
31 | PELIB_IMG_RES_DIR_ENTRY entry; | 31 | PELIB_IMG_RES_DIR_ENTRY entry; |
32 | /// A pointer to one of the node's child nodes. | 32 | /// A pointer to one of the node's child nodes. |
33 | ResourceElement* child; | 33 | ResourceElement* child; |
34 | 34 | ||
35 | public: | 35 | public: |
36 | /// Function which compares a resource ID to the node's resource ID. | 36 | /// Function which compares a resource ID to the node's resource ID. |
37 | bool equalId(dword wId) const; // EXPORT | 37 | bool equalId(dword wId) const; // EXPORT |
38 | /// Function which compares a string to the node's resource name. | 38 | /// Function which compares a string to the node's resource name. |
39 | bool equalName(std::string strName) const; // EXPORT | 39 | bool equalName(std::string strName) const; // EXPORT |
40 | /// Predicate that determines if a child is identified by name or by ID. | 40 | /// Predicate that determines if a child is identified by name or by ID. |
41 | bool isNamedResource() const; // EXPORT | 41 | bool isNamedResource() const; // EXPORT |
42 | /// Used for sorting a node's children. | 42 | /// Used for sorting a node's children. |
43 | bool operator<(const ResourceChild& rc) const; // EXPORT | 43 | bool operator<(const ResourceChild& rc) const; // EXPORT |
44 | /// Returns the size of a resource child. | 44 | /// Returns the size of a resource child. |
45 | // unsigned int size() const; | 45 | // unsigned int size() const; |
46 | 46 | ||
47 | /// Standard constructor. Does absolutely nothing. | 47 | /// Standard constructor. Does absolutely nothing. |
48 | ResourceChild(); | 48 | ResourceChild(); |
49 | /// Makes a deep copy of a ResourceChild object. | 49 | /// Makes a deep copy of a ResourceChild object. |
50 | ResourceChild(const ResourceChild& rhs); | 50 | ResourceChild(const ResourceChild& rhs); |
51 | /// Makes a deep copy of a ResourceChild object. | 51 | /// Makes a deep copy of a ResourceChild object. |
52 | ResourceChild& operator=(const ResourceChild& rhs); | 52 | ResourceChild& operator=(const ResourceChild& rhs); |
53 | /// Deletes a ResourceChild object. | 53 | /// Deletes a ResourceChild object. |
54 | ~ResourceChild(); | 54 | ~ResourceChild(); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /// Base class for ResourceNode and ResourceLeaf, the elements of the resource tree. | 57 | /// Base class for ResourceNode and ResourceLeaf, the elements of the resource tree. |
58 | /// \todo write | 58 | /// \todo write |
59 | class ResourceElement | 59 | class ResourceElement |
60 | { | 60 | { |
61 | friend class ResourceChild; | 61 | friend class ResourceChild; |
62 | friend class ResourceNode; | 62 | friend class ResourceNode; |
63 | friend class ResourceLeaf; | 63 | friend class ResourceLeaf; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | /// Stores RVA of the resource element in the file. | 66 | /// Stores RVA of the resource element in the file. |
67 | unsigned int uiElementRva; | 67 | unsigned int uiElementRva; |
68 | 68 | ||
69 | /// Reads the next resource element from the InputBuffer. | 69 | /// Reads the next resource element from the InputBuffer. |
70 | virtual int read(InputBuffer&, unsigned int, unsigned int/*, const std::string&*/) = 0; | 70 | virtual int read(InputBuffer&, unsigned int, unsigned int/*, const std::string&*/) = 0; |
71 | /// Writes the next resource element into the OutputBuffer. | 71 | /// Writes the next resource element into the OutputBuffer. |
72 | virtual void rebuild(OutputBuffer&, unsigned int&, unsigned int, const std::string&) const = 0; | 72 | virtual void rebuild(OutputBuffer&, unsigned int&, unsigned int, const std::string&) const = 0; |
73 | 73 | ||
74 | public: | 74 | public: |
75 | /// Returns the RVA of the element in the file. | 75 | /// Returns the RVA of the element in the file. |
76 | unsigned int getElementRva() const; // EXPORT | 76 | unsigned int getElementRva() const; // EXPORT |
77 | /// Indicates if the resource element is a leaf or a node. | 77 | /// Indicates if the resource element is a leaf or a node. |
78 | virtual bool isLeaf() const = 0; // EXPORT | 78 | virtual bool isLeaf() const = 0; // EXPORT |
79 | /// Corrects erroneous valeus in the ResourceElement. | 79 | /// Corrects erroneous valeus in the ResourceElement. |
80 | virtual void makeValid() = 0; // EXPORT | 80 | virtual void makeValid() = 0; // EXPORT |
81 | /// Returns the size of a resource element. | 81 | /// Returns the size of a resource element. |
82 | // virtual unsigned int size() const = 0; | 82 | // virtual unsigned int size() const = 0; |
83 | /// Necessary virtual destructor. | 83 | /// Necessary virtual destructor. |
84 | virtual ~ResourceElement() {} | 84 | virtual ~ResourceElement() {} |
85 | }; | 85 | }; |
86 | 86 | ||
87 | /// ResourceLeafs represent the leafs of the resource tree: The actual resources. | 87 | /// ResourceLeafs represent the leafs of the resource tree: The actual resources. |
88 | class ResourceLeaf : public ResourceElement | 88 | class ResourceLeaf : public ResourceElement |
89 | { | 89 | { |
90 | friend class ResourceChild; | 90 | friend class ResourceChild; |
91 | friend class ResourceDirectory; | 91 | friend class ResourceDirectory; |
92 | template<typename T> friend struct fixNumberOfEntries; | 92 | template<typename T> friend struct fixNumberOfEntries; |
93 | 93 | ||
94 | private: | 94 | private: |
95 | /// The resource data. | 95 | /// The resource data. |
96 | std::vector<byte> m_data; | 96 | std::vector<byte> m_data; |
97 | /// PeLib equivalent of the Win32 structure IMAGE_RESOURCE_DATA_ENTRY | 97 | /// PeLib equivalent of the Win32 structure IMAGE_RESOURCE_DATA_ENTRY |
98 | PELIB_IMAGE_RESOURCE_DATA_ENTRY entry; | 98 | PELIB_IMAGE_RESOURCE_DATA_ENTRY entry; |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | int read(InputBuffer& inpBuffer, unsigned int uiOffset, unsigned int rva/*, const std::string&*/); | 101 | int read(InputBuffer& inpBuffer, unsigned int uiOffset, unsigned int rva/*, const std::string&*/); |
102 | /// Writes the next resource leaf into the OutputBuffer. | 102 | /// Writes the next resource leaf into the OutputBuffer. |
103 | void rebuild(OutputBuffer&, unsigned int& uiOffset, unsigned int uiRva, const std::string&) const; | 103 | void rebuild(OutputBuffer&, unsigned int& uiOffset, unsigned int uiRva, const std::string&) const; |
104 | 104 | ||
105 | public: | 105 | public: |
106 | /// Indicates if the resource element is a leaf or a node. | 106 | /// Indicates if the resource element is a leaf or a node. |
107 | bool isLeaf() const; // EXPORT | 107 | bool isLeaf() const; // EXPORT |
108 | /// Corrects erroneous valeus in the ResourceLeaf. | 108 | /// Corrects erroneous valeus in the ResourceLeaf. |
109 | void makeValid(); // EXPORT | 109 | void makeValid(); // EXPORT |
110 | /// Reads the next resource leaf from the InputBuffer. | 110 | /// Reads the next resource leaf from the InputBuffer. |
111 | /// Returns the size of a resource lead. | 111 | /// Returns the size of a resource lead. |
112 | // unsigned int size() const; | 112 | // unsigned int size() const; |
113 | 113 | ||
114 | /// Returns the resource data of this resource leaf. | 114 | /// Returns the resource data of this resource leaf. |
115 | std::vector<byte> getData() const; // EXPORT | 115 | std::vector<byte> getData() const; // EXPORT |
116 | /// Sets the resource data of this resource leaf. | 116 | /// Sets the resource data of this resource leaf. |
117 | void setData(const std::vector<byte>& vData); // EXPORT | 117 | void setData(const std::vector<byte>& vData); // EXPORT |
118 | 118 | ||
119 | /// Returns the OffsetToData value of this resource leaf. | 119 | /// Returns the OffsetToData value of this resource leaf. |
120 | dword getOffsetToData() const; // EXPORT | 120 | dword getOffsetToData() const; // EXPORT |
121 | /// Returns the Size value of this resource leaf. | 121 | /// Returns the Size value of this resource leaf. |
122 | dword getSize() const; // EXPORT | 122 | dword getSize() const; // EXPORT |
123 | /// Returns the CodePage value of this resource leaf. | 123 | /// Returns the CodePage value of this resource leaf. |
124 | dword getCodePage() const; // EXPORT | 124 | dword getCodePage() const; // EXPORT |
125 | /// Returns the Reserved value of this resource leaf. | 125 | /// Returns the Reserved value of this resource leaf. |
126 | dword getReserved() const; // EXPORT | 126 | dword getReserved() const; // EXPORT |
127 | 127 | ||
128 | /// Sets the OffsetToData value of this resource leaf. | 128 | /// Sets the OffsetToData value of this resource leaf. |
129 | void setOffsetToData(dword dwValue); // EXPORT | 129 | void setOffsetToData(dword dwValue); // EXPORT |
130 | /// Sets the Size value of this resource leaf. | 130 | /// Sets the Size value of this resource leaf. |
131 | void setSize(dword dwValue); // EXPORT | 131 | void setSize(dword dwValue); // EXPORT |
132 | /// Sets the CodePage value of this resource leaf. | 132 | /// Sets the CodePage value of this resource leaf. |
133 | void setCodePage(dword dwValue); // EXPORT | 133 | void setCodePage(dword dwValue); // EXPORT |
134 | /// Sets the Reserved value of this resource leaf. | 134 | /// Sets the Reserved value of this resource leaf. |
135 | void setReserved(dword dwValue); // EXPORT | 135 | void setReserved(dword dwValue); // EXPORT |
136 | }; | 136 | }; |
137 | 137 | ||
138 | /// ResourceNodes represent the nodes in the resource tree. | 138 | /// ResourceNodes represent the nodes in the resource tree. |
139 | class ResourceNode : public ResourceElement | 139 | class ResourceNode : public ResourceElement |
140 | { | 140 | { |
141 | friend class ResourceChild; | 141 | friend class ResourceChild; |
142 | friend class ResourceDirectory; | 142 | friend class ResourceDirectory; |
143 | template<typename T> friend struct fixNumberOfEntries; | 143 | template<typename T> friend struct fixNumberOfEntries; |
144 | 144 | ||
145 | /// The node's children. | 145 | /// The node's children. |
146 | std::vector<ResourceChild> children; | 146 | std::vector<ResourceChild> children; |
147 | /// The node's header. Equivalent to IMAGE_RESOURCE_DIRECTORY from the Win32 API. | 147 | /// The node's header. Equivalent to IMAGE_RESOURCE_DIRECTORY from the Win32 API. |
148 | PELIB_IMAGE_RESOURCE_DIRECTORY header; | 148 | PELIB_IMAGE_RESOURCE_DIRECTORY header; |
149 | 149 | ||
150 | protected: | 150 | protected: |
151 | /// Reads the next resource node. | 151 | /// Reads the next resource node. |
152 | int read(InputBuffer& inpBuffer, unsigned int uiOffset, unsigned int rva/*, const std::string&*/); | 152 | int read(InputBuffer& inpBuffer, unsigned int uiOffset, unsigned int rva/*, const std::string&*/); |
153 | /// Writes the next resource node into the OutputBuffer. | 153 | /// Writes the next resource node into the OutputBuffer. |
154 | void rebuild(OutputBuffer&, unsigned int& uiOffset, unsigned int uiRva, const std::string&) const; | 154 | void rebuild(OutputBuffer&, unsigned int& uiOffset, unsigned int uiRva, const std::string&) const; |
155 | 155 | ||
156 | public: | 156 | public: |
157 | /// Indicates if the resource element is a leaf or a node. | 157 | /// Indicates if the resource element is a leaf or a node. |
158 | bool isLeaf() const; // EXPORT | 158 | bool isLeaf() const; // EXPORT |
159 | /// Corrects erroneous valeus in the ResourceNode. | 159 | /// Corrects erroneous valeus in the ResourceNode. |
160 | void makeValid(); // EXPORT | 160 | void makeValid(); // EXPORT |
161 | 161 | ||
162 | /// Returns the node's number of children. | 162 | /// Returns the node's number of children. |
163 | unsigned int getNumberOfChildren() const; // EXPORT | 163 | unsigned int getNumberOfChildren() const; // EXPORT |
164 | /// Adds another child to node. | 164 | /// Adds another child to node. |
165 | void addChild(); // EXPORT | 165 | void addChild(); // EXPORT |
166 | /// Returns a node's child. | 166 | /// Returns a node's child. |
167 | ResourceElement* getChild(unsigned int uiIndex); // EXPORT | 167 | ResourceElement* getChild(unsigned int uiIndex); // EXPORT |
168 | /// Removes a node's child. | 168 | /// Removes a node's child. |
169 | void removeChild(unsigned int uiIndex); // EXPORT | 169 | void removeChild(unsigned int uiIndex); // EXPORT |
170 | 170 | ||
171 | /// Returns the name of one of the node's children. | 171 | /// Returns the name of one of the node's children. |
172 | std::string getChildName(unsigned int uiIndex) const; // EXPORT | 172 | std::string getChildName(unsigned int uiIndex) const; // EXPORT |
173 | /// Returns the Name value of one of the node's children. | 173 | /// Returns the Name value of one of the node's children. |
174 | dword getOffsetToChildName(unsigned int uiIndex) const; // EXPORT | 174 | dword getOffsetToChildName(unsigned int uiIndex) const; // EXPORT |
175 | /// Returns the OffsetToData value of one of the node's children. | 175 | /// Returns the OffsetToData value of one of the node's children. |
176 | dword getOffsetToChildData(unsigned int uiIndex) const; // EXPORT | 176 | dword getOffsetToChildData(unsigned int uiIndex) const; // EXPORT |
177 | 177 | ||
178 | /// Sets the name of one of the node's children. | 178 | /// Sets the name of one of the node's children. |
179 | void setChildName(unsigned int uiIndex, const std::string& strNewName); // EXPORT | 179 | void setChildName(unsigned int uiIndex, const std::string& strNewName); // EXPORT |
180 | /// Sets the Name value of one of the node's children. | 180 | /// Sets the Name value of one of the node's children. |
181 | void setOffsetToChildName(unsigned int uiIndex, dword dwNewOffset); // EXPORT | 181 | void setOffsetToChildName(unsigned int uiIndex, dword dwNewOffset); // EXPORT |
182 | /// Sets the OffsetToData value of one of the node's children. | 182 | /// Sets the OffsetToData value of one of the node's children. |
183 | void setOffsetToChildData(unsigned int uiIndex, dword dwNewOffset); // EXPORT | 183 | void setOffsetToChildData(unsigned int uiIndex, dword dwNewOffset); // EXPORT |
184 | 184 | ||
185 | /// Returns the node's Characteristics value. | 185 | /// Returns the node's Characteristics value. |
186 | dword getCharacteristics() const; // EXPORT | 186 | dword getCharacteristics() const; // EXPORT |
187 | /// Returns the node's TimeDateStamp value. | 187 | /// Returns the node's TimeDateStamp value. |
188 | dword getTimeDateStamp() const; // EXPORT | 188 | dword getTimeDateStamp() const; // EXPORT |
189 | /// Returns the node's MajorVersion value. | 189 | /// Returns the node's MajorVersion value. |
190 | word getMajorVersion() const; // EXPORT | 190 | word getMajorVersion() const; // EXPORT |
191 | /// Returns the node's MinorVersion value. | 191 | /// Returns the node's MinorVersion value. |
192 | word getMinorVersion() const; // EXPORT | 192 | word getMinorVersion() const; // EXPORT |
193 | /// Returns the node's NumberOfNamedEntries value. | 193 | /// Returns the node's NumberOfNamedEntries value. |
194 | word getNumberOfNamedEntries() const; // EXPORT | 194 | word getNumberOfNamedEntries() const; // EXPORT |
195 | /// Returns the node's NumberOfIdEntries value. | 195 | /// Returns the node's NumberOfIdEntries value. |
196 | word getNumberOfIdEntries() const; // EXPORT | 196 | word getNumberOfIdEntries() const; // EXPORT |
197 | 197 | ||
198 | /// Sets the node's Characteristics value. | 198 | /// Sets the node's Characteristics value. |
199 | void setCharacteristics(dword value); // EXPORT | 199 | void setCharacteristics(dword value); // EXPORT |
200 | /// Sets the node's TimeDateStamp value. | 200 | /// Sets the node's TimeDateStamp value. |
201 | void setTimeDateStamp(dword value); // EXPORT | 201 | void setTimeDateStamp(dword value); // EXPORT |
202 | /// Sets the node's MajorVersion value. | 202 | /// Sets the node's MajorVersion value. |
203 | void setMajorVersion(word value); // EXPORT | 203 | void setMajorVersion(word value); // EXPORT |
204 | /// Sets the node's MinorVersion value. | 204 | /// Sets the node's MinorVersion value. |
205 | void setMinorVersion(word value); // EXPORT | 205 | void setMinorVersion(word value); // EXPORT |
206 | /// Sets the node's NumberOfNamedEntries value. | 206 | /// Sets the node's NumberOfNamedEntries value. |
207 | void setNumberOfNamedEntries(word value); // EXPORT | 207 | void setNumberOfNamedEntries(word value); // EXPORT |
208 | /// Sets the node's NumberOfIdEntries value. | 208 | /// Sets the node's NumberOfIdEntries value. |
209 | void setNumberOfIdEntries(word value); // EXPORT | 209 | void setNumberOfIdEntries(word value); // EXPORT |
210 | 210 | ||
211 | /// Returns the size of a resource node. | 211 | /// Returns the size of a resource node. |
212 | // unsigned int size() const; | 212 | // unsigned int size() const; |
213 | }; | 213 | }; |
214 | 214 | ||
215 | /// Auxiliary functor which is used to search through the resource tree. | 215 | /// Auxiliary functor which is used to search through the resource tree. |
216 | /** | 216 | /** |
217 | * Traits class for the template functions of ResourceDirectory. | 217 | * Traits class for the template functions of ResourceDirectory. |
218 | * It's used to find out which function to use when searching for resource nodes or resource leafs | 218 | * It's used to find out which function to use when searching for resource nodes or resource leafs |
219 | * in a node's children vector. | 219 | * in a node's children vector. |
220 | **/ | 220 | **/ |
221 | template<typename T> | 221 | template<typename T> |
222 | struct ResComparer | 222 | struct ResComparer |
223 | { | 223 | { |
224 | /// Pointer to a member function of ResourceChild | 224 | /// Pointer to a member function of ResourceChild |
225 | typedef bool(ResourceChild::*CompFunc)(T) const; | 225 | typedef bool(ResourceChild::*CompFunc)(T) const; |
226 | 226 | ||
227 | /// Return 0 for all unspecialized versions of ResComparer. | 227 | /// Return 0 for all unspecialized versions of ResComparer. |
228 | static CompFunc comp(); | 228 | static CompFunc comp(); |
229 | }; | 229 | }; |
230 | 230 | ||
231 | /// Auxiliary functor which is used to search through the resource tree. | 231 | /// Auxiliary functor which is used to search through the resource tree. |
232 | /** | 232 | /** |
233 | * ResComparer<dword> is used when a resource element is searched for by ID. | 233 | * ResComparer<dword> is used when a resource element is searched for by ID. |
234 | **/ | 234 | **/ |
235 | template<> | 235 | template<> |
236 | struct ResComparer<dword> | 236 | struct ResComparer<dword> |
237 | { | 237 | { |
238 | /// Pointer to a member function of ResourceChild | 238 | /// Pointer to a member function of ResourceChild |
239 | typedef bool(ResourceChild::*CompFunc)(dword) const; | 239 | typedef bool(ResourceChild::*CompFunc)(dword) const; |
240 | 240 | ||
241 | /// Return the address of the ResourceChild member function that compares the ids of resource elements. | 241 | /// Return the address of the ResourceChild member function that compares the ids of resource elements. |
242 | static CompFunc comp() | 242 | static CompFunc comp() |
243 | { | 243 | { |
244 | return &ResourceChild::equalId; | 244 | return &ResourceChild::equalId; |
245 | } | 245 | } |
246 | }; | 246 | }; |
247 | 247 | ||
248 | /// Auxiliary functor which is used to search through the resource tree. | 248 | /// Auxiliary functor which is used to search through the resource tree. |
249 | /** | 249 | /** |
250 | * This specializd version of ResComparer is used when a resource element is searched for by name. | 250 | * This specializd version of ResComparer is used when a resource element is searched for by name. |
251 | **/ | 251 | **/ |
252 | template<> | 252 | template<> |
253 | struct ResComparer<std::string> | 253 | struct ResComparer<std::string> |
254 | { | 254 | { |
255 | /// Pointer to a member function of ResourceChild | 255 | /// Pointer to a member function of ResourceChild |
256 | typedef bool(ResourceChild::*CompFunc)(std::string) const; | 256 | typedef bool(ResourceChild::*CompFunc)(std::string) const; |
257 | 257 | ||
258 | /// Return the address of the ResourceChild member function that compares the names of resource elements. | 258 | /// Return the address of the ResourceChild member function that compares the names of resource elements. |
259 | static CompFunc comp() | 259 | static CompFunc comp() |
260 | { | 260 | { |
261 | return &ResourceChild::equalName; | 261 | return &ResourceChild::equalName; |
262 | } | 262 | } |
263 | }; | 263 | }; |
264 | 264 | ||
265 | /// Unspecialized function that's used as base template for the specialized versions below. | 265 | /// Unspecialized function that's used as base template for the specialized versions below. |
266 | template<typename T> | 266 | template<typename T> |
267 | struct fixNumberOfEntries | 267 | struct fixNumberOfEntries |
268 | { | 268 | { |
269 | /// Fixes a resource node's header. | 269 | /// Fixes a resource node's header. |
270 | static void fix(ResourceNode*); | 270 | static void fix(ResourceNode*); |
271 | }; | 271 | }; |
272 | 272 | ||
273 | /// Fixes NumberOfIdEntries value of a node. | 273 | /// Fixes NumberOfIdEntries value of a node. |
274 | template<> | 274 | template<> |
275 | struct fixNumberOfEntries<dword> | 275 | struct fixNumberOfEntries<dword> |
276 | { | 276 | { |
277 | /// Fixes a resource node's NumberOfIdEntries value. | 277 | /// Fixes a resource node's NumberOfIdEntries value. |
278 | static void fix(ResourceNode* node) | 278 | static void fix(ResourceNode* node) |
279 | { | 279 | { |
280 | node->header.NumberOfIdEntries = (unsigned int)node->children.size() - std::count_if(node->children.begin(), node->children.end(), std::mem_fun_ref(&ResourceChild::isNamedResource)); | 280 | node->header.NumberOfIdEntries = (unsigned int)node->children.size() - std::count_if(node->children.begin(), node->children.end(), std::mem_fun_ref(&ResourceChild::isNamedResource)); |
281 | } | 281 | } |
282 | }; | 282 | }; |
283 | 283 | ||
284 | /// Fixes NumberOfNamedEntries value of a node. | 284 | /// Fixes NumberOfNamedEntries value of a node. |
285 | template<> | 285 | template<> |
286 | struct fixNumberOfEntries<std::string> | 286 | struct fixNumberOfEntries<std::string> |
287 | { | 287 | { |
288 | /// Fixes a resource node's NumberOfNamedEntries value. | 288 | /// Fixes a resource node's NumberOfNamedEntries value. |
289 | static void fix(ResourceNode* node) | 289 | static void fix(ResourceNode* node) |
290 | { | 290 | { |
291 | node->header.NumberOfNamedEntries = static_cast<PeLib::word>(std::count_if(node->children.begin(), node->children.end(), std::mem_fun_ref(&ResourceChild::isNamedResource))); | 291 | node->header.NumberOfNamedEntries = static_cast<PeLib::word>(std::count_if(node->children.begin(), node->children.end(), std::mem_fun_ref(&ResourceChild::isNamedResource))); |
292 | } | 292 | } |
293 | }; | 293 | }; |
294 | 294 | ||
295 | /// Class that represents the resource directory of a PE file. | 295 | /// Class that represents the resource directory of a PE file. |
296 | /** | 296 | /** |
297 | * The class ResourceDirectory represents the resource directory of a PE file. This class is fundamentally | 297 | * The class ResourceDirectory represents the resource directory of a PE file. This class is fundamentally |
298 | * different from the other classes of the PeLib library due to the structure of the ResourceDirectory. | 298 | * different from the other classes of the PeLib library due to the structure of the ResourceDirectory. |
299 | * For once, it's possible to manipulate the ResourceDirectory through a set of "high level" functions and | 299 | * For once, it's possible to manipulate the ResourceDirectory through a set of "high level" functions and |
300 | * and through a set of "low level" functions. The "high level" functions are the functions inside the | 300 | * and through a set of "low level" functions. The "high level" functions are the functions inside the |
301 | * ResourceDirectory class with the exception of getRoot.<br><br> | 301 | * ResourceDirectory class with the exception of getRoot.<br><br> |
302 | * getRoot on the other hand is the first "low level" function. Use it to retrieve the root node of the | 302 | * getRoot on the other hand is the first "low level" function. Use it to retrieve the root node of the |
303 | * resource tree. Then you can traverse through the tree and manipulate individual nodes and leafs | 303 | * resource tree. Then you can traverse through the tree and manipulate individual nodes and leafs |
304 | * directly using the functions provided by the classes ResourceNode and ResourceLeaf.<br><br> | 304 | * directly using the functions provided by the classes ResourceNode and ResourceLeaf.<br><br> |
305 | * There's another difference between the ResourceDirectory class and the other PeLib classes, which is | 305 | * There's another difference between the ResourceDirectory class and the other PeLib classes, which is |
306 | * once again caused by the special structure of the PE resource directory. The nodes of the resource | 306 | * once again caused by the special structure of the PE resource directory. The nodes of the resource |
307 | * tree must be in a certain order. Manipulating the resource tree does not directly sort the nodes | 307 | * tree must be in a certain order. Manipulating the resource tree does not directly sort the nodes |
308 | * correctly as this would cause more trouble than it fixes. That means it's your responsibility to | 308 | * correctly as this would cause more trouble than it fixes. That means it's your responsibility to |
309 | * fix the resource tree after manipulating it. PeLib makes the job easy for you, just call the | 309 | * fix the resource tree after manipulating it. PeLib makes the job easy for you, just call the |
310 | * ResourceDirectory::makeValid function.<br><br> | 310 | * ResourceDirectory::makeValid function.<br><br> |
311 | * You might also wonder why there's no size() function in this class. I did not forget it. It's just | 311 | * You might also wonder why there's no size() function in this class. I did not forget it. It's just |
312 | * that it's impossible to calculate the size of the resource directory without rebuilding it. So why | 312 | * that it's impossible to calculate the size of the resource directory without rebuilding it. So why |
313 | * should PeLib do this if you can do it just as easily by calling rebuild() and then checking the length | 313 | * should PeLib do this if you can do it just as easily by calling rebuild() and then checking the length |
314 | * of the returned vector.<br><br> | 314 | * of the returned vector.<br><br> |
315 | * There are also different ways to serialize (rebuild) the resource tree as it's not a fixed structure | 315 | * There are also different ways to serialize (rebuild) the resource tree as it's not a fixed structure |
316 | * that can easily be minimized like most other PE directories.<br><br> | 316 | * that can easily be minimized like most other PE directories.<br><br> |
317 | * This means it's entirely possible that the resource tree you read from a file differs from the one | 317 | * This means it's entirely possible that the resource tree you read from a file differs from the one |
318 | * PeLib creates. This might cause a minor issue. The original resource tree might be smaller (due to | 318 | * PeLib creates. This might cause a minor issue. The original resource tree might be smaller (due to |
319 | * different padding) so it's crucial that you check if there's enough space in the original resource | 319 | * different padding) so it's crucial that you check if there's enough space in the original resource |
320 | * directory before you write the rebuilt resource directory back to the file. | 320 | * directory before you write the rebuilt resource directory back to the file. |
321 | **/ | 321 | **/ |
322 | class ResourceDirectory | 322 | class ResourceDirectory |
323 | { | 323 | { |
324 | private: | 324 | private: |
325 | /// The root node of the resource directory. | 325 | /// The root node of the resource directory. |
326 | ResourceNode m_rnRoot; | 326 | ResourceNode m_rnRoot; |
327 | 327 | ||
328 | // Prepare for some crazy syntax below to make Digital Mars happy. | 328 | // Prepare for some crazy syntax below to make Digital Mars happy. |
329 | 329 | ||
330 | /// Retrieves an iterator to a specified resource child. | 330 | /// Retrieves an iterator to a specified resource child. |
331 | template<typename S, typename T> | 331 | template<typename S, typename T> |
332 | std::vector<ResourceChild>::const_iterator locateResourceT(S restypeid, T resid) const; | 332 | std::vector<ResourceChild>::const_iterator locateResourceT(S restypeid, T resid) const; |
333 | 333 | ||
334 | /// Retrieves an iterator to a specified resource child. | 334 | /// Retrieves an iterator to a specified resource child. |
335 | template<typename S, typename T> | 335 | template<typename S, typename T> |
336 | std::vector<ResourceChild>::iterator locateResourceT(S restypeid, T resid); | 336 | std::vector<ResourceChild>::iterator locateResourceT(S restypeid, T resid); |
337 | 337 | ||
338 | /// Adds a new resource. | 338 | /// Adds a new resource. |
339 | template<typename S, typename T> | 339 | template<typename S, typename T> |
340 | int addResourceT(S restypeid, T resid, ResourceChild& rc); | 340 | int addResourceT(S restypeid, T resid, ResourceChild& rc); |
341 | 341 | ||
342 | /// Removes new resource. | 342 | /// Removes new resource. |
343 | template<typename S, typename T> | 343 | template<typename S, typename T> |
344 | int removeResourceT(S restypeid, T resid); | 344 | int removeResourceT(S restypeid, T resid); |
345 | 345 | ||
346 | /// Returns the data of a resource. | 346 | /// Returns the data of a resource. |
347 | template<typename S, typename T> | 347 | template<typename S, typename T> |
348 | int getResourceDataT(S restypeid, T resid, std::vector<byte>& data) const; | 348 | int getResourceDataT(S restypeid, T resid, std::vector<byte>& data) const; |
349 | 349 | ||
350 | /// Sets the data of a resource. | 350 | /// Sets the data of a resource. |
351 | template<typename S, typename T> | 351 | template<typename S, typename T> |
352 | int setResourceDataT(S restypeid, T resid, std::vector<byte>& data); | 352 | int setResourceDataT(S restypeid, T resid, std::vector<byte>& data); |
353 | 353 | ||
354 | /// Returns the ID of a resource. | 354 | /// Returns the ID of a resource. |
355 | template<typename S, typename T> | 355 | template<typename S, typename T> |
356 | dword getResourceIdT(S restypeid, T resid) const; | 356 | dword getResourceIdT(S restypeid, T resid) const; |
357 | 357 | ||
358 | /// Sets the ID of a resource. | 358 | /// Sets the ID of a resource. |
359 | template<typename S, typename T> | 359 | template<typename S, typename T> |
360 | int setResourceIdT(S restypeid, T resid, dword dwNewResId); | 360 | int setResourceIdT(S restypeid, T resid, dword dwNewResId); |
361 | 361 | ||
362 | /// Returns the name of a resource. | 362 | /// Returns the name of a resource. |
363 | template<typename S, typename T> | 363 | template<typename S, typename T> |
364 | std::string getResourceNameT(S restypeid, T resid) const; | 364 | std::string getResourceNameT(S restypeid, T resid) const; |
365 | 365 | ||
366 | /// Sets the name of a resource. | 366 | /// Sets the name of a resource. |
367 | template<typename S, typename T> | 367 | template<typename S, typename T> |
368 | int setResourceNameT(S restypeid, T resid, std::string strNewResName); | 368 | int setResourceNameT(S restypeid, T resid, std::string strNewResName); |
369 | 369 | ||
370 | public: | 370 | public: |
371 | ResourceNode* getRoot(); | 371 | ResourceNode* getRoot(); |
372 | /// Corrects a erroneous resource directory. | 372 | /// Corrects a erroneous resource directory. |
373 | void makeValid(); | 373 | void makeValid(); |
374 | /// Reads the resource directory from a file. | 374 | /// Reads the resource directory from a file. |
375 | int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, unsigned int uiResDirRva); | 375 | int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, unsigned int uiResDirRva); |
376 | /// Rebuilds the resource directory. | 376 | /// Rebuilds the resource directory. |
377 | void rebuild(std::vector<byte>& vBuffer, unsigned int uiRva) const; | 377 | void rebuild(std::vector<byte>& vBuffer, unsigned int uiRva) const; |
378 | /// Returns the size of the rebuilt resource directory. | 378 | /// Returns the size of the rebuilt resource directory. |
379 | // unsigned int size() const; | 379 | // unsigned int size() const; |
380 | /// Writes the resource directory to a file. | 380 | /// Writes the resource directory to a file. |
381 | int write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const; | 381 | int write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const; |
382 | 382 | ||
383 | /// Adds a new resource type. | 383 | /// Adds a new resource type. |
384 | int addResourceType(dword dwResTypeId); | 384 | int addResourceType(dword dwResTypeId); |
385 | /// Adds a new resource type. | 385 | /// Adds a new resource type. |
386 | int addResourceType(const std::string& strResTypeName); | 386 | int addResourceType(const std::string& strResTypeName); |
387 | 387 | ||
388 | /// Removes a resource type and all of it's resources. | 388 | /// Removes a resource type and all of it's resources. |
389 | int removeResourceType(dword dwResTypeId); | 389 | int removeResourceType(dword dwResTypeId); |
390 | /// Removes a resource type and all of it's resources. | 390 | /// Removes a resource type and all of it's resources. |
391 | int removeResourceType(const std::string& strResTypeName); | 391 | int removeResourceType(const std::string& strResTypeName); |
392 | 392 | ||
393 | /// Removes a resource type and all of it's resources. | 393 | /// Removes a resource type and all of it's resources. |
394 | int removeResourceTypeByIndex(unsigned int uiIndex); | 394 | int removeResourceTypeByIndex(unsigned int uiIndex); |
395 | 395 | ||
396 | /// Adds a new resource. | 396 | /// Adds a new resource. |
397 | int addResource(dword dwResTypeId, dword dwResId); | 397 | int addResource(dword dwResTypeId, dword dwResId); |
398 | /// Adds a new resource. | 398 | /// Adds a new resource. |
399 | int addResource(dword dwResTypeId, const std::string& strResName); | 399 | int addResource(dword dwResTypeId, const std::string& strResName); |
400 | /// Adds a new resource. | 400 | /// Adds a new resource. |
401 | int addResource(const std::string& strResTypeName, dword dwResId); | 401 | int addResource(const std::string& strResTypeName, dword dwResId); |
402 | /// Adds a new resource. | 402 | /// Adds a new resource. |
403 | int addResource(const std::string& strResTypeName, const std::string& strResName); | 403 | int addResource(const std::string& strResTypeName, const std::string& strResName); |
404 | 404 | ||
405 | /// Removes a resource. | 405 | /// Removes a resource. |
406 | int removeResource(dword dwResTypeId, dword dwResId); | 406 | int removeResource(dword dwResTypeId, dword dwResId); |
407 | /// Removes a resource. | 407 | /// Removes a resource. |
408 | int removeResource(dword dwResTypeId, const std::string& strResName); | 408 | int removeResource(dword dwResTypeId, const std::string& strResName); |
409 | /// Removes a resource. | 409 | /// Removes a resource. |
410 | int removeResource(const std::string& strResTypeName, dword dwResId); | 410 | int removeResource(const std::string& strResTypeName, dword dwResId); |
411 | /// Removes a resource. | 411 | /// Removes a resource. |
412 | int removeResource(const std::string& strResTypeName, const std::string& strResName); | 412 | int removeResource(const std::string& strResTypeName, const std::string& strResName); |
413 | 413 | ||
414 | /// Returns the number of resource types. | 414 | /// Returns the number of resource types. |
415 | unsigned int getNumberOfResourceTypes() const; | 415 | unsigned int getNumberOfResourceTypes() const; |
416 | 416 | ||
417 | /// Returns the ID of a resource type. | 417 | /// Returns the ID of a resource type. |
418 | dword getResourceTypeIdByIndex(unsigned int uiIndex) const; | 418 | dword getResourceTypeIdByIndex(unsigned int uiIndex) const; |
419 | /// Returns the name of a resource type. | 419 | /// Returns the name of a resource type. |
420 | std::string getResourceTypeNameByIndex(unsigned int uiIndex) const; | 420 | std::string getResourceTypeNameByIndex(unsigned int uiIndex) const; |
421 | 421 | ||
422 | /// Converts a resource type ID to an index. | 422 | /// Converts a resource type ID to an index. |
423 | int resourceTypeIdToIndex(dword dwResTypeId) const; | 423 | int resourceTypeIdToIndex(dword dwResTypeId) const; |
424 | /// Converts a resource type name to an index. | 424 | /// Converts a resource type name to an index. |
425 | int resourceTypeNameToIndex(const std::string& strResTypeName) const; | 425 | int resourceTypeNameToIndex(const std::string& strResTypeName) const; |
426 | 426 | ||
427 | /// Returns the number of resources of a certain resource type. | 427 | /// Returns the number of resources of a certain resource type. |
428 | unsigned int getNumberOfResources(dword dwId) const; | 428 | unsigned int getNumberOfResources(dword dwId) const; |
429 | /// Returns the number of resources of a certain resource type. | 429 | /// Returns the number of resources of a certain resource type. |
430 | unsigned int getNumberOfResources(const std::string& strResTypeName) const; | 430 | unsigned int getNumberOfResources(const std::string& strResTypeName) const; |
431 | 431 | ||
432 | /// Returns the number of resources of a certain resource type. | 432 | /// Returns the number of resources of a certain resource type. |
433 | unsigned int getNumberOfResourcesByIndex(unsigned int uiIndex) const; | 433 | unsigned int getNumberOfResourcesByIndex(unsigned int uiIndex) const; |
434 | 434 | ||
435 | /// Returns the data of a certain resource. | 435 | /// Returns the data of a certain resource. |
436 | void getResourceData(dword dwResTypeId, dword dwResId, std::vector<byte>& data) const; | 436 | void getResourceData(dword dwResTypeId, dword dwResId, std::vector<byte>& data) const; |
437 | /// Returns the data of a certain resource. | 437 | /// Returns the data of a certain resource. |
438 | void getResourceData(dword dwResTypeId, const std::string& strResName, std::vector<byte>& data) const; | 438 | void getResourceData(dword dwResTypeId, const std::string& strResName, std::vector<byte>& data) const; |
439 | /// Returns the data of a certain resource. | 439 | /// Returns the data of a certain resource. |
440 | void getResourceData(const std::string& strResTypeName, dword dwResId, std::vector<byte>& data) const; | 440 | void getResourceData(const std::string& strResTypeName, dword dwResId, std::vector<byte>& data) const; |
441 | /// Returns the data of a certain resource. | 441 | /// Returns the data of a certain resource. |
442 | void getResourceData(const std::string& strResTypeName, const std::string& strResName, std::vector<byte>& data) const; | 442 | void getResourceData(const std::string& strResTypeName, const std::string& strResName, std::vector<byte>& data) const; |
443 | 443 | ||
444 | /// Returns the data of a certain resource. | 444 | /// Returns the data of a certain resource. |
445 | void getResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector<byte>& data) const; | 445 | void getResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector<byte>& data) const; |
446 | 446 | ||
447 | /// Sets the data of a certain resource. | 447 | /// Sets the data of a certain resource. |
448 | void setResourceData(dword dwResTypeId, dword dwResId, std::vector<byte>& data); | 448 | void setResourceData(dword dwResTypeId, dword dwResId, std::vector<byte>& data); |
449 | /// Sets the data of a certain resource. | 449 | /// Sets the data of a certain resource. |
450 | void setResourceData(dword dwResTypeId, const std::string& strResName, std::vector<byte>& data); | 450 | void setResourceData(dword dwResTypeId, const std::string& strResName, std::vector<byte>& data); |
451 | /// Sets the data of a certain resource. | 451 | /// Sets the data of a certain resource. |
452 | void setResourceData(const std::string& strResTypeName, dword dwResId, std::vector<byte>& data); | 452 | void setResourceData(const std::string& strResTypeName, dword dwResId, std::vector<byte>& data); |
453 | /// Sets the data of a certain resource. | 453 | /// Sets the data of a certain resource. |
454 | void setResourceData(const std::string& strResTypeName, const std::string& strResName, std::vector<byte>& data); | 454 | void setResourceData(const std::string& strResTypeName, const std::string& strResName, std::vector<byte>& data); |
455 | 455 | ||
456 | /// Sets the data of a certain resource. | 456 | /// Sets the data of a certain resource. |
457 | void setResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector<byte>& data); | 457 | void setResourceDataByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, std::vector<byte>& data); |
458 | 458 | ||
459 | /// Returns the ID of a certain resource. | 459 | /// Returns the ID of a certain resource. |
460 | dword getResourceId(dword dwResTypeId, const std::string& strResName) const; | 460 | dword getResourceId(dword dwResTypeId, const std::string& strResName) const; |
461 | /// Returns the ID of a certain resource. | 461 | /// Returns the ID of a certain resource. |
462 | dword getResourceId(const std::string& strResTypeName, const std::string& strResName) const; | 462 | dword getResourceId(const std::string& strResTypeName, const std::string& strResName) const; |
463 | 463 | ||
464 | /// Returns the ID of a certain resource. | 464 | /// Returns the ID of a certain resource. |
465 | dword getResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const; | 465 | dword getResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const; |
466 | 466 | ||
467 | /// Sets the ID of a certain resource. | 467 | /// Sets the ID of a certain resource. |
468 | void setResourceId(dword dwResTypeId, dword dwResId, dword dwNewResId); | 468 | void setResourceId(dword dwResTypeId, dword dwResId, dword dwNewResId); |
469 | /// Sets the ID of a certain resource. | 469 | /// Sets the ID of a certain resource. |
470 | void setResourceId(dword dwResTypeId, const std::string& strResName, dword dwNewResId); | 470 | void setResourceId(dword dwResTypeId, const std::string& strResName, dword dwNewResId); |
471 | /// Sets the ID of a certain resource. | 471 | /// Sets the ID of a certain resource. |
472 | void setResourceId(const std::string& strResTypeName, dword dwResId, dword dwNewResId); | 472 | void setResourceId(const std::string& strResTypeName, dword dwResId, dword dwNewResId); |
473 | /// Sets the ID of a certain resource. | 473 | /// Sets the ID of a certain resource. |
474 | void setResourceId(const std::string& strResTypeName, const std::string& strResName, dword dwNewResId); | 474 | void setResourceId(const std::string& strResTypeName, const std::string& strResName, dword dwNewResId); |
475 | 475 | ||
476 | /// Sets the ID of a certain resource. | 476 | /// Sets the ID of a certain resource. |
477 | void setResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, dword dwNewResId); | 477 | void setResourceIdByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, dword dwNewResId); |
478 | 478 | ||
479 | /// Returns the name of a certain resource. | 479 | /// Returns the name of a certain resource. |
480 | std::string getResourceName(dword dwResTypeId, dword dwResId) const; | 480 | std::string getResourceName(dword dwResTypeId, dword dwResId) const; |
481 | /// Returns the name of a certain resource. | 481 | /// Returns the name of a certain resource. |
482 | std::string getResourceName(const std::string& strResTypeName, dword dwResId) const; | 482 | std::string getResourceName(const std::string& strResTypeName, dword dwResId) const; |
483 | 483 | ||
484 | /// Returns the name of a certain resource. | 484 | /// Returns the name of a certain resource. |
485 | std::string getResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const; | 485 | std::string getResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex) const; |
486 | 486 | ||
487 | /// Sets the name of a certain resource. | 487 | /// Sets the name of a certain resource. |
488 | void setResourceName(dword dwResTypeId, dword dwResId, const std::string& strNewResName); | 488 | void setResourceName(dword dwResTypeId, dword dwResId, const std::string& strNewResName); |
489 | /// Sets the name of a certain resource. | 489 | /// Sets the name of a certain resource. |
490 | void setResourceName(dword dwResTypeId, const std::string& strResName, const std::string& strNewResName); | 490 | void setResourceName(dword dwResTypeId, const std::string& strResName, const std::string& strNewResName); |
491 | /// Sets the name of a certain resource. | 491 | /// Sets the name of a certain resource. |
492 | void setResourceName(const std::string& strResTypeName, dword dwResId, const std::string& strNewResName); | 492 | void setResourceName(const std::string& strResTypeName, dword dwResId, const std::string& strNewResName); |
493 | /// Sets the name of a certain resource. | 493 | /// Sets the name of a certain resource. |
494 | void setResourceName(const std::string& strResTypeName, const std::string& strResName, const std::string& strNewResName); | 494 | void setResourceName(const std::string& strResTypeName, const std::string& strResName, const std::string& strNewResName); |
495 | 495 | ||
496 | /// Sets the name of a certain resource. | 496 | /// Sets the name of a certain resource. |
497 | void setResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, const std::string& strNewResName); | 497 | void setResourceNameByIndex(unsigned int uiResTypeIndex, unsigned int uiResIndex, const std::string& strNewResName); |
498 | }; | 498 | }; |
499 | 499 | ||
500 | /** | 500 | /** |
501 | * Looks through the entire resource tree and returns a const_iterator to the resource specified | 501 | * Looks through the entire resource tree and returns a const_iterator to the resource specified |
502 | * by the parameters. | 502 | * by the parameters. |
503 | * @param restypeid Identifier of the resource type (either ID or name). | 503 | * @param restypeid Identifier of the resource type (either ID or name). |
504 | * @param resid Identifier of the resource (either ID or name). | 504 | * @param resid Identifier of the resource (either ID or name). |
505 | * @return A const_iterator to the specified resource. | 505 | * @return A const_iterator to the specified resource. |
506 | **/ | 506 | **/ |
507 | template<typename S, typename T> | 507 | template<typename S, typename T> |
508 | std::vector<ResourceChild>::const_iterator ResourceDirectory::locateResourceT(S restypeid, T resid) const | 508 | std::vector<ResourceChild>::const_iterator ResourceDirectory::locateResourceT(S restypeid, T resid) const |
509 | { | 509 | { |
510 | typedef bool(ResourceChild::*CompFunc1)(S) const; | 510 | typedef bool(ResourceChild::*CompFunc1)(S) const; |
511 | typedef bool(ResourceChild::*CompFunc2)(T) const; | 511 | typedef bool(ResourceChild::*CompFunc2)(T) const; |
512 | 512 | ||
513 | CompFunc1 comp1 = ResComparer<S>::comp(); | 513 | CompFunc1 comp1 = ResComparer<S>::comp(); |
514 | CompFunc2 comp2 = ResComparer<T>::comp(); | 514 | CompFunc2 comp2 = ResComparer<T>::comp(); |
515 | 515 | ||
516 | std::vector<ResourceChild>::const_iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); | 516 | std::vector<ResourceChild>::const_iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); |
517 | if (Iter == m_rnRoot.children.end()) | 517 | if (Iter == m_rnRoot.children.end()) |
518 | { | 518 | { |
519 | return Iter; | 519 | return Iter; |
520 | } | 520 | } |
521 | 521 | ||
522 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); | 522 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); |
523 | std::vector<ResourceChild>::const_iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); | 523 | std::vector<ResourceChild>::const_iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); |
524 | if (ResIter == currNode->children.end()) | 524 | if (ResIter == currNode->children.end()) |
525 | { | 525 | { |
526 | return ResIter; | 526 | return ResIter; |
527 | } | 527 | } |
528 | 528 | ||
529 | return ResIter; | 529 | return ResIter; |
530 | } | 530 | } |
531 | 531 | ||
532 | /** | 532 | /** |
533 | * Looks through the entire resource tree and returns an iterator to the resource specified | 533 | * Looks through the entire resource tree and returns an iterator to the resource specified |
534 | * by the parameters. | 534 | * by the parameters. |
535 | * @param restypeid Identifier of the resource type (either ID or name). | 535 | * @param restypeid Identifier of the resource type (either ID or name). |
536 | * @param resid Identifier of the resource (either ID or name). | 536 | * @param resid Identifier of the resource (either ID or name). |
537 | * @return An iterator to the specified resource. | 537 | * @return An iterator to the specified resource. |
538 | **/ | 538 | **/ |
539 | template<typename S, typename T> | 539 | template<typename S, typename T> |
540 | std::vector<ResourceChild>::iterator ResourceDirectory::locateResourceT(S restypeid, T resid) | 540 | std::vector<ResourceChild>::iterator ResourceDirectory::locateResourceT(S restypeid, T resid) |
541 | { | 541 | { |
542 | typedef bool(ResourceChild::*CompFunc1)(S) const; | 542 | typedef bool(ResourceChild::*CompFunc1)(S) const; |
543 | typedef bool(ResourceChild::*CompFunc2)(T) const; | 543 | typedef bool(ResourceChild::*CompFunc2)(T) const; |
544 | 544 | ||
545 | CompFunc1 comp1 = ResComparer<S>::comp(); | 545 | CompFunc1 comp1 = ResComparer<S>::comp(); |
546 | CompFunc2 comp2 = ResComparer<T>::comp(); | 546 | CompFunc2 comp2 = ResComparer<T>::comp(); |
547 | 547 | ||
548 | std::vector<ResourceChild>::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); | 548 | std::vector<ResourceChild>::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); |
549 | if (Iter == m_rnRoot.children.end()) | 549 | if (Iter == m_rnRoot.children.end()) |
550 | { | 550 | { |
551 | return Iter; | 551 | return Iter; |
552 | } | 552 | } |
553 | 553 | ||
554 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); | 554 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); |
555 | std::vector<ResourceChild>::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); | 555 | std::vector<ResourceChild>::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); |
556 | if (ResIter == currNode->children.end()) | 556 | if (ResIter == currNode->children.end()) |
557 | { | 557 | { |
558 | return ResIter; | 558 | return ResIter; |
559 | } | 559 | } |
560 | 560 | ||
561 | return ResIter; | 561 | return ResIter; |
562 | } | 562 | } |
563 | 563 | ||
564 | /** | 564 | /** |
565 | * Adds a new resource, resource type and ID are specified by the parameters. | 565 | * Adds a new resource, resource type and ID are specified by the parameters. |
566 | * @param restypeid Identifier of the resource type (either ID or name). | 566 | * @param restypeid Identifier of the resource type (either ID or name). |
567 | * @param resid Identifier of the resource (either ID or name). | 567 | * @param resid Identifier of the resource (either ID or name). |
568 | * @param rc ResourceChild that will be added. | 568 | * @param rc ResourceChild that will be added. |
569 | **/ | 569 | **/ |
570 | template<typename S, typename T> | 570 | template<typename S, typename T> |
571 | int ResourceDirectory::addResourceT(S restypeid, T resid, ResourceChild& rc) | 571 | int ResourceDirectory::addResourceT(S restypeid, T resid, ResourceChild& rc) |
572 | { | 572 | { |
573 | typedef bool(ResourceChild::*CompFunc1)(S) const; | 573 | typedef bool(ResourceChild::*CompFunc1)(S) const; |
574 | typedef bool(ResourceChild::*CompFunc2)(T) const; | 574 | typedef bool(ResourceChild::*CompFunc2)(T) const; |
575 | 575 | ||
576 | CompFunc1 comp1 = ResComparer<S>::comp(); | 576 | CompFunc1 comp1 = ResComparer<S>::comp(); |
577 | CompFunc2 comp2 = ResComparer<T>::comp(); | 577 | CompFunc2 comp2 = ResComparer<T>::comp(); |
578 | 578 | ||
579 | std::vector<ResourceChild>::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); | 579 | std::vector<ResourceChild>::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); |
580 | if (Iter == m_rnRoot.children.end()) | 580 | if (Iter == m_rnRoot.children.end()) |
581 | { | 581 | { |
582 | return 1; | 582 | return 1; |
583 | // throw Exceptions::ResourceTypeDoesNotExist(ResourceDirectoryId, __LINE__); | 583 | // throw Exceptions::ResourceTypeDoesNotExist(ResourceDirectoryId, __LINE__); |
584 | } | 584 | } |
585 | 585 | ||
586 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); | 586 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); |
587 | std::vector<ResourceChild>::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); | 587 | std::vector<ResourceChild>::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); |
588 | if (ResIter != currNode->children.end()) | 588 | if (ResIter != currNode->children.end()) |
589 | { | 589 | { |
590 | return 1; | 590 | return 1; |
591 | // throw Exceptions::EntryAlreadyExists(ResourceDirectoryId, __LINE__); | 591 | // throw Exceptions::EntryAlreadyExists(ResourceDirectoryId, __LINE__); |
592 | } | 592 | } |
593 | 593 | ||
594 | rc.child = new ResourceNode; | 594 | rc.child = new ResourceNode; |
595 | ResourceChild rlnew; | 595 | ResourceChild rlnew; |
596 | rlnew.child = new ResourceLeaf; | 596 | rlnew.child = new ResourceLeaf; |
597 | ResourceNode* currNode2 = static_cast<ResourceNode*>(rc.child); | 597 | ResourceNode* currNode2 = static_cast<ResourceNode*>(rc.child); |
598 | currNode2->children.push_back(rlnew); | 598 | currNode2->children.push_back(rlnew); |
599 | currNode->children.push_back(rc); | 599 | currNode->children.push_back(rc); |
600 | 600 | ||
601 | fixNumberOfEntries<T>::fix(currNode); | 601 | fixNumberOfEntries<T>::fix(currNode); |
602 | fixNumberOfEntries<T>::fix(currNode2); | 602 | fixNumberOfEntries<T>::fix(currNode2); |
603 | 603 | ||
604 | return 0; | 604 | return 0; |
605 | } | 605 | } |
606 | 606 | ||
607 | /** | 607 | /** |
608 | * Removes a resource, resource type and ID are specified by the parameters. | 608 | * Removes a resource, resource type and ID are specified by the parameters. |
609 | * @param restypeid Identifier of the resource type (either ID or name). | 609 | * @param restypeid Identifier of the resource type (either ID or name). |
610 | * @param resid Identifier of the resource (either ID or name). | 610 | * @param resid Identifier of the resource (either ID or name). |
611 | **/ | 611 | **/ |
612 | template<typename S, typename T> | 612 | template<typename S, typename T> |
613 | int ResourceDirectory::removeResourceT(S restypeid, T resid) | 613 | int ResourceDirectory::removeResourceT(S restypeid, T resid) |
614 | { | 614 | { |
615 | typedef bool(ResourceChild::*CompFunc1)(S) const; | 615 | typedef bool(ResourceChild::*CompFunc1)(S) const; |
616 | typedef bool(ResourceChild::*CompFunc2)(T) const; | 616 | typedef bool(ResourceChild::*CompFunc2)(T) const; |
617 | 617 | ||
618 | CompFunc1 comp1 = ResComparer<S>::comp(); | 618 | CompFunc1 comp1 = ResComparer<S>::comp(); |
619 | CompFunc2 comp2 = ResComparer<T>::comp(); | 619 | CompFunc2 comp2 = ResComparer<T>::comp(); |
620 | 620 | ||
621 | std::vector<ResourceChild>::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); | 621 | std::vector<ResourceChild>::iterator Iter = std::find_if(m_rnRoot.children.begin(), m_rnRoot.children.end(), std::bind2nd(std::mem_fun_ref(comp1), restypeid)); |
622 | if (Iter == m_rnRoot.children.end()) | 622 | if (Iter == m_rnRoot.children.end()) |
623 | { | 623 | { |
624 | return 1; | 624 | return 1; |
625 | //throw Exceptions::ResourceTypeDoesNotExist(ResourceDirectoryId, __LINE__); | 625 | //throw Exceptions::ResourceTypeDoesNotExist(ResourceDirectoryId, __LINE__); |
626 | } | 626 | } |
627 | 627 | ||
628 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); | 628 | ResourceNode* currNode = static_cast<ResourceNode*>(Iter->child); |
629 | std::vector<ResourceChild>::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); | 629 | std::vector<ResourceChild>::iterator ResIter = std::find_if(currNode->children.begin(), currNode->children.end(), std::bind2nd(std::mem_fun_ref(comp2), resid)); |
630 | if (ResIter == currNode->children.end()) | 630 | if (ResIter == currNode->children.end()) |
631 | { | 631 | { |
632 | return 1; | 632 | return 1; |
633 | // throw Exceptions::InvalidName(ResourceDirectoryId, __LINE__); | 633 | // throw Exceptions::InvalidName(ResourceDirectoryId, __LINE__); |
634 | } | 634 | } |
635 | 635 | ||
636 | currNode->children.erase(ResIter); | 636 | currNode->children.erase(ResIter); |
637 | 637 | ||
638 | fixNumberOfEntries<T>::fix(currNode); | 638 | fixNumberOfEntries<T>::fix(currNode); |
639 | 639 | ||
640 | return 0; | 640 | return 0; |
641 | } | 641 | } |
642 | 642 | ||
643 | /** | 643 | /** |
644 | * Returns the data of a resource, resource type and ID are specified by the parameters. | 644 | * Returns the data of a resource, resource type and ID are specified by the parameters. |
645 | * @param restypeid Identifier of the resource type (either ID or name). | 645 | * @param restypeid Identifier of the resource type (either ID or name). |
646 | * @param resid Identifier of the resource (either ID or name). | 646 | * @param resid Identifier of the resource (either ID or name). |
647 | * @param data The data of the resource will be written into this vector. | 647 | * @param data The data of the resource will be written into this vector. |
648 | **/ | 648 | **/ |
649 | template<typename S, typename T> | 649 | template<typename S, typename T> |
650 | int ResourceDirectory::getResourceDataT(S restypeid, T resid, std::vector<byte>& data) const | 650 | int ResourceDirectory::getResourceDataT(S restypeid, T resid, std::vector<byte>& data) const |
651 | { | 651 | { |
652 | std::vector<ResourceChild>::const_iterator ResIter = locateResourceT(restypeid, resid); | 652 | std::vector<ResourceChild>::const_iterator ResIter = locateResourceT(restypeid, resid); |
653 | ResourceNode* currNode = static_cast<ResourceNode*>(ResIter->child); | 653 | ResourceNode* currNode = static_cast<ResourceNode*>(ResIter->child); |
654 | ResourceLeaf* currLeaf = static_cast<ResourceLeaf*>(currNode->children[0].child); | 654 | ResourceLeaf* currLeaf = static_cast<ResourceLeaf*>(currNode->children[0].child); |
655 | data.assign(currLeaf->m_data.begin(), currLeaf->m_data.end()); | 655 | data.assign(currLeaf->m_data.begin(), currLeaf->m_data.end()); |
656 | 656 | ||
657 | return 0; | 657 | return 0; |
658 | } | 658 | } |
659 | 659 | ||
660 | /** | 660 | /** |
661 | * Sets the data of a resource, resource type and ID are specified by the parameters. | 661 | * Sets the data of a resource, resource type and ID are specified by the parameters. |
662 | * @param restypeid Identifier of the resource type (either ID or name). | 662 | * @param restypeid Identifier of the resource type (either ID or name). |
663 | * @param resid Identifier of the resource (either ID or name). | 663 | * @param resid Identifier of the resource (either ID or name). |
664 | * @param data The new data of the resource is taken from this vector. | 664 | * @param data The new data of the resource is taken from this vector. |
665 | **/ | 665 | **/ |
666 | template<typename S, typename T> | 666 | template<typename S, typename T> |
667 | int ResourceDirectory::setResourceDataT(S restypeid, T resid, std::vector<byte>& data) | 667 | int ResourceDirectory::setResourceDataT(S restypeid, T resid, std::vector<byte>& data) |
668 | { | 668 | { |
669 | std::vector<ResourceChild>::iterator ResIter = locateResourceT(restypeid, resid); | 669 | std::vector<ResourceChild>::iterator ResIter = locateResourceT(restypeid, resid); |
670 | ResourceNode* currNode = static_cast<ResourceNode*>(ResIter->child); | 670 | ResourceNode* currNode = static_cast<ResourceNode*>(ResIter->child); |
671 | ResourceLeaf* currLeaf = static_cast<ResourceLeaf*>(currNode->children[0].child); | 671 | ResourceLeaf* currLeaf = static_cast<ResourceLeaf*>(currNode->children[0].child); |
672 | currLeaf->m_data.assign(data.begin(), data.end()); | 672 | currLeaf->m_data.assign(data.begin(), data.end()); |
673 | 673 | ||
674 | return 0; | 674 | return 0; |
675 | } | 675 | } |
676 | 676 | ||
677 | /** | 677 | /** |
678 | * Returns the id of a resource, resource type and ID are specified by the parameters. | 678 | * Returns the id of a resource, resource type and ID are specified by the parameters. |
679 | * Note: Calling this function with resid == the ID of the resource makes no sense at all. | 679 | * Note: Calling this function with resid == the ID of the resource makes no sense at all. |
680 | * @param restypeid Identifier of the resource type (either ID or name). | 680 | * @param restypeid Identifier of the resource type (either ID or name). |
681 | * @param resid Identifier of the resource (either ID or name). | 681 | * @param resid Identifier of the resource (either ID or name). |
682 | * @return The ID of the specified resource. | 682 | * @return The ID of the specified resource. |
683 | **/ | 683 | **/ |
684 | template<typename S, typename T> | 684 | template<typename S, typename T> |
685 | dword ResourceDirectory::getResourceIdT(S restypeid, T resid) const | 685 | dword ResourceDirectory::getResourceIdT(S restypeid, T resid) const |
686 | { | 686 | { |
687 | std::vector<ResourceChild>::const_iterator ResIter = locateResourceT(restypeid, resid); | 687 | std::vector<ResourceChild>::const_iterator ResIter = locateResourceT(restypeid, resid); |
688 | return ResIter->entry.irde.Name; | 688 | return ResIter->entry.irde.Name; |
689 | } | 689 | } |
690 | 690 | ||
691 | /** | 691 | /** |
692 | * Sets the id of a resource, resource type and ID are specified by the parameters. | 692 | * Sets the id of a resource, resource type and ID are specified by the parameters. |
693 | * @param restypeid Identifier of the resource type (either ID or name). | 693 | * @param restypeid Identifier of the resource type (either ID or name). |
694 | * @param resid Identifier of the resource (either ID or name). | 694 | * @param resid Identifier of the resource (either ID or name). |
695 | * @param dwNewResId New ID of the resource. | 695 | * @param dwNewResId New ID of the resource. |
696 | **/ | 696 | **/ |
697 | template<typename S, typename T> | 697 | template<typename S, typename T> |
698 | int ResourceDirectory::setResourceIdT(S restypeid, T resid, dword dwNewResId) | 698 | int ResourceDirectory::setResourceIdT(S restypeid, T resid, dword dwNewResId) |
699 | { | 699 | { |
700 | std::vector<ResourceChild>::iterator ResIter = locateResourceT(restypeid, resid); | 700 | std::vector<ResourceChild>::iterator ResIter = locateResourceT(restypeid, resid); |
701 | ResIter->entry.irde.Name = dwNewResId; | 701 | ResIter->entry.irde.Name = dwNewResId; |
702 | return 0; | 702 | return 0; |
703 | } | 703 | } |
704 | 704 | ||
705 | /** | 705 | /** |
706 | * Returns the name of a resource, resource type and ID are specified by the parameters. | 706 | * Returns the name of a resource, resource type and ID are specified by the parameters. |
707 | * Note: Calling this function with resid == the name of the resource makes no sense at all. | 707 | * Note: Calling this function with resid == the name of the resource makes no sense at all. |
708 | * @param restypeid Identifier of the resource type (either ID or name). | 708 | * @param restypeid Identifier of the resource type (either ID or name). |
709 | * @param resid Identifier of the resource (either ID or name). | 709 | * @param resid Identifier of the resource (either ID or name). |
710 | * @return The name of the specified resource. | 710 | * @return The name of the specified resource. |
711 | **/ | 711 | **/ |
712 | template<typename S, typename T> | 712 | template<typename S, typename T> |
713 | std::string ResourceDirectory::getResourceNameT(S restypeid, T resid) const | 713 | std::string ResourceDirectory::getResourceNameT(S restypeid, T resid) const |
714 | { | 714 | { |
715 | std::vector<ResourceChild>::const_iterator ResIter = locateResourceT(restypeid, resid); | 715 | std::vector<ResourceChild>::const_iterator ResIter = locateResourceT(restypeid, resid); |
716 | return ResIter->entry.wstrName; | 716 | return ResIter->entry.wstrName; |
717 | } | 717 | } |
718 | 718 | ||
719 | /** | 719 | /** |
720 | * Sets the name of a resource, resource type and ID are specified by the parameters. | 720 | * Sets the name of a resource, resource type and ID are specified by the parameters. |
721 | * @param restypeid Identifier of the resource type (either ID or name). | 721 | * @param restypeid Identifier of the resource type (either ID or name). |
722 | * @param resid Identifier of the resource (either ID or name). | 722 | * @param resid Identifier of the resource (either ID or name). |
723 | * @param strNewResName The new name of the resource. | 723 | * @param strNewResName The new name of the resource. |
724 | **/ | 724 | **/ |
725 | template<typename S, typename T> | 725 | template<typename S, typename T> |
726 | int ResourceDirectory::setResourceNameT(S restypeid, T resid, std::string strNewResName) | 726 | int ResourceDirectory::setResourceNameT(S restypeid, T resid, std::string strNewResName) |
727 | { | 727 | { |
728 | std::vector<ResourceChild>::iterator ResIter = locateResourceT(restypeid, resid); | 728 | std::vector<ResourceChild>::iterator ResIter = locateResourceT(restypeid, resid); |
729 | ResIter->entry.wstrName = strNewResName; | 729 | ResIter->entry.wstrName = strNewResName; |
730 | 730 | ||
731 | return 0; | 731 | return 0; |
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | #endif | 735 | #endif |