Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UTypes.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2014 Dylan Blair
3 //
4 // email: dblair@alumni.cs.utexas.edu
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 
21 #ifndef UTYPES_H
22 #define UTYPES_H
23 
24 //EASTL's eabase.h must go first to define char16_t and char32_t for VS2010
25 #ifdef USE_EASTL
26 #include <EABase/eabase.h>
27 #endif //USE_EASTL
28 
29 #include <cstddef>
30 #include <string.h> //for memset()
31 #include <assert.h>
32 
33 #define MAX_STRING_SIZE 4096
34 
35 #define UNUSED(var) (void)var;
36 
37 namespace OpenSkyNet {
38  namespace Utils {
39  typedef unsigned int uint;
40  #ifdef _WIN32
41  typedef unsigned __int64 uint64;
42  #else
43  typedef unsigned long long uint64;
44  #endif
45 
46  class TaggedUnion {
47  public:
49  private:
50  TAG _tag;
51 
52  union TaggedUnionData {
53  const void* _constPointer;
54  void* _pointer;
55  int _int;
56  float _float;
57  TaggedUnionData() { memset(this, 0, sizeof(TaggedUnionData)); }
58  } _taggedUnionData;
59  public:
60  TaggedUnion(TAG tag_) : _tag(tag_) {}
61  TaggedUnion(const void* const &pointer_) : _tag(CONST_POINTER) { _taggedUnionData._constPointer = pointer_; }
62  TaggedUnion(void* const &pointer_) : _tag(POINTER) { _taggedUnionData._pointer = pointer_; }
63  TaggedUnion(const int& int_) : _tag(INT) { _taggedUnionData._int = int_; }
64  TaggedUnion(const float& float_) : _tag(FLOAT) { _taggedUnionData._float = float_; }
65 
66  inline TAG getTag() const { return _tag; }
67 
68  inline const void* getConstPointer() const { assert(_tag == CONST_POINTER); return _taggedUnionData._constPointer; }
69  inline void* getPointer() const { assert(_tag == POINTER); return _taggedUnionData._pointer; }
70  inline int getInt() const { assert(_tag == INT); return _taggedUnionData._int; }
71  inline float getFloat() const { assert(_tag == FLOAT); return _taggedUnionData._float; }
72 
73  inline void setConstPointer(const void* const &pointer_) { assert(_tag == CONST_POINTER); _taggedUnionData._constPointer = pointer_; }
74  inline void setPointer(void* const &pointer_) { assert(_tag == POINTER); _taggedUnionData._pointer = pointer_; }
75  inline void setInt(const int& int_) { assert(_tag == INT); _taggedUnionData._int = int_; }
76  inline void setFloat(const float& float_) { assert(_tag == FLOAT); _taggedUnionData._float = float_; }
77  };
78  }
79 }
80 
81 #endif //UTYPES_H
TaggedUnion(const float &float_)
Definition: UTypes.h:64
int getInt() const
Definition: UTypes.h:70
void setPointer(void *const &pointer_)
Definition: UTypes.h:74
void * getPointer() const
Definition: UTypes.h:69
TaggedUnion(const void *const &pointer_)
Definition: UTypes.h:61
TaggedUnion(void *const &pointer_)
Definition: UTypes.h:62
float getFloat() const
Definition: UTypes.h:71
TAG getTag() const
Definition: UTypes.h:66
TaggedUnion(TAG tag_)
Definition: UTypes.h:60
void setFloat(const float &float_)
Definition: UTypes.h:76
void setInt(const int &int_)
Definition: UTypes.h:75
unsigned long long uint64
Definition: UTypes.h:43
unsigned int uint
Definition: UTypes.h:39
const void * getConstPointer() const
Definition: UTypes.h:68
Definition: UTypes.h:46
TaggedUnion(const int &int_)
Definition: UTypes.h:63
void setConstPointer(const void *const &pointer_)
Definition: UTypes.h:73
TAG
Definition: UTypes.h:48