2014-10-21 20:37:43 +00:00
|
|
|
#ifndef RESOURCEFORK_H
|
|
|
|
#define RESOURCEFORK_H
|
2014-10-08 00:52:15 +00:00
|
|
|
|
|
|
|
#include <string>
|
2014-10-12 17:12:10 +00:00
|
|
|
#include <map>
|
|
|
|
#include "ResType.h"
|
2014-10-08 00:52:15 +00:00
|
|
|
|
|
|
|
class Resource
|
|
|
|
{
|
2019-08-18 11:21:00 +00:00
|
|
|
ResType type;
|
|
|
|
short id;
|
|
|
|
std::string name;
|
|
|
|
std::string data;
|
|
|
|
int attr;
|
2014-10-08 00:52:15 +00:00
|
|
|
public:
|
2019-08-18 11:21:00 +00:00
|
|
|
Resource() {}
|
|
|
|
Resource(ResType type, int id, std::string data, std::string name = "", int attr = 0)
|
|
|
|
: type(type), id(id), name(name), data(data), attr(attr) {}
|
|
|
|
|
|
|
|
const std::string& getData() const { return data; }
|
|
|
|
inline ResType getType() const { return type; }
|
|
|
|
inline int getID() const { return id; }
|
|
|
|
inline ResRef getTypeAndID() const { return ResRef(type, id); }
|
|
|
|
std::string getName() const { return name; }
|
|
|
|
int getAttr() const { return attr; }
|
2014-10-08 00:52:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Fork
|
|
|
|
{
|
|
|
|
public:
|
2019-08-18 11:21:00 +00:00
|
|
|
virtual void writeFork(std::ostream& out) const { }
|
|
|
|
virtual ~Fork() {}
|
2014-10-08 00:52:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Resources : public Fork
|
|
|
|
{
|
|
|
|
public:
|
2019-08-18 11:21:00 +00:00
|
|
|
std::map<ResRef, Resource> resources;
|
2015-08-30 23:16:54 +00:00
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
Resources() {}
|
|
|
|
Resources(std::istream& in);
|
|
|
|
void writeFork(std::ostream& out) const;
|
|
|
|
void addResource(Resource res) { resources[res.getTypeAndID()] = res; }
|
|
|
|
void addResources(const Resources& res);
|
2015-08-27 18:49:55 +00:00
|
|
|
|
2019-08-18 11:21:00 +00:00
|
|
|
unsigned countResources() const { return resources.size(); }
|
2014-10-08 00:52:15 +00:00
|
|
|
};
|
|
|
|
|
2014-10-21 20:37:43 +00:00
|
|
|
#endif // RESOURCEFORK_H
|