New Parser Completed. Verification next.
This commit is contained in:
23
Source/FPSTemplate/Public/GameLift/GameLiftClp.h
Normal file
23
Source/FPSTemplate/Public/GameLift/GameLiftClp.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "GameLiftClpTypes.h"
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
namespace cmdlineparser
|
||||
{
|
||||
// int32 GetConfiguredOrDefaultPort();
|
||||
int32 GetConfiguredOrDefaultPort(const FString& Token = TEXT("port="));
|
||||
int32 GetConfiguredOrDefaultPort(const FString& CommandLine, const FString& Token = TEXT("port="));
|
||||
|
||||
details::FParseResult GetValueOfToken(const FString& CommandLine, const details::EAvailableTokens Token);
|
||||
}
|
||||
|
||||
namespace cmdlineparser::details
|
||||
{
|
||||
inline static constexpr int32 MIN_PORT = 1024;
|
||||
inline static constexpr int32 MAX_PORT = 65535;
|
||||
inline static constexpr const TCHAR* DEFAULT_PORT_TOKEN = TEXT("port=");
|
||||
|
||||
FString EnsureEndsWith(const FString& Token, const TCHAR* Suffix);
|
||||
int32 GetConfiguredOrDefaultPort(const FString& CommandLine, const FString& Token);
|
||||
}
|
||||
|
||||
93
Source/FPSTemplate/Public/GameLift/GameLiftValidators.h
Normal file
93
Source/FPSTemplate/Public/GameLift/GameLiftValidators.h
Normal file
@@ -0,0 +1,93 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GameLiftValidators.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EGameLiftParams : uint8
|
||||
{
|
||||
AuthToken,
|
||||
FleetId,
|
||||
HostId,
|
||||
ServerRegion,
|
||||
WebSocketUrl,
|
||||
Max // Sentry to determine length of EGameLiftParams
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EValidationError : uint8
|
||||
{
|
||||
None, // Valid
|
||||
Empty, // Missing Parameter
|
||||
TooShort, // Too Short
|
||||
TooLong, // Too long
|
||||
InvalidFormat, // Invalid format
|
||||
NotFound // Sentinel value, any new error codes get put above this.
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FParamResult
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
EGameLiftParams ParamType;
|
||||
FString Value;
|
||||
bool bValid;
|
||||
FString ErrorMessage;
|
||||
EValidationError ErrorCode;
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class FPSTEMPLATE_API UGameLiftValidators : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
static TArray<FString>& GetPatterns();
|
||||
|
||||
|
||||
|
||||
static constexpr int32 MaxLengths[static_cast<int32>(EGameLiftParams::Max)] =
|
||||
{
|
||||
64, //authToken
|
||||
512, //FleetId
|
||||
128, //HostId
|
||||
128, //WebSocketUrl
|
||||
16, //Region (ca-central-1)
|
||||
};
|
||||
|
||||
static constexpr int32 MinLengths[static_cast<int32>(EGameLiftParams::Max)] =
|
||||
{
|
||||
1, //authToken
|
||||
1, //FleetId
|
||||
1, //HostId
|
||||
1, //WebSocketUrl
|
||||
3, //Region (ca-central-1)
|
||||
};
|
||||
|
||||
static bool IsStringValid(const FString& Value, EGameLiftParams ParamType);
|
||||
static bool IsStringShort(const FString& Value, EGameLiftParams ParamType);
|
||||
static bool IsStringLong(const FString& Value, EGameLiftParams ParamType);
|
||||
static bool IsMatchesRegex(const FString& Value, EGameLiftParams ParamType);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GameLift")
|
||||
static FParamResult ValidateParam(const FString& Value, EGameLiftParams ParamType);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GameLift")
|
||||
static FString GetParameterFromEnum(EGameLiftParams InParam);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GameLift")
|
||||
static FString GetErrorFromEnum(EValidationError InParam);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GameLift")
|
||||
static void LogValidationErrorMessage(FParamResult ValidationResult);
|
||||
|
||||
};
|
||||
24
Source/FPSTemplate/Public/GameLift/GameLiftValidators_old.h
Normal file
24
Source/FPSTemplate/Public/GameLift/GameLiftValidators_old.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
struct FParamResult
|
||||
{
|
||||
FString Value;
|
||||
bool bValid;
|
||||
FString ErrorMessage;
|
||||
};
|
||||
|
||||
namespace GameLiftValidators2
|
||||
{
|
||||
enum class ECliParam
|
||||
{
|
||||
AuthToken, FleetId, HostId, Region, WebSocketUrl, Max
|
||||
};
|
||||
|
||||
|
||||
int32 GetMaxLength(ECliParam ParamType);
|
||||
int32 GetMinLength(ECliParam ParamType);
|
||||
|
||||
bool IsStringValid(const FString& Value, ECliParam ParamType);
|
||||
bool IsNumberValid(int32 Value, int32 Min, int32 Max);
|
||||
}
|
||||
Reference in New Issue
Block a user