$#include "File.h" $#include "Resource.h" class Resource { bool Load(Deserializer& source); bool Save(Serializer& dest) const; tolua_outside bool ResourceLoad @ Load(const String fileName); tolua_outside bool ResourceSave @ Save(const String fileName) const; const String GetName() const; StringHash GetNameHash() const; unsigned GetMemoryUse() const; tolua_readonly tolua_property__get_set String& name; tolua_readonly tolua_property__get_set StringHash nameHash; tolua_readonly tolua_property__get_set unsigned memoryUse; }; ${ static bool ResourceLoad(Resource* resource, const String& fileName) { if (!resource) return false; File file(resource->GetContext()); if (!file.Open(fileName, FILE_READ)) return false; return resource->Save(file); } static bool ResourceSave(const Resource* resource, const String& fileName) { if (!resource) return false; File file(resource->GetContext()); if (!file.Open(fileName, FILE_WRITE)) return false; return resource->Save(file); } $}