CommonLibSSE (Parapets fork)
Loading...
Searching...
No Matches
Variable.h
Go to the documentation of this file.
1#pragma once
2
5#include "RE/T/TypeInfo.h"
6
7namespace RE
8{
9 namespace BSScript
10 {
11 class Array;
12 class Object;
13
15 {
16 public:
17 union Value
18 {
19 Value(void* a_val = nullptr);
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);
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 IsArray() const;
51 [[nodiscard]] bool IsBool() const;
52 [[nodiscard]] bool IsFloat() const;
53 [[nodiscard]] bool IsInt() const;
54 [[nodiscard]] bool IsLiteralArray() const;
55 [[nodiscard]] bool IsNoneArray() const;
56 [[nodiscard]] bool IsNoneObject() const;
57 [[nodiscard]] bool IsObject(void) const;
58 [[nodiscard]] bool IsObjectArray() const;
59 [[nodiscard]] bool IsString() const;
60
61 [[nodiscard]] std::int32_t GetSInt() const;
62 [[nodiscard]] std::uint32_t GetUInt() const;
63 [[nodiscard]] float GetFloat() const;
64 [[nodiscard]] bool GetBool() const;
65 [[nodiscard]] BSTSmartPointer<Array> GetArray() const;
66 [[nodiscard]] BSTSmartPointer<Object> GetObject() const;
67 [[nodiscard]] std::string_view GetString() const;
68
69 void SetNone();
70 void SetSInt(std::int32_t a_val);
71 void SetUInt(std::uint32_t a_val);
72 void SetFloat(float a_val);
73 void SetBool(bool a_val);
77 void SetString(std::string_view a_val);
78
79 template <class T>
80 void Pack(T&& a_src);
81
82 template <class T>
83 [[nodiscard]] T Unpack() const;
84
85 private:
86 void ChangeType(TypeInfo::RawType a_type);
87 void Cleanup();
88 void Assign(const Variable& a_rhs);
89
90 // members
91 TypeInfo varType; // 00
92 Value value; // 08
93 };
94 static_assert(sizeof(Variable) == 0x10);
95 }
96}
Definition: TypeInfo.h:10
RawType
Definition: TypeInfo.h:13
Definition: Variable.h:15
bool IsNoneObject() const
BSTSmartPointer< Array > GetArray() const
std::uint32_t GetUInt() const
Variable(const Variable &a_rhs)
bool IsLiteralArray() const
void SetFloat(float a_val)
bool IsObjectArray() const
void SetObject(BSTSmartPointer< Object > a_val, TypeInfo::RawType a_type)
Variable & operator=(const Variable &a_rhs)
bool IsObject(void) const
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 operator>=(const Variable &a_rhs) const
T Unpack() const
Definition: PackUnpack.h:298
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)
Variable & operator=(Variable &&a_rhs)
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)
BSTSmartPointer< Object > GetObject() const
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)