OpenMW
|
00001 #ifndef OPENMW_ESM_VARIANT_H 00002 #define OPENMW_ESM_VARIANT_H 00003 00004 #include <string> 00005 #include <iosfwd> 00006 00007 namespace ESM 00008 { 00009 class ESMReader; 00010 class ESMWriter; 00011 00012 enum VarType 00013 { 00014 VT_Unknown = 0, 00015 VT_None, 00016 VT_Short, // stored as a float, kinda 00017 VT_Int, 00018 VT_Long, // stored as a float 00019 VT_Float, 00020 VT_String 00021 }; 00022 00023 class VariantDataBase; 00024 00025 class Variant 00026 { 00027 VarType mType; 00028 VariantDataBase *mData; 00029 00030 public: 00031 00032 enum Format 00033 { 00034 Format_Global, 00035 Format_Gmst, 00036 Format_Info 00037 }; 00038 00039 Variant(); 00040 00041 ~Variant(); 00042 00043 Variant& operator= (const Variant& variant); 00044 00045 Variant (const Variant& variant); 00046 00047 VarType getType() const; 00048 00049 std::string getString() const; 00051 00052 int getInteger() const; 00055 00056 float getFloat() const; 00058 00059 void read (ESMReader& esm, Format format); 00060 00061 void write (ESMWriter& esm, Format format) const; 00062 00063 void write (std::ostream& stream) const; 00065 00066 void setType (VarType type); 00067 00068 void setString (const std::string& value); 00070 00071 void setInteger (int value); 00073 00074 void setFloat (float value); 00076 00077 bool isEqual (const Variant& value) const; 00078 }; 00079 00080 std::ostream& operator<<(std::ostream& stream, const Variant& value); 00081 00082 bool operator== (const Variant& left, const Variant& right); 00083 bool operator!= (const Variant& left, const Variant& right); 00084 } 00085 00086 #endif