Parsing and error logging complete
This commit is contained in:
@@ -40,10 +40,17 @@ cmdlineparser::details::FParseResult cmdlineparser::GetValueOfToken(const FStrin
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Validation of inputs
|
||||
if (details::DoesRegExMatch(ValueOfToken, details::REGEX_PATTERNS[static_cast<int32>(Token)]))
|
||||
{
|
||||
Result.ErrorCode = details::EErrorCodes::NoError;
|
||||
Result.bIsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Result.ErrorCode = details::EErrorCodes::FailedValidation;
|
||||
Result.bIsValid = false;
|
||||
}
|
||||
Result.Value = ValueOfToken;
|
||||
Result.ErrorCode = details::EErrorCodes::NoError;
|
||||
Result.bIsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +58,9 @@ cmdlineparser::details::FParseResult cmdlineparser::GetValueOfToken(const FStrin
|
||||
FString ErrorMessage = details::ERROR_MESSAGES[static_cast<int32>(Result.ErrorCode)];
|
||||
FString TokenName = details::CLI_TOKENS[static_cast<int32>(Result.Token)];
|
||||
FString Value = Result.Value;
|
||||
Result.ErrorMessage = FString::Format(*ErrorMessage, {FStringFormatArg(TokenName), FStringFormatArg(Value)});
|
||||
// Result.ErrorMessage = FString::Format(*ErrorMessage, {FStringFormatArg(TokenName), FStringFormatArg(Value)});
|
||||
Result.ErrorMessage = ErrorMessage;
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -75,4 +84,11 @@ int32 cmdlineparser::details::GetConfiguredOrDefaultPort(const FString& CommandL
|
||||
}
|
||||
}
|
||||
return Port;
|
||||
}
|
||||
}
|
||||
|
||||
bool cmdlineparser::details::DoesRegExMatch(const FString& Text, const FString& Pattern)
|
||||
{
|
||||
const FRegexPattern RegexPattern(Pattern);
|
||||
FRegexMatcher Matcher(RegexPattern, Text);
|
||||
return Matcher.FindNext();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user