#ifndef FILELOADER_H #define FILELOADER_H FILELOADER_H #include #include class FileLoader { public: class Path { public: std::string fullPath; std::string shortPath; Path() { } Path(const std::string & full_path, const std::string & short_path) : fullPath(full_path), shortPath(short_path) { } std::string toString() const { std::string ret; if (shortPath != "") ret += shortPath + ","; if (fullPath != "") ret += fullPath; return ret; } }; class Buffer { public: char * data; int size; Buffer(int sz) { size = sz; data = new char[size]; _refcnt = new int; *_refcnt = 1; m_alloced = true; } Buffer(char * data, int sz) { size = sz; this->data = data; m_alloced = false; } void copy(const Buffer & other) { data = other.data; size = other.size; m_alloced = other.m_alloced; if (m_alloced) { _refcnt = other._refcnt; (*_refcnt)++; } } Buffer(const Buffer & other) { copy(other); } Buffer & operator=(const Buffer & other) { copy(other); return *this; } ~Buffer() { if (m_alloced) { (*_refcnt)--; if (*_refcnt < 1) { delete _refcnt; delete data; } } } protected: int * _refcnt; bool m_alloced; }; virtual int getSize(const Path & path) = 0; virtual Buffer load(const Path & path) = 0; }; #endif