comparison Resources/EmbedResources.py @ 64:71c4a4abe90b orthanc-renaming

renaming of resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 16 Sep 2012 09:35:31 +0200
parents 601ee9b7f2c7
children 5133cfc8db86
comparison
equal deleted inserted replaced
63:f1d0470ff334 64:71c4a4abe90b
86 header.write(""" 86 header.write("""
87 #pragma once 87 #pragma once
88 88
89 #include <string> 89 #include <string>
90 90
91 namespace Palanthir 91 namespace Orthanc
92 { 92 {
93 namespace EmbeddedResources 93 namespace EmbeddedResources
94 { 94 {
95 enum FileResourceId 95 enum FileResourceId
96 { 96 {
177 177
178 cpp = open(sys.argv[1] + '.cpp', 'w') 178 cpp = open(sys.argv[1] + '.cpp', 'w')
179 179
180 cpp.write(""" 180 cpp.write("""
181 #include "%s.h" 181 #include "%s.h"
182 #include "%s/Core/PalanthirException.h" 182 #include "%s/Core/OrthancException.h"
183 183
184 #include <stdint.h> 184 #include <stdint.h>
185 #include <string.h> 185 #include <string.h>
186 186
187 namespace Palanthir 187 namespace Orthanc
188 { 188 {
189 namespace EmbeddedResources 189 namespace EmbeddedResources
190 { 190 {
191 """ % (os.path.basename(sys.argv[1]), 191 """ % (os.path.basename(sys.argv[1]),
192 os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))) 192 os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))))
216 cpp.write(' case %s:\n' % name) 216 cpp.write(' case %s:\n' % name)
217 cpp.write(' return resource%dBuffer;\n' % resources[name]['Index']) 217 cpp.write(' return resource%dBuffer;\n' % resources[name]['Index'])
218 218
219 cpp.write(""" 219 cpp.write("""
220 default: 220 default:
221 throw PalanthirException(ErrorCode_ParameterOutOfRange); 221 throw OrthancException(ErrorCode_ParameterOutOfRange);
222 } 222 }
223 } 223 }
224 224
225 size_t GetFileResourceSize(FileResourceId id) 225 size_t GetFileResourceSize(FileResourceId id)
226 { 226 {
233 cpp.write(' case %s:\n' % name) 233 cpp.write(' case %s:\n' % name)
234 cpp.write(' return resource%dSize;\n' % resources[name]['Index']) 234 cpp.write(' return resource%dSize;\n' % resources[name]['Index'])
235 235
236 cpp.write(""" 236 cpp.write("""
237 default: 237 default:
238 throw PalanthirException(ErrorCode_ParameterOutOfRange); 238 throw OrthancException(ErrorCode_ParameterOutOfRange);
239 } 239 }
240 } 240 }
241 """) 241 """)
242 242
243 243
258 cpp.write(' case %s:\n' % name) 258 cpp.write(' case %s:\n' % name)
259 isFirst = True 259 isFirst = True
260 for path in resources[name]['Files']: 260 for path in resources[name]['Files']:
261 cpp.write(' if (!strcmp(path, "%s"))\n' % path) 261 cpp.write(' if (!strcmp(path, "%s"))\n' % path)
262 cpp.write(' return resource%dBuffer;\n' % resources[name]['Files'][path]['Index']) 262 cpp.write(' return resource%dBuffer;\n' % resources[name]['Files'][path]['Index'])
263 cpp.write(' throw PalanthirException("Unknown path in a directory resource");\n\n') 263 cpp.write(' throw OrthancException("Unknown path in a directory resource");\n\n')
264 264
265 cpp.write(""" default: 265 cpp.write(""" default:
266 throw PalanthirException(ErrorCode_ParameterOutOfRange); 266 throw OrthancException(ErrorCode_ParameterOutOfRange);
267 } 267 }
268 } 268 }
269 269
270 size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path) 270 size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path)
271 { 271 {
278 cpp.write(' case %s:\n' % name) 278 cpp.write(' case %s:\n' % name)
279 isFirst = True 279 isFirst = True
280 for path in resources[name]['Files']: 280 for path in resources[name]['Files']:
281 cpp.write(' if (!strcmp(path, "%s"))\n' % path) 281 cpp.write(' if (!strcmp(path, "%s"))\n' % path)
282 cpp.write(' return resource%dSize;\n' % resources[name]['Files'][path]['Index']) 282 cpp.write(' return resource%dSize;\n' % resources[name]['Files'][path]['Index'])
283 cpp.write(' throw PalanthirException("Unknown path in a directory resource");\n\n') 283 cpp.write(' throw OrthancException("Unknown path in a directory resource");\n\n')
284 284
285 cpp.write(""" default: 285 cpp.write(""" default:
286 throw PalanthirException(ErrorCode_ParameterOutOfRange); 286 throw OrthancException(ErrorCode_ParameterOutOfRange);
287 } 287 }
288 } 288 }
289 """) 289 """)
290 290
291 291