1 /* 2 * Copyright (c) 2005-2010, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Author: 6 * DarkWyrm <darkwyrm@gmail.com> 7 */ 8 #ifndef RESOURCE_DATA_H 9 #define RESOURCE_DATA_H 10 11 #include <fs_attr.h> 12 #include <Resources.h> 13 #include <Node.h> 14 #include <String.h> 15 16 class ResourceData 17 { 18 public: 19 ResourceData(void); 20 ResourceData(const type_code &code, const int32 &id, 21 const char *name, char *data, 22 const size_t &length); 23 ResourceData(const ResourceData &data); 24 ~ResourceData(void); 25 void SetTo(const type_code &code, const int32 &id, 26 const char *name, char *data, const size_t &length); 27 ResourceData & operator=(const ResourceData &data); 28 29 bool SetFromResource(const int32 &index, BResources &res); 30 bool SetFromAttribute(const char *name, BNode &node); 31 GetType(void)32 type_code GetType(void) const { return fType; } GetTypeString(void)33 const char * GetTypeString(void) const { return fTypeString.String(); } 34 void SetType(const type_code &code); 35 GetID(void)36 int32 GetID(void) const { return fID; } GetIDString(void)37 const char * GetIDString(void) const { return fIDString.String(); } 38 void SetID(const int32 &id); 39 GetName(void)40 const char * GetName(void) const { return fName.String(); } SetName(const char * name)41 void SetName(const char *name) { fName = name; } 42 GetData(void)43 char * GetData(void) { return fData; } GetLength(void)44 size_t GetLength(void) const { return fLength; } 45 void SetData(const char *data, const size_t &size); 46 IsAttribute(void)47 bool IsAttribute(void) const { return fAttr; } SetAttribute(const bool & value)48 void SetAttribute(const bool &value) { fAttr = value; } 49 50 private: 51 int32 fType; 52 BString fTypeString; 53 int32 fID; 54 BString fIDString; 55 BString fName; 56 char *fData; 57 size_t fLength; 58 bool fAttr; 59 }; 60 61 #endif 62