本文整理汇总了C++中BaseType::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseType::isValid方法的具体用法?C++ BaseType::isValid怎么用?C++ BaseType::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseType
的用法示例。
在下文中一共展示了BaseType::isValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consumeType
TypeDeclaration consumeType(TokenVector::const_iterator &token, TokenVector::const_iterator end, bool allowIdentifier, const TokenKindSet &stopTokens)
{
IndirectionVector indirections;
BaseType baseType = consumeBaseType(token, end, allowIdentifier, stopTokens);
if (!baseType.isValid())
{
return TypeDeclaration();
}
// Keep going until we run out of tokens or hit a stop token
while(token != end && (stopTokens.count(token->getKind()) == 0))
{
if (token->is(clang::tok::raw_identifier))
{
const std::string identifier(identifierString(*token));
if (identifier == "const")
{
// Is this applying to a *
if (!indirections.empty() && (indirections.back() == Indirection::Pointer))
{
// Convert to a const *
indirections.back() = Indirection::ConstPointer;
}
else
{
// Unexpected
return TypeDeclaration();
}
}
else if (allowIdentifier && (++token == end))
{
// Trailing identifier
break;
}
else
{
// Unexpected
return TypeDeclaration();
}
}
else if (token->is(clang::tok::amp))
{
indirections.push_back(Indirection::Reference);
}
else if (token->is(clang::tok::star))
{
// Assume non-const, following "const" may modify it
indirections.push_back(Indirection::Pointer);
}
else
{
// Something we don't know about
return TypeDeclaration();
}
token++;
}
return TypeDeclaration(baseType.isConst, baseType.typeName, indirections);
}