OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
variant.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_ESM_VARIANT_H
2 #define OPENMW_ESM_VARIANT_H
3 
4 #include <string>
5 #include <iosfwd>
6 
7 namespace ESM
8 {
9  class ESMReader;
10  class ESMWriter;
11 
12  enum VarType
13  {
16  VT_Short, // stored as a float, kinda
18  VT_Long, // stored as a float
21  };
22 
23  class VariantDataBase;
24 
25  class Variant
26  {
29 
30  public:
31 
32  enum Format
33  {
37  Format_Local // local script variables in save game files
38  };
39 
40  Variant();
41 
42  Variant (const std::string& value);
43  Variant (int value);
44  Variant (float value);
45 
46  ~Variant();
47 
48  Variant& operator= (const Variant& variant);
49 
50  Variant (const Variant& variant);
51 
52  VarType getType() const;
53 
54  std::string getString() const;
56 
57  int getInteger() const;
60 
61  float getFloat() const;
63 
64  void read (ESMReader& esm, Format format);
65 
66  void write (ESMWriter& esm, Format format) const;
67 
68  void write (std::ostream& stream) const;
70 
71  void setType (VarType type);
72 
73  void setString (const std::string& value);
75 
76  void setInteger (int value);
78 
79  void setFloat (float value);
81 
82  bool isEqual (const Variant& value) const;
83  };
84 
85  std::ostream& operator<<(std::ostream& stream, const Variant& value);
86 
87  bool operator== (const Variant& left, const Variant& right);
88  bool operator!= (const Variant& left, const Variant& right);
89 }
90 
91 #endif
Variant & operator=(const Variant &variant)
Definition: variant.cpp:50
Definition: variant.hpp:37
VarType
Definition: variant.hpp:12
bool operator==(const CellId &left, const CellId &right)
Definition: cellid.cpp:29
Definition: esmreader.hpp:21
Definition: variant.hpp:36
void setType(VarType type)
Definition: variant.cpp:253
void setFloat(float value)
Will throw an exception, if type is not compatible with float.
Definition: variant.cpp:306
Variant()
Definition: variant.cpp:19
Definition: variant.hpp:15
Format
Definition: variant.hpp:32
Definition: variant.hpp:14
Definition: esmwriter.hpp:17
bool isEqual(const Variant &value) const
Definition: variant.cpp:314
~Variant()
Definition: variant.cpp:45
Definition: variantimp.hpp:10
std::ostream & operator<<(std::ostream &stream, const Variant &value)
Definition: variant.cpp:327
Definition: variant.hpp:18
Definition: variant.hpp:16
int getInteger() const
Definition: variant.cpp:82
Definition: variant.hpp:35
void setString(const std::string &value)
Will throw an exception, if type is not compatible with string.
Definition: variant.cpp:290
VarType getType() const
Definition: variant.cpp:69
Definition: variant.hpp:20
Definition: variant.hpp:25
Definition: variant.hpp:34
std::string getString() const
Will throw an exception, if value can not be represented as a string.
Definition: variant.cpp:74
float getFloat() const
Will throw an exception, if value can not be represented as a float value.
Definition: variant.cpp:90
Definition: variant.hpp:19
void read(ESMReader &esm, Format format)
Definition: variant.cpp:98
void write(ESMWriter &esm, Format format) const
Definition: variant.cpp:189
Definition: variant.hpp:17
void setInteger(int value)
Will throw an exception, if type is not compatible with integer.
Definition: variant.cpp:298
bool operator!=(const CellId &left, const CellId &right)
Definition: cellid.cpp:35
VariantDataBase * mData
Definition: variant.hpp:28
VarType mType
Definition: variant.hpp:27