ScummVM API documentation
te_variant.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_VARIANT_H
23 #define TETRAEDGE_TE_TE_VARIANT_H
24 
25 #include "common/str.h"
26 #include "common/types.h"
27 
28 namespace Tetraedge {
29 
30 class TeVariant {
31 public:
32  TeVariant();
33  TeVariant(bool val);
34  TeVariant(double val);
35  TeVariant(const Common::String &val);
36  TeVariant(const char *val);
37  TeVariant(const TeVariant &other);
38 
39  enum VariantType {
40  TypeNone,
41  TypeBoolean,
42  TypeInt32,
43  TypeUInt32,
44  TypeInt64,
45  TypeUInt64,
46  TypeFloat32,
47  TypeFloat64,
48  TypeString
49  };
50 
51  VariantType type() const { return _type; }
52 
53  bool toBoolean(bool *success = nullptr) const;
54  float toFloat32(bool *success = nullptr) const;
55  double toFloat64(bool *success = nullptr) const;
56  int32 toSigned32(bool *success = nullptr) const;
57  int64 toSigned64(bool *success = nullptr) const;
58  Common::String toString(bool *success = nullptr) const;
59  uint32 toUnsigned32(bool *success = nullptr) const;
60  uint64 toUnsigned64(bool *success = nullptr) const;
61 
63  Common::String dumpStr() const;
64 
65 private:
66  uint64 _data;
67  VariantType _type;
68  const Common::String _strVal;
69 };
70 
71 } // end namespace Tetraedge
72 
73 #endif // TETRAEDGE_TE_TE_VARIANT_H
Definition: str.h:59
Definition: detection.h:27
Common::String dumpStr() const
Dump a string representation for debugging.
Definition: te_variant.h:30