-
Notifications
You must be signed in to change notification settings - Fork 2
/
StringParseTool.h
57 lines (42 loc) · 1.93 KB
/
StringParseTool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "CoreMinimal.h"
#include "StringParseTool.generated.h"
class UMyObjejct;
/**
* DataAsset to get strings from other classes float/int/bool-fields and add them to a Description into DescriptionPreview.
*
* Format for fields inside Description is strictly following:
* - int/float-fields: {ObjX:MemberVariableName} where X is an integer between 1 and 3 representing StringParseTool member-variable and MemberVariableName exists as a member-variable / getter() inside *ObjX
* - bool-fields: {ObjX:MemberVariableName$PrintIfTrue$PrintIfFalse} where X is an integer between 1 and 3 representing StringParseTool member-variable and MemberVariableName exists as a member-variable / getter() inside *ObjX
*/
UCLASS()
class DEMO_API UStringParseTool : public UDataAsset
{
GENERATED_BODY()
public:
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
FString ParseDescription() const;
UPROPERTY(Instanced, EditAnywhere, BlueprintReadWrite, Category="Objects")
UMyObjejct *Obj1;
UPROPERTY(Instanced, EditAnywhere, BlueprintReadWrite, Category="Objects")
UMyObjejct *Obj2;
UPROPERTY(Instanced, EditAnywhere, BlueprintReadWrite, Category="Objects")
UMyObjejct *Obj3;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText Description;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
FString DescriptionPreview;
private:
struct FToken
{
enum TOKEN_STATUS { READY, NEED_TO_PARSE } TokenStatus;
FString TokenValue;
};
UE_NODISCARD bool GetTokens(const FString& Str, TArray<FToken>& Tokens) const;
UE_NODISCARD TOptional<FString> ParseToken(const FString& TokenValue) const;
/**
* STL-convention FString::Find-wrapper (returning TokenValue.Len() instead of -1 if not found leads to a cleaner code)
*/
UE_NODISCARD static int32 FindCharacterInToken(const FString& TokenValue, const FString& SubStr, int32 IndexStart);
UE_NODISCARD UMyObjejct* GetObjectByShortName(FString&& Name) const;
};