Lesson 55 working properly now
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
namespace cmdlineparser::details
|
||||
{
|
||||
enum EAvailableTokens
|
||||
{
|
||||
Unknown = 0,
|
||||
AuthToken,
|
||||
HostId,
|
||||
FleetId,
|
||||
WebsocketUrl,
|
||||
MaxToken
|
||||
};
|
||||
|
||||
enum EErrorCodes
|
||||
{
|
||||
NoError,
|
||||
TokenNotFound,
|
||||
ValueEmpty,
|
||||
FailedValidation,
|
||||
MaxCode
|
||||
};
|
||||
|
||||
inline static const TMap<EErrorCodes, FString>& ERROR_MESSAGES = []() ->
|
||||
const TMap<EErrorCodes, FString>&
|
||||
{
|
||||
static TMap<EErrorCodes, FString> Error_Messages =
|
||||
{
|
||||
{NoError,TEXT("VALID: {0}: {1}") },
|
||||
{FailedValidation,TEXT("VALIDATION FAILED: [-{0}=] found.... Value: [{1}]") },
|
||||
{TokenNotFound,TEXT("INVALID TOKEN: [-{0}=] not found in command line arguments") },
|
||||
{ValueEmpty,TEXT("EMPTY VALUE: [-{0}=] found. No value assigned") },
|
||||
|
||||
};
|
||||
return Error_Messages;
|
||||
}();
|
||||
|
||||
inline static const TMap<EAvailableTokens, FString>& CLI_TOKENS = []() ->
|
||||
const TMap<EAvailableTokens, FString>&
|
||||
{
|
||||
static TMap<EAvailableTokens, FString> Cli_Tokens =
|
||||
{
|
||||
{AuthToken, TEXT("authtoken") },
|
||||
{FleetId, TEXT("fleetid") },
|
||||
{HostId, TEXT("hostid") },
|
||||
{Unknown, TEXT("unknown") },
|
||||
{WebsocketUrl, TEXT("websocketurl") }
|
||||
};
|
||||
return Cli_Tokens;
|
||||
}();
|
||||
|
||||
inline static const TMap<EAvailableTokens, FString>& REGEX_PATTERNS = []() ->
|
||||
const TMap<EAvailableTokens, FString>&
|
||||
{
|
||||
static TMap<EAvailableTokens, FString> Regex_Patterns =
|
||||
{
|
||||
{Unknown,TEXT(".*") },
|
||||
{AuthToken,TEXT("^[a-zA-Z0-9\\-]+$") },
|
||||
{HostId,TEXT("^[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62}[a-zA-Z0-9]?$") },
|
||||
{FleetId,TEXT("^[a-z]*fleet-[a-zA-Z0-9\\-]+$|^arn:.*:[a-z]*fleet\\/[a-z]*fleet-[a-zA-Z0-9\\-]+$") },
|
||||
{WebsocketUrl,TEXT("^wss://[a-z0-9-]+(\\.[a-z0-9-]+)*\\.api\\.amazongamelift\\.com(:[0-9]+)?/?$") },
|
||||
};
|
||||
return Regex_Patterns;
|
||||
}();
|
||||
|
||||
// extern const TMap<EErrorCodes, FString>& ERROR_MESSAGES;
|
||||
// extern const TMap<EAvailableTokens, FString>& CLI_TOKENS;
|
||||
// extern const TMap<EAvailableTokens, FString>& REGEX_PATTERNS;
|
||||
|
||||
struct FParseResult
|
||||
{
|
||||
EAvailableTokens Token = EAvailableTokens::Unknown;
|
||||
FString Value = FString();
|
||||
bool bIsValid = false;
|
||||
EErrorCodes ErrorCode = EErrorCodes::TokenNotFound;
|
||||
FString ErrorMessage = FString();
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user