Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
NamePermissionList.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Containers/Map.h"
7#include "Containers/StringFwd.h"
8#include "Containers/StringView.h"
9#include "CoreTypes.h"
10#include "Delegates/Delegate.h"
11#include "HAL/PlatformCrt.h"
12#include "Templates/SharedPointer.h"
13#include "UObject/NameTypes.h"
14
15class FString;
16
17/** List of owner names that requested a specific item filtered, allows unregistering specific set of changes by a given plugin or system */
19
21{
22public:
24 virtual ~FNamePermissionList() {}
25
26 /** Returns true if passes filter restrictions using exact match */
27 bool PassesFilter(const FName Item) const;
28
29 /**
30 * Add item to DenyList, this specific item will be filtered out.
31 * @return whether the filters changed.
32 */
33 bool AddDenyListItem(const FName OwnerName, const FName Item);
34
35 /**
36 * Add item to allowlist after which all items not in the allowlist will be filtered out.
37 * @return whether the filters changed.
38 */
39 bool AddAllowListItem(const FName OwnerName, const FName Item);
40
41 /**
42 * Removes a previously-added item from the DenyList.
43 * @return whether the filters changed.
44 */
45 bool RemoveDenyListItem(const FName OwnerName, const FName Item);
46
47 /**
48 * Removes a previously-added item from the allowlist.
49 * @return whether the filters changed.
50 */
51 bool RemoveAllowListItem(const FName OwnerName, const FName Item);
52
53 /**
54 * Set to filter out all items.
55 * @return whether the filters changed.
56 */
57 bool AddDenyListAll(const FName OwnerName);
58
59 /** True if has filters active */
60 bool HasFiltering() const;
61
62 /** Gathers the names of all the owners in this DenyList. */
64
65 /**
66 * Removes all filtering changes associated with a specific owner name.
67 * @return whether the filters changed.
68 */
69 bool UnregisterOwner(const FName OwnerName);
70
71 /**
72 * Removes all filtering changes associated with the specified list of owner names.
73 * @return whether the filters changed.
74 */
75 bool UnregisterOwners(const TArray<FName>& OwnerNames);
76
77 /**
78 * Add the specified filters to this one.
79 * @return whether the filters changed.
80 */
81 bool Append(const FNamePermissionList& Other);
82
83 /**
84 * Unregisters specified owners then adds specified filters in one operation (to avoid multiple filters changed events).
85 * @return whether the filters changed.
86 */
87 bool UnregisterOwnersAndAppend(const TArray<FName>& OwnerNamesToRemove, const FNamePermissionList& FiltersToAdd);
88
89 /** Get raw DenyList */
90 const TMap<FName, FPermissionListOwners>& GetDenyList() const { return DenyList; }
91
92 /** Get raw allowlist */
93 const TMap<FName, FPermissionListOwners>& GetAllowList() const { return AllowList; }
94
95 /** Are all items set to be filtered out */
96 bool IsDenyListAll() const { return DenyListAll.Num() > 0; }
97
98 /** Triggered when filter changes */
99 FSimpleMulticastDelegate& OnFilterChanged() { return OnFilterChangedDelegate; }
100
101protected:
102
103 /** List if items to filter out */
105
106 /** List of items to allow, if not empty all items will be filtered out unless they are in the list */
108
109 /** List of owner names that requested all items to be filtered out */
111
112 /** Triggered when filter changes */
113 FSimpleMulticastDelegate OnFilterChangedDelegate;
114
115 /** Temporarily prevent delegate from being triggered */
117};
118
120{
121 Default, // Default path permission list
122 ClassPaths // Class permission list
123};
124
126{
127public:
129 : ListType(InType)
130 {
131 }
133
134 /** Returns true if passes filter restrictions using exact match */
135 bool PassesFilter(const FStringView Item) const;
136
137 /** Returns true if passes filter restrictions using exact match */
138 bool PassesFilter(const FName Item) const;
139
140 /** Returns true if passes filter restrictions using exact match */
141 bool PassesFilter(const TCHAR* Item) const;
142
143 /** Returns true if passes filter restrictions for path */
144 bool PassesStartsWithFilter(const FStringView Item, const bool bAllowParentPaths = false) const;
145
146 /** Returns true if passes filter restrictions for path */
147 bool PassesStartsWithFilter(const FName Item, const bool bAllowParentPaths = false) const;
148
149 /** Returns true if passes filter restrictions for path */
150 bool PassesStartsWithFilter(const TCHAR* Item, const bool bAllowParentPaths = false) const;
151
152 /**
153 * Add item to DenyList, this specific item will be filtered out.
154 * @return whether the filters changed.
155 */
156 bool AddDenyListItem(const FName OwnerName, const FStringView Item);
157
158 /**
159 * Add item to DenyList, this specific item will be filtered out.
160 * @return whether the filters changed.
161 */
162 bool AddDenyListItem(const FName OwnerName, const FName Item);
163
164 /**
165 * Add item to DenyList, this specific item will be filtered out.
166 * @return whether the filters changed.
167 */
168 bool AddDenyListItem(const FName OwnerName, const TCHAR* Item);
169
170 /**
171 * Remove item from the DenyList
172 * @return whether the filters changed
173 */
174 bool RemoveDenyListItem(const FName OwnerName, const FStringView Item);
175
176 /**
177 * Remove item from the DenyList
178 * @return whether the filters changed
179 */
180 bool RemoveDenyListItem(const FName OwnerName, const FName Item);
181
182 /**
183 * Remove item from the DenyList
184 * @return whether the filters changed
185 */
186 bool RemoveDenyListItem(const FName OwnerName, const TCHAR* Item);
187
188 /**
189 * Add item to allowlist after which all items not in the allowlist will be filtered out.
190 * @return whether the filters changed.
191 */
192 bool AddAllowListItem(const FName OwnerName, const FStringView Item);
193
194 /**
195 * Add item to allowlist after which all items not in the allowlist will be filtered out.
196 * @return whether the filters changed.
197 */
198 bool AddAllowListItem(const FName OwnerName, const FName Item);
199
200 /**
201 * Add item to allowlist after which all items not in the allowlist will be filtered out.
202 * @return whether the filters changed.
203 */
204 bool AddAllowListItem(const FName OwnerName, const TCHAR* Item);
205
206 /**
207 * Remove item from the AllowList
208 * @return whether the filters changed
209 */
210 bool RemoveAllowListItem(const FName OwnerName, const FStringView Item);
211
212 /**
213 * Remove item from the AllowList
214 * @return whether the filters changed
215 */
216 bool RemoveAllowListItem(const FName OwnerName, const FName Item);
217
218 /**
219 * Remove item from the AllowList
220 * @return whether the filters changed
221 */
222 bool RemoveAllowListItem(const FName OwnerName, const TCHAR* Item);
223
224 /**
225 * Set to filter out all items.
226 * @return whether the filters changed.
227 */
228 bool AddDenyListAll(const FName OwnerName);
229
230 /** True if has filters active */
231 bool HasFiltering() const;
232
233 /** Gathers the names of all the owners in this DenyList. */
235
236 /**
237 * Removes all filtering changes associated with a specific owner name.
238 * @return whether the filters changed.
239 */
240 bool UnregisterOwner(const FName OwnerName);
241
242 /**
243 * Removes all filtering changes associated with the specified list of owner names.
244 * @return whether the filters changed.
245 */
246 bool UnregisterOwners(const TArray<FName>& OwnerNames);
247
248 /**
249 * Add the specified filters to this one. Rules are not applied, direct append lists.
250 * @return whether the filters changed.
251 */
252 bool Append(const FPathPermissionList& Other);
253
254 /**
255 * Combine two filters.
256 * Result will contain all DenyList paths combined.
257 * Result will contain AllowList paths that pass both filters.
258 * @return new combined filter.
259 */
261
262 /**
263 * Unregisters specified owners then adds specified filters in one operation (to avoid multiple filters changed events).
264 * @return whether the filters changed.
265 */
266 bool UnregisterOwnersAndAppend(const TArray<FName>& OwnerNamesToRemove, const FPathPermissionList& FiltersToAdd);
267
268 /** Get raw DenyList */
269 const TMap<FString, FPermissionListOwners>& GetDenyList() const { return DenyList; }
270
271 /** Get raw allowlist */
272 const TMap<FString, FPermissionListOwners>& GetAllowList() const { return AllowList; }
273
274 /** Are all items set to be filtered out */
275 bool IsDenyListAll() const { return DenyListAll.Num() > 0; }
276
277 /** Triggered when filter changes */
278 FSimpleMulticastDelegate& OnFilterChanged() { return OnFilterChangedDelegate; }
279
280protected:
281
282 /**
283 * Checks if an item is of a valid format for this list
284 * @return True if the item passes list type test.
285 */
286 void VerifyItemMatchesListType(const FStringView Item) const;
287
288 /** List if items to filter out */
290
291 /** List of items to allow, if not empty all items will be filtered out unless they are in the list */
293
294 /** List of owner names that requested all items to be filtered out */
296
297 /** Triggered when filter changes */
298 FSimpleMulticastDelegate OnFilterChangedDelegate;
299
300 /** Temporarily prevent delegate from being triggered */
302
303 /** Type of paths this list represent */
305};
EPathPermissionListType
Definition Enums.h:34469
TArray< FName > FPermissionListOwners
bool UnregisterOwner(const FName OwnerName)
FPermissionListOwners DenyListAll
bool RemoveAllowListItem(const FName OwnerName, const FName Item)
bool AddDenyListItem(const FName OwnerName, const FName Item)
bool HasFiltering() const
TMap< FName, FPermissionListOwners > AllowList
bool UnregisterOwners(const TArray< FName > &OwnerNames)
bool PassesFilter(const FName Item) const
bool Append(const FNamePermissionList &Other)
FSimpleMulticastDelegate & OnFilterChanged()
bool UnregisterOwnersAndAppend(const TArray< FName > &OwnerNamesToRemove, const FNamePermissionList &FiltersToAdd)
bool AddAllowListItem(const FName OwnerName, const FName Item)
bool RemoveDenyListItem(const FName OwnerName, const FName Item)
const TMap< FName, FPermissionListOwners > & GetDenyList() const
TMap< FName, FPermissionListOwners > DenyList
TArray< FName > GetOwnerNames() const
bool AddDenyListAll(const FName OwnerName)
FSimpleMulticastDelegate OnFilterChangedDelegate
const TMap< FName, FPermissionListOwners > & GetAllowList() const
EPathPermissionListType ListType
bool RemoveDenyListItem(const FName OwnerName, const FStringView Item)
bool PassesStartsWithFilter(const FName Item, const bool bAllowParentPaths=false) const
bool RemoveDenyListItem(const FName OwnerName, const FName Item)
bool AddDenyListItem(const FName OwnerName, const FStringView Item)
bool UnregisterOwnersAndAppend(const TArray< FName > &OwnerNamesToRemove, const FPathPermissionList &FiltersToAdd)
FSimpleMulticastDelegate OnFilterChangedDelegate
bool AddDenyListItem(const FName OwnerName, const TCHAR *Item)
TArray< FName > GetOwnerNames() const
bool PassesStartsWithFilter(const FStringView Item, const bool bAllowParentPaths=false) const
bool AddAllowListItem(const FName OwnerName, const FStringView Item)
FPermissionListOwners DenyListAll
bool RemoveAllowListItem(const FName OwnerName, const FStringView Item)
const TMap< FString, FPermissionListOwners > & GetDenyList() const
TMap< FString, FPermissionListOwners > DenyList
bool PassesFilter(const FStringView Item) const
FPathPermissionList CombinePathFilters(const FPathPermissionList &OtherFilter) const
TMap< FString, FPermissionListOwners > AllowList
const TMap< FString, FPermissionListOwners > & GetAllowList() const
bool PassesFilter(const FName Item) const
void VerifyItemMatchesListType(const FStringView Item) const
bool Append(const FPathPermissionList &Other)
FPathPermissionList(EPathPermissionListType InType=EPathPermissionListType::Default)
bool UnregisterOwner(const FName OwnerName)
FSimpleMulticastDelegate & OnFilterChanged()
bool AddDenyListItem(const FName OwnerName, const FName Item)
bool RemoveDenyListItem(const FName OwnerName, const TCHAR *Item)
bool PassesStartsWithFilter(const TCHAR *Item, const bool bAllowParentPaths=false) const
bool PassesFilter(const TCHAR *Item) const
bool AddDenyListAll(const FName OwnerName)
bool AddAllowListItem(const FName OwnerName, const TCHAR *Item)
bool RemoveAllowListItem(const FName OwnerName, const FName Item)
bool AddAllowListItem(const FName OwnerName, const FName Item)
bool RemoveAllowListItem(const FName OwnerName, const TCHAR *Item)
bool HasFiltering() const
bool UnregisterOwners(const TArray< FName > &OwnerNames)