CommonLibSSE NG
BGSKeywordForm.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BGSKeyword.h"
4 #include "RE/B/BSContainer.h"
6 
7 namespace RE
8 {
9  class BGSKeyword;
10 
12  {
13  public:
14  inline static constexpr auto RTTI = RTTI_BGSKeywordForm;
15 
16  ~BGSKeywordForm() override; // 00
17 
18  // override (BaseFormComponent)
19  void InitializeDataComponent() override; // 01 - { return; }
20  void ClearDataComponent() override; // 02
21  void CopyComponent(BaseFormComponent* a_rhs) override; // 03
22 
23  // add
24  [[nodiscard]] virtual bool HasKeyword(const BGSKeyword* a_keyword) const; // 04
25  [[nodiscard]] virtual BGSKeyword* GetDefaultKeyword() const; // 05 - { return 0; }
26 
27  bool AddKeyword(BGSKeyword* a_keyword);
28  bool AddKeywords(const std::vector<BGSKeyword*>& a_keywords);
29  [[nodiscard]] bool ContainsKeywordString(std::string_view a_editorID) const;
30  void ForEachKeyword(std::function<BSContainer::ForEachResult(BGSKeyword*)> a_callback) const;
31  [[nodiscard]] std::optional<BGSKeyword*> GetKeywordAt(std::uint32_t a_idx) const;
32  [[nodiscard]] std::optional<std::uint32_t> GetKeywordIndex(BGSKeyword* a_keyword) const;
33  [[nodiscard]] std::uint32_t GetNumKeywords() const;
34  [[nodiscard]] bool HasKeywordID(FormID a_formID) const;
35  [[nodiscard]] bool HasKeywordString(std::string_view a_editorID) const;
36  bool RemoveKeyword(std::uint32_t a_index);
37  bool RemoveKeyword(BGSKeyword* a_keyword);
38  bool RemoveKeywords(const std::vector<BGSKeyword*>& a_keywords);
39 
40  [[nodiscard]] std::span<BGSKeyword*> GetKeywords()
41  {
42  return { keywords, numKeywords };
43  }
44 
45  [[nodiscard]] std::span<BGSKeyword* const> GetKeywords() const
46  {
47  return { keywords, numKeywords };
48  }
49 
50  // members
51  BGSKeyword** keywords; // 08 - KWDA
52  std::uint32_t numKeywords; // 10 - KSIZ
53  std::uint32_t pad14; // 14
54 
55  private:
56  void CopyKeywords(const std::vector<RE::BGSKeyword*>& a_copiedData);
57  };
58  static_assert(sizeof(BGSKeywordForm) == 0x18);
59 }
Definition: BGSKeywordForm.h:12
std::optional< std::uint32_t > GetKeywordIndex(BGSKeyword *a_keyword) const
std::uint32_t numKeywords
Definition: BGSKeywordForm.h:52
std::optional< BGSKeyword * > GetKeywordAt(std::uint32_t a_idx) const
std::uint32_t pad14
Definition: BGSKeywordForm.h:53
bool HasKeywordID(FormID a_formID) const
bool RemoveKeyword(BGSKeyword *a_keyword)
static constexpr auto RTTI
Definition: BGSKeywordForm.h:14
std::span< BGSKeyword *const > GetKeywords() const
Definition: BGSKeywordForm.h:45
bool AddKeyword(BGSKeyword *a_keyword)
void InitializeDataComponent() override
BGSKeyword ** keywords
Definition: BGSKeywordForm.h:51
bool AddKeywords(const std::vector< BGSKeyword * > &a_keywords)
bool ContainsKeywordString(std::string_view a_editorID) const
std::span< BGSKeyword * > GetKeywords()
Definition: BGSKeywordForm.h:40
virtual bool HasKeyword(const BGSKeyword *a_keyword) const
virtual BGSKeyword * GetDefaultKeyword() const
bool RemoveKeywords(const std::vector< BGSKeyword * > &a_keywords)
~BGSKeywordForm() override
void CopyComponent(BaseFormComponent *a_rhs) override
void ForEachKeyword(std::function< BSContainer::ForEachResult(BGSKeyword *)> a_callback) const
bool HasKeywordString(std::string_view a_editorID) const
void ClearDataComponent() override
std::uint32_t GetNumKeywords() const
bool RemoveKeyword(std::uint32_t a_index)
Definition: BGSKeyword.h:10
Definition: BaseFormComponent.h:8
ForEachResult
Definition: BSContainer.h:6
Definition: AbsorbEffect.h:6
std::uint32_t FormID
Definition: BSCoreTypes.h:5
constexpr REL::VariantID RTTI_BGSKeywordForm(513855, 392223, 0x1ed6e18)