00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _ATTRIBUTE_
00019 #define _ATTRIBUTE_
00020
00021 #include <list>
00022 #include <map>
00023 #include <string>
00024
00025 #include "util/Colour.h"
00026 #include "util/Macros.h"
00027 #include "util/Rect.h"
00028 #include "util/Vector2.h"
00029
00030 class Attribute;
00031
00032 DEFINE_STL_TYPE(std::list<const Attribute*>, AttributeList);
00033 DEFINE_STL_TYPE(std::multimap<CONCAT(std::string, Attribute*)>, AttributeMap);
00034
00035 class Attribute
00036 {
00037 private:
00038
00039 std::string m_value;
00040
00041 AttributeMap m_subAttributes;
00042
00043 public:
00044 Attribute() { }
00045 ~Attribute();
00046
00047 AttributeMapConstIterator GetAttributeIterator() const { return m_subAttributes.begin(); }
00048 const AttributeMap & GetAllAttributes() const { return m_subAttributes; }
00049 const Attribute * GetFirstAttribute(const std::string & name) const;
00050 AttributeList GetAttributes(const std::string & name) const;
00051
00052 const std::string & GetValue() const { return m_value; }
00053 void SetValue(const std::string & value) { m_value = value; }
00054
00055 void SetIntegerValue(int nValue);
00056 void SetFloatValue(const float fValue);
00057 void SetBooleanValue(const bool bValue);
00058 void SetVectorValue(const Vector2& value);
00059 void SetColourValue(const Colour& value);
00060 void SetRectValue(const Rect& value);
00061
00062 Attribute * AddAttribute(const std::string & name);
00063 Attribute * AddAttribute(const std::string & name, const std::string & value);
00064
00065 int ParseIntegerValue() const;
00066 float ParseFloatValue() const;
00067 bool ParseBooleanValue() const;
00068 Vector2 ParseVectorValue() const;
00069 Colour ParseColourValue() const;
00070 Rect ParseRectValue() const;
00071 };
00072
00073 #endif