CommonLibSSE NG
FxResponseArgs.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "RE/G/GFxValue.h"
5 
6 namespace RE
7 {
8  template <std::uint32_t SIZE>
10  {
11  public:
14  _values{},
15  _index(1),
16  _pad(0)
17  {}
18 
19  ~FxResponseArgs() override = default; // 00
20 
21  // override (FxResponseArgsBase)
22  std::uint32_t GetValues(GFxValue** a_params) override // 01
23  {
24  *a_params = _values;
25  return _index;
26  }
27 
28  void Add(const GFxValue& a_val)
29  {
30  if (_index > SIZE) {
31  assert(false); // insertion out of bounds
32  return;
33  }
34  _values[_index++] = a_val;
35  }
36 
37  private:
38  GFxValue _values[SIZE + 1]; // 08 - includes response data
39  std::uint32_t _index; // ??
40  std::uint32_t _pad; // ??
41  };
42  static_assert(sizeof(FxResponseArgs<1>) == 0x40);
43 
44  template <std::size_t N>
46  {
47  private:
48  static constexpr std::size_t O = 1;
49 
50  using super = FxResponseArgsBase;
51  using container_type = std::array<GFxValue, N + O>;
52 
53  static_assert(N + O <= static_cast<std::size_t>((std::numeric_limits<std::uint32_t>::max)()));
54 
55  public:
56  using value_type = typename container_type::value_type;
57  using size_type = typename container_type::size_type;
58  using difference_type = typename container_type::difference_type;
59  using reference = typename container_type::reference;
60  using const_reference = typename container_type::const_reference;
61  using pointer = typename container_type::pointer;
62  using const_pointer = typename container_type::const_pointer;
63  using iterator = typename container_type::iterator;
64  using const_iterator = typename container_type::const_iterator;
65  using reverse_iterator = typename container_type::reverse_iterator;
66  using const_reverse_iterator = typename container_type::const_reverse_iterator;
67 
69  super(),
70  _args()
71  {}
72 
75 
76  FxResponseArgsEx(const std::array<GFxValue, N>& a_args) :
77  super(),
78  _args()
79  {
80  for (std::size_t i = 0; i < N; ++i) {
81  _args[i + O] = a_args[i];
82  }
83  }
84 
85  FxResponseArgsEx(std::array<GFxValue, N>&& a_args) :
86  super(),
87  _args()
88  {
89  for (std::size_t i = 0; i < N; ++i) {
90  _args[i + O] = std::move(a_args[i]);
91  }
92  }
93 
94  ~FxResponseArgsEx() override = default;
95 
98 
99  [[nodiscard]] constexpr reference at(size_type a_pos) { return _args.at(a_pos); }
100  [[nodiscard]] constexpr const_reference at(size_type a_pos) const { return _args.at(a_pos); }
101 
102  [[nodiscard]] constexpr reference operator[](size_type a_pos) { return _args[a_pos + O]; }
103  [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const { return _args[a_pos + O]; }
104 
105  [[nodiscard]] constexpr reference front() { return _args.front(); }
106  [[nodiscard]] constexpr const_reference front() const { return _args.front(); }
107 
108  [[nodiscard]] constexpr reference back() { return _args.back(); }
109  [[nodiscard]] constexpr const_reference back() const { return _args.back(); }
110 
111  [[nodiscard]] constexpr pointer data() noexcept { return _args.data(); }
112  [[nodiscard]] constexpr const_pointer data() const noexcept { return _args.data(); }
113 
114  [[nodiscard]] constexpr iterator begin() noexcept { return ++_args.begin(); }
115  [[nodiscard]] constexpr const_iterator begin() const noexcept { return ++_args.begin(); }
116  [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return ++_args.cbegin(); }
117 
118  [[nodiscard]] constexpr iterator end() noexcept { return _args.end(); }
119  [[nodiscard]] constexpr const_iterator end() const noexcept { return _args.end(); }
120  [[nodiscard]] constexpr const_iterator cend() const noexcept { return _args.cend(); }
121 
122  [[nodiscard]] constexpr reverse_iterator rbegin() noexcept { return _args.rbegin(); }
123  [[nodiscard]] constexpr const_reverse_iterator rbegin() const noexcept { return _args.rbegin(); }
124  [[nodiscard]] constexpr const_reverse_iterator crbegin() const noexcept { return _args.crbegin(); }
125 
126  [[nodiscard]] constexpr reverse_iterator rend() noexcept { return --_args.rend(); }
127  [[nodiscard]] constexpr const_reverse_iterator rend() const noexcept { return --_args.rend(); }
128  [[nodiscard]] constexpr const_reverse_iterator crend() const noexcept { return --_args.crend(); }
129 
130  [[nodiscard]] constexpr bool empty() const noexcept { return begin() == end(); }
131 
132  [[nodiscard]] constexpr size_type size() const noexcept { return _args.size() - O; }
133 
134  [[nodiscard]] constexpr size_type max_size() const noexcept { return size(); }
135 
136  protected:
137  std::uint32_t GetValues(GFxValue** a_params) override // 01
138  {
139  *a_params = _args.data();
140  return static_cast<std::uint32_t>(_args.size());
141  }
142 
143  private:
144  container_type _args;
145  };
146 
147  template <std::size_t N>
148  FxResponseArgsEx(const std::array<GFxValue, N>&) -> FxResponseArgsEx<N>;
149 
150  template <std::size_t N>
151  FxResponseArgsEx(std::array<GFxValue, N>&&) -> FxResponseArgsEx<N>;
152 }
Definition: FxResponseArgsBase.h:8
FxResponseArgsBase()=default
Definition: FxResponseArgs.h:46
FxResponseArgsEx(const FxResponseArgsEx &)=default
FxResponseArgsEx(const std::array< GFxValue, N > &a_args)
Definition: FxResponseArgs.h:76
constexpr iterator begin() noexcept
Definition: FxResponseArgs.h:114
constexpr const_iterator cbegin() const noexcept
Definition: FxResponseArgs.h:116
constexpr const_reverse_iterator rbegin() const noexcept
Definition: FxResponseArgs.h:123
constexpr const_reference at(size_type a_pos) const
Definition: FxResponseArgs.h:100
FxResponseArgsEx & operator=(FxResponseArgsEx &&)=default
constexpr size_type max_size() const noexcept
Definition: FxResponseArgs.h:134
FxResponseArgsEx()
Definition: FxResponseArgs.h:68
typename container_type::const_reverse_iterator const_reverse_iterator
Definition: FxResponseArgs.h:66
constexpr reference front()
Definition: FxResponseArgs.h:105
typename container_type::reverse_iterator reverse_iterator
Definition: FxResponseArgs.h:65
~FxResponseArgsEx() override=default
constexpr const_iterator begin() const noexcept
Definition: FxResponseArgs.h:115
constexpr const_reverse_iterator crbegin() const noexcept
Definition: FxResponseArgs.h:124
constexpr reference at(size_type a_pos)
Definition: FxResponseArgs.h:99
FxResponseArgsEx(std::array< GFxValue, N > &&a_args)
Definition: FxResponseArgs.h:85
typename container_type::value_type value_type
Definition: FxResponseArgs.h:56
typename container_type::size_type size_type
Definition: FxResponseArgs.h:57
constexpr pointer data() noexcept
Definition: FxResponseArgs.h:111
typename container_type::iterator iterator
Definition: FxResponseArgs.h:63
constexpr reference operator[](size_type a_pos)
Definition: FxResponseArgs.h:102
typename container_type::const_reference const_reference
Definition: FxResponseArgs.h:60
constexpr size_type size() const noexcept
Definition: FxResponseArgs.h:132
constexpr const_reference back() const
Definition: FxResponseArgs.h:109
std::uint32_t GetValues(GFxValue **a_params) override
Definition: FxResponseArgs.h:137
constexpr iterator end() noexcept
Definition: FxResponseArgs.h:118
FxResponseArgsEx & operator=(const FxResponseArgsEx &)=default
typename container_type::difference_type difference_type
Definition: FxResponseArgs.h:58
constexpr const_pointer data() const noexcept
Definition: FxResponseArgs.h:112
FxResponseArgsEx(FxResponseArgsEx &&)=default
constexpr reference back()
Definition: FxResponseArgs.h:108
typename container_type::const_iterator const_iterator
Definition: FxResponseArgs.h:64
constexpr bool empty() const noexcept
Definition: FxResponseArgs.h:130
typename container_type::reference reference
Definition: FxResponseArgs.h:59
constexpr const_reference front() const
Definition: FxResponseArgs.h:106
constexpr const_iterator cend() const noexcept
Definition: FxResponseArgs.h:120
constexpr const_reference operator[](size_type a_pos) const
Definition: FxResponseArgs.h:103
constexpr const_reverse_iterator crend() const noexcept
Definition: FxResponseArgs.h:128
constexpr const_iterator end() const noexcept
Definition: FxResponseArgs.h:119
constexpr const_reverse_iterator rend() const noexcept
Definition: FxResponseArgs.h:127
typename container_type::const_pointer const_pointer
Definition: FxResponseArgs.h:62
constexpr reverse_iterator rend() noexcept
Definition: FxResponseArgs.h:126
constexpr reverse_iterator rbegin() noexcept
Definition: FxResponseArgs.h:122
typename container_type::pointer pointer
Definition: FxResponseArgs.h:61
Definition: FxResponseArgs.h:10
std::uint32_t GetValues(GFxValue **a_params) override
Definition: FxResponseArgs.h:22
~FxResponseArgs() override=default
void Add(const GFxValue &a_val)
Definition: FxResponseArgs.h:28
FxResponseArgs()
Definition: FxResponseArgs.h:12
Definition: GFxValue.h:92
NiColor() max(const NiColor &a_lhs, const NiColor &a_rhs)
Definition: ColorUtil.h:71
Definition: AbsorbEffect.h:6
FxResponseArgsEx(const std::array< GFxValue, N > &) -> FxResponseArgsEx< N >