OpenMW
components/esm/variantimp.hpp
Go to the documentation of this file.
00001 #ifndef OPENMW_ESM_VARIANTIMP_H
00002 #define OPENMW_ESM_VARIANTIMP_H
00003 
00004 #include <string>
00005 
00006 #include "variant.hpp"
00007 
00008 namespace ESM
00009 {
00010     class VariantDataBase
00011     {
00012         public:
00013 
00014             virtual ~VariantDataBase();
00015 
00016             virtual VariantDataBase *clone() const = 0;
00017 
00018             virtual std::string getString (bool default_ = false) const;
00026 
00027             virtual int getInteger (bool default_ = false) const;
00034 
00035             virtual float getFloat (bool default_ = false) const;
00041 
00042             virtual void setString (const std::string& value);
00046 
00047             virtual void setInteger (int value);
00051 
00052             virtual void setFloat (float value);
00056 
00057             virtual void read (ESMReader& esm, Variant::Format format, VarType type) = 0;
00059 
00060             virtual void write (ESMWriter& esm, Variant::Format format, VarType type) const = 0;
00062 
00063             virtual bool isEqual (const VariantDataBase& value) const = 0;
00065 
00066     };
00067 
00068     class VariantStringData : public VariantDataBase
00069     {
00070             std::string mValue;
00071 
00072         public:
00073 
00074             VariantStringData (const VariantDataBase *data = 0);
00077 
00078             virtual VariantDataBase *clone() const;
00079 
00080             virtual std::string getString (bool default_ = false) const;
00086 
00087             virtual void setString (const std::string& value);
00089 
00090             virtual void read (ESMReader& esm, Variant::Format format, VarType type);
00092 
00093             virtual void write (ESMWriter& esm, Variant::Format format, VarType type) const;
00095 
00096             virtual bool isEqual (const VariantDataBase& value) const;
00098     };
00099 
00100     class VariantIntegerData : public VariantDataBase
00101     {
00102             int mValue;
00103 
00104         public:
00105 
00106             VariantIntegerData (const VariantDataBase *data = 0);
00109 
00110             virtual VariantDataBase *clone() const;
00111 
00112             virtual int getInteger (bool default_ = false) const;
00117 
00118             virtual float getFloat (bool default_ = false) const;
00122 
00123             virtual void setInteger (int value);
00125 
00126             virtual void setFloat (float value);
00128 
00129             virtual void read (ESMReader& esm, Variant::Format format, VarType type);
00131 
00132             virtual void write (ESMWriter& esm, Variant::Format format, VarType type) const;
00134 
00135             virtual bool isEqual (const VariantDataBase& value) const;
00137     };
00138 
00139     class VariantFloatData : public VariantDataBase
00140     {
00141             float mValue;
00142 
00143         public:
00144 
00145             VariantFloatData (const VariantDataBase *data = 0);
00148 
00149             virtual VariantDataBase *clone() const;
00150 
00151             virtual int getInteger (bool default_ = false) const;
00156 
00157             virtual float getFloat (bool default_ = false) const;
00161 
00162             virtual void setInteger (int value);
00164 
00165             virtual void setFloat (float value);
00167 
00168             virtual void read (ESMReader& esm, Variant::Format format, VarType type);
00170 
00171             virtual void write (ESMWriter& esm, Variant::Format format, VarType type) const;
00173 
00174             virtual bool isEqual (const VariantDataBase& value) const;
00176     };
00177 }
00178 
00179 #endif