本文整理汇总了C++中ListIterator::currentIsInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ ListIterator::currentIsInteger方法的具体用法?C++ ListIterator::currentIsInteger怎么用?C++ ListIterator::currentIsInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListIterator
的用法示例。
在下文中一共展示了ListIterator::currentIsInteger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getValue
// getValue
// Gets the value of the number/expression at the current position
// If the current value is an integer, return it
// If it's a parenthetical expression, evaluate, and return
// evalMultiplication is a flag used to ensure multiplication happens before addition
// If true, it will handle any multiplication that is applied to the current value
// That way, what is returned to the addition function is what we actually want to add
// Parameters:
// iter - the iterator for the list of tokens
// postExpr - the postfix expression we are converting to
// evalMultiplication (input boolean) whether to evaluate multiplication, see above
// Pre-condition: expr[pos] is an int or parenthesis
// Post-condition: expr[pos] is the end of the value
// If it was an int, it's on the int
// If it was a parenthesis, it's on the end parenthesis
// If handling multiplication, it's on the last multiplied int
// postExpr has the values handled here pushed to it
void getValue(ListIterator& iter, TokenList& postExpr, bool evalMultiplication)
{
bool negative = false;
if (!iter.currentIsInteger() && iter.tokenChar() == '-')
{
negative = true;
iter.advance();
}
if (iter.currentIsInteger())
{
postExpr.push_back(iter.integerValue());
if (negative)
{
postExpr.push_back(Token('~'));
}
while (evalMultiplication && isNextOperatorMultiplication(iter))
{
iter.advance();
handleMultiplyLevelOperation(iter, postExpr);
}
}
else
{
handleParenthesis(iter, postExpr);
if (negative)
{
postExpr.push_back(Token('~'));
}
}
}