Plasma Engine  2.0
Loading...
Searching...
No Matches
DynamicStringEnum.h
1#pragma once
2
3#include <Foundation/Containers/Map.h>
4#include <Foundation/Strings/String.h>
5#include <GuiFoundation/GuiFoundationDLL.h>
6
13class PL_GUIFOUNDATION_DLL plDynamicStringEnum
14{
15public:
19 static plDynamicStringEnum& GetDynamicEnum(plStringView sEnumName);
20
21 static plDynamicStringEnum& CreateDynamicEnum(plStringView sEnumName);
22
24 static void RemoveEnum(plStringView sEnumName);
25
27 const plHybridArray<plString, 16>& GetAllValidValues() const { return m_ValidValues; }
28
30 void Clear();
31
33 void AddValidValue(plStringView sValue, bool bSortValues = false);
34
36 void RemoveValue(plStringView sValue);
37
39 bool IsValueValid(plStringView sValue) const;
40
42 void SortValues();
43
47 void SetStorageFile(plStringView sFile) { m_sStorageFile = sFile; }
48
50 plStringView GetStorageFile() const { return m_sStorageFile; }
51
52 void ReadFromStorage();
53
54 void SaveToStorage();
55
60
61private:
62 plHybridArray<plString, 16> m_ValidValues;
63 plString m_sStorageFile;
64
65 static plMap<plString, plDynamicStringEnum> s_DynamicEnums;
66};
Stores the valid values and names for 'dynamic' enums.
Definition DynamicStringEnum.h:14
static plDelegate< void(plStringView sEnumName, plDynamicStringEnum &e)> s_RequestUnknownCallback
Invoked by GetDynamicEnum() for enums that are unkonwn at that time.
Definition DynamicStringEnum.h:59
const plHybridArray< plString, 16 > & GetAllValidValues() const
Returns all enum values and current names.
Definition DynamicStringEnum.h:27
void SetStorageFile(plStringView sFile)
If set to non-empty, the user can easily edit this enum through a simple dialog and the values will b...
Definition DynamicStringEnum.h:47
plStringView GetStorageFile() const
The file where values will be stored.
Definition DynamicStringEnum.h:50
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition Map.h:408
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A generic delegate class which supports static functions and member functions.
Definition Delegate.h:76