Parsing and error logging complete

This commit is contained in:
Norman Lansing
2026-03-12 07:13:47 -04:00
parent bf2ead5f97
commit 51e89e8613
6 changed files with 161 additions and 113 deletions

View File

@@ -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();
}