diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/prince/resource.h | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/engines/prince/resource.h b/engines/prince/resource.h index 6c823a7702..a2cd8a6262 100644 --- a/engines/prince/resource.h +++ b/engines/prince/resource.h @@ -32,66 +32,66 @@ namespace Prince { namespace Resource { - template <typename T> - bool loadFromStream(T &resource, Common::SeekableReadStream &stream) { - return resource.loadStream(stream); - } - - template<typename T> - bool loadResource(T *resource, const char *resourceName, bool required) { - Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName)); - if (!stream) { - if (required) - error("Can't load %s", resourceName); - return false; - } +template <typename T> +bool loadFromStream(T &resource, Common::SeekableReadStream &stream) { + return resource.loadStream(stream); +} - return loadFromStream(*resource, *stream); +template<typename T> +bool loadResource(T *resource, const char *resourceName, bool required) { + Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName)); + if (!stream) { + if (required) + error("Can't load %s", resourceName); + return false; } - template <typename T> - bool loadResource(Common::Array<T> &array, Common::SeekableReadStream &stream, bool required = true) { - T t; - while (t.loadFromStream(stream)) - array.push_back(t); + return loadFromStream(*resource, *stream); +} - return true; - } +template <typename T> +bool loadResource(Common::Array<T> &array, Common::SeekableReadStream &stream, bool required = true) { + T t; + while (t.loadFromStream(stream)) + array.push_back(t); + return true; +} - template <typename T> - bool loadResource(Common::Array<T> &array, const char *resourceName, bool required = true) { - Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName)); - if (!stream) { - if (required) - error("Can't load %s", resourceName); - return false; - } - return loadResource(array, *stream, required); +template <typename T> +bool loadResource(Common::Array<T> &array, const char *resourceName, bool required = true) { + Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName)); + if (!stream) { + if (required) + error("Can't load %s", resourceName); + return false; } - template <typename T> - bool loadResource(Common::Array<T *> &array, const char *resourceName, bool required = true) { + return loadResource(array, *stream, required); +} - Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName)); - if (!stream) { - if (required) - error("Can't load %s", resourceName); - return false; - } +template <typename T> +bool loadResource(Common::Array<T *> &array, const char *resourceName, bool required = true) { - // FIXME: This is stupid. Maybe loadFromStream should be helper method that returns initialized object - while (true) { - T* t = new T(); - if (!t->loadFromStream(*stream)) { - delete t; - break; - } - array.push_back(t); + Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember(resourceName)); + if (!stream) { + if (required) + error("Can't load %s", resourceName); + return false; + } + + // FIXME: This is stupid. Maybe loadFromStream should be helper method that returns initialized object + while (true) { + T* t = new T(); + if (!t->loadFromStream(*stream)) { + delete t; + break; } - return true; + array.push_back(t); } + return true; +} } |