CommonLibSSE (powerof3)
Variable.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSFixedString.h"
4 #include "RE/B/BSTSmartPointer.h"
5 #include "RE/T/TypeInfo.h"
6 
7 namespace RE
8 {
9  namespace BSScript
10  {
11  class Array;
12  class Object;
13 
14  class Variable
15  {
16  public:
17  union Value
18  {
19  Value(void* a_val = nullptr);
20  ~Value();
21 
22  // members
23  std::int32_t i;
24  std::uint32_t u;
25  float f;
26  bool b;
27  void* p;
31  };
32  static_assert(sizeof(Value) == 0x8);
33 
35  Variable(const TypeInfo& a_type);
36  Variable(const Variable& a_rhs);
37  Variable(Variable&& a_rhs);
39 
40  Variable& operator=(const Variable& a_rhs);
42 
43  bool operator==(const Variable& a_rhs) const;
44  bool operator!=(const Variable& a_rhs) const;
45  bool operator<(const Variable& a_rhs) const;
46  bool operator>(const Variable& a_rhs) const;
47  bool operator<=(const Variable& a_rhs) const;
48  bool operator>=(const Variable& a_rhs) const;
49 
50  [[nodiscard]] bool IsType(TypeInfo a_typeInfo) const;
51  [[nodiscard]] bool IsArray() const;
52  [[nodiscard]] bool IsBool() const;
53  [[nodiscard]] bool IsFloat() const;
54  [[nodiscard]] bool IsInt() const;
55  [[nodiscard]] bool IsLiteralArray() const;
56  [[nodiscard]] bool IsNoneArray() const;
57  [[nodiscard]] bool IsNoneObject() const;
58  [[nodiscard]] bool IsObject(void) const;
59  [[nodiscard]] bool IsObjectArray() const;
60  [[nodiscard]] bool IsString() const;
61 
62  [[nodiscard]] TypeInfo GetType() const;
63  [[nodiscard]] std::int32_t GetSInt() const;
64  [[nodiscard]] std::uint32_t GetUInt() const;
65  [[nodiscard]] float GetFloat() const;
66  [[nodiscard]] bool GetBool() const;
67  [[nodiscard]] BSTSmartPointer<Array> GetArray() const;
68  [[nodiscard]] BSTSmartPointer<Object> GetObject() const;
69  [[nodiscard]] std::string_view GetString() const;
70 
71  void SetNone();
72  void SetSInt(std::int32_t a_val);
73  void SetUInt(std::uint32_t a_val);
74  void SetFloat(float a_val);
75  void SetBool(bool a_val);
79  void SetString(std::string_view a_val);
80 
81  template <class T>
82  void Pack(T&& a_src);
83 
84  template <class T>
85  [[nodiscard]] T Unpack() const;
86 
87  private:
88  void ChangeType(TypeInfo::RawType a_type);
89  void Cleanup();
90  void Assign(const Variable& a_rhs);
91 
92  // members
93  TypeInfo varType; // 00
94  Value value; // 08
95  };
96  static_assert(sizeof(Variable) == 0x10);
97  }
98 }
Definition: TypeInfo.h:10
RawType
Definition: TypeInfo.h:13
Definition: Variable.h:15
bool IsNoneObject() const
std::uint32_t GetUInt() const
Variable(const Variable &a_rhs)
bool IsLiteralArray() const
void SetFloat(float a_val)
BSTSmartPointer< Array > GetArray() const
bool IsObjectArray() const
void SetObject(BSTSmartPointer< Object > a_val, TypeInfo::RawType a_type)
bool IsObject(void) const
Variable & operator=(const Variable &a_rhs)
void SetString(std::string_view a_val)
void Pack(T &&a_src)
Definition: PackUnpack.h:292
Variable(Variable &&a_rhs)
bool operator<=(const Variable &a_rhs) const
bool IsType(TypeInfo a_typeInfo) const
bool operator>=(const Variable &a_rhs) const
T Unpack() const
Definition: PackUnpack.h:298
Variable & operator=(Variable &&a_rhs)
bool operator!=(const Variable &a_rhs) const
void SetBool(bool a_val)
std::string_view GetString() const
void SetSInt(std::int32_t a_val)
void SetObject(BSTSmartPointer< Object > a_val)
void SetUInt(std::uint32_t a_val)
BSTSmartPointer< Object > GetObject() const
TypeInfo GetType() const
std::int32_t GetSInt() const
bool operator==(const Variable &a_rhs) const
Variable(const TypeInfo &a_type)
bool operator<(const Variable &a_rhs) const
bool operator>(const Variable &a_rhs) const
void SetArray(BSTSmartPointer< Array > a_val)
bool IsNoneArray() const
float GetFloat() const
Definition: BSTSmartPointer.h:37
Definition: AbsorbEffect.h:6
Definition: Variable.h:18
float f
Definition: Variable.h:25
std::int32_t i
Definition: Variable.h:23
std::uint32_t u
Definition: Variable.h:24
void * p
Definition: Variable.h:27
BSFixedString str
Definition: Variable.h:30
BSTSmartPointer< Object > obj
Definition: Variable.h:29
bool b
Definition: Variable.h:26
BSTSmartPointer< Array > arr
Definition: Variable.h:28
Value(void *a_val=nullptr)