本文整理汇总了C++中Type::GetPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ Type::GetPrimitive方法的具体用法?C++ Type::GetPrimitive怎么用?C++ Type::GetPrimitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type::GetPrimitive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Type
Type *Type::CreateFromString(Node *parent, const std::string &name)
{
if (name.empty())
return new Type(parent, TypePrimitive::Unknown, "__unknown");;
size_t start = 0;
size_t end = name.size() - 1;
int numDereferences = 0;
bool isReference = false;
bool isConst = false;
static const std::string constPrefix = "const ";
if (!name.compare(0, constPrefix.size(), constPrefix))
{
isConst = true;
start += constPrefix.size();
}
if (name[end] == '&')
{
isReference = true;
--end;
}
while (name[end] == '*')
{
++numDereferences;
--end;
if (!end)
return nullptr;
}
while (name[start] == ' ' && start < end)
++start;
while (name[end] == ' ' && end > start)
--end;
std::string decayedName = name.substr(start, end - start + 1);
if (decayedName.empty())
return nullptr;
start = 0;
end = decayedName.size() - 1;
if (decayedName[end] == ']')
{
end = decayedName.find(" [");
if (end == std::string::npos)
return nullptr;
decayedName = decayedName.substr(0, end);
}
start = 0;
end = decayedName.size() - 1;
if (decayedName[end] == '>')
{
end = decayedName.find('<');
if (end == std::string::npos)
return nullptr;
decayedName = decayedName.substr(0, end);
}
if (decayedName.empty())
return nullptr;
Type *t = nullptr;
TypePrimitive tp = TypePrimitiveFromString(decayedName);
if (tp != TypePrimitive::Unknown)
{
t = new Type(parent, tp, decayedName);
}
else
{
Namespace *ns = Node::TryGetNamespace(parent);
if (ns)
{
Type *complexType = ns->FindTypeByName(decayedName);
if (complexType)
{
if (complexType->GetPrimitive() == TypePrimitive::Class)
t = new Type(complexType->GetClass());
else if (complexType->GetPrimitive() == TypePrimitive::TypeDef)
{
}
}
}
}
if (!t)
t = new Type(parent, TypePrimitive::Unknown, decayedName);
//.........这里部分代码省略.........