本文整理汇总了C++中ExprNode::GetVarLeaves方法的典型用法代码示例。如果您正苦于以下问题:C++ ExprNode::GetVarLeaves方法的具体用法?C++ ExprNode::GetVarLeaves怎么用?C++ ExprNode::GetVarLeaves使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExprNode
的用法示例。
在下文中一共展示了ExprNode::GetVarLeaves方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
static string
GetRealVariableHelper(const string &var, set<string> expandedVars)
{
// Check for recursion in expanded vars
if (expandedVars.count(var))
{
EXCEPTION1(RecursiveExpressionException, var);
}
expandedVars.insert(var);
// If this variable is not an expression, then it is real
Expression *expr = ParsingExprList::GetExpression(var);
if (!expr)
{
// Found the real variable
return var;
}
// Otherwise, descend into it; get the expression tree
ExprNode *tree = ParsingExprList::GetExpressionTree(expr);
if (!tree)
{
// We won't normally get here because error
// conditions will usually throw exceptions.
// Otherwise, every expression should have
// a tree.
return "";
}
// Get the leaves for this expression
const vector<string> &varLeaves = tree->GetVarLeaves();
if (varLeaves.empty())
{
delete tree;
return "";
}
// For each leaf, look for a real variable
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
// Don't use const iterator on win32 MSVC 6.
for (std::vector<std::string>::iterator it = varLeaves.begin();
it != varLeaves.end(); ++it)
#else
for (std::vector<std::string>::const_iterator it = varLeaves.begin();
it != varLeaves.end(); ++it)
#endif
{
string realvar = GetRealVariableHelper(*it, expandedVars);
// If we found a real variable, return it!
if (!realvar.empty())
{
delete tree;
return realvar;
}
}
// Didn't find any real variables
delete tree;
return "";
}