本文整理汇总了C++中TOptional::GetTokenStartPos方法的典型用法代码示例。如果您正苦于以下问题:C++ TOptional::GetTokenStartPos方法的具体用法?C++ TOptional::GetTokenStartPos怎么用?C++ TOptional::GetTokenStartPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TOptional
的用法示例。
在下文中一共展示了TOptional::GetTokenStartPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseEscapedChar
TOptional<FExpressionError> ParseEscapedChar(FExpressionTokenConsumer& Consumer)
{
FTokenStream& Stream = Consumer.GetStream();
TOptional<FStringToken> Token = Stream.ParseSymbol(EscapeChar);
if (!Token.IsSet())
{
return TOptional<FExpressionError>();
}
FStringToken& TokenValue = Token.GetValue();
// Accumulate the next character into the token
TOptional<FStringToken> EscapedChar = Consumer.GetStream().ParseSymbol(&TokenValue);
if (!EscapedChar.IsSet())
{
return TOptional<FExpressionError>();
}
// Check for a valid escape character
const TCHAR Character = *EscapedChar->GetTokenStartPos();
if (IsValidEscapeChar(Character))
{
// Add the token to the consumer - this moves the read position in the stream to the end of the token.
Consumer.Add(TokenValue, FEscapedCharacter(Character));
}
return TOptional<FExpressionError>();
}
示例2: if
/** Parse an escaped character */
TOptional<FExpressionError> ParseEscapedChar(FExpressionTokenConsumer& Consumer, bool bEmitErrors)
{
static const TCHAR* ValidEscapeChars = TEXT("{`");
TOptional<FStringToken> Token = Consumer.GetStream().ParseSymbol(EscapeChar);
if (!Token.IsSet())
{
return TOptional<FExpressionError>();
}
// Accumulate the next character into the token
TOptional<FStringToken> EscapedChar = Consumer.GetStream().ParseSymbol(&Token.GetValue());
if (!EscapedChar.IsSet())
{
return TOptional<FExpressionError>();
}
// Check for a valid escape character
const TCHAR Character = *EscapedChar->GetTokenStartPos();
if (FCString::Strchr(ValidEscapeChars, Character))
{
// Add the token to the consumer. This moves the read position in the stream to the end of the token.
Consumer.Add(Token.GetValue(), FEscapedCharacter(Character));
return TOptional<FExpressionError>();
}
else if (bEmitErrors)
{
FString CharStr;
CharStr += Character;
FFormatOrderedArguments Args;
Args.Add(FText::FromString(CharStr));
return FExpressionError(FText::Format(LOCTEXT("InvalidEscapeCharacter", "Invalid escape character '{0}'"), Args));
}
else
{
return TOptional<FExpressionError>();
}
}