本文整理汇总了C++中Expression::end方法的典型用法代码示例。如果您正苦于以下问题:C++ Expression::end方法的具体用法?C++ Expression::end怎么用?C++ Expression::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addConstraints
/** Add a list of constraints from a string
* @param str :: A comma-separated list of constraint expressions.
* @param isDefault :: Flag to mark as default the value of an object associated with this reference.
*
*/
void IFunction::addConstraints(const std::string& str, bool isDefault)
{
Expression list;
list.parse(str);
list.toList();
for(auto expr = list.begin(); expr != list.end(); ++expr)
{
IConstraint* c = ConstraintFactory::Instance().createInitialized(this,*expr,isDefault);
this->addConstraint(c);
}
}
示例2: Expression
/// Copy constructor
Expression::Expression(const Expression& expr)
:m_namespace(expr.m_namespace),
m_object(expr.m_object),
m_name(expr.m_name),
m_op(expr.m_op),
m_operators(expr.m_operators)
{
for(const_iterator it = expr.begin();it!=expr.end();it++)
{
m_terms.push_back(boost::shared_ptr<Expression>(new Expression(**it)));
}
}
示例3: print_expression
void print_expression(Expression &expr)
{
LessConstant* pconst;
LessColor* pcolor;
cout<<"expression begin\n"<<endl;
for(auto iter = expr.begin(); iter != expr.end(); ++iter) {
switch(iter->type) {
case CONSTANT:
pconst = (LessConstant *)iter->data;
cout<<"constant:"<<pconst->val<<pconst->unit<<'\n'<<endl;
break;
case STRING:
cout<<"string:"<<*((string*)iter->data)<<"\n"<<endl;
break;
case COLOR:
cout<<"color:";
cout<<"r:"<<((LessColor *)iter->data)->r;
cout<<"g:"<<((LessColor *)iter->data)->g;
cout<<"b:"<<((LessColor *)iter->data)->b;
cout<<"\n"<<endl;
break;
case LEFT_BRACE:
cout<<"left brace\n"<<endl;
break;
case RIGHT_BRACE:
cout<<"right brace\n"<<endl;
break;
case OP_AT:
cout<<"operator @\n"<<endl;
break;
case OP_ADD:
cout<<"operator +\n"<<endl;
break;
case OP_NEG:
cout<<"operator negative\n"<<endl;
break;
case OP_SUB:
cout<<"operator sub\n"<<endl;
break;
case OP_MUL:
cout<<"operator *\n"<<endl;
break;
case OP_DIV:
cout<<"operator /\n"<<endl;
break;
default:
break;
}
}
cout<<"expression end\n"<<endl;
}
示例4: addTies
/**
* Add ties to the function.
* @param ties :: Comma-separated list of name=value pairs where name is a parameter name and value
* is a math expression tying the parameter to other parameters or a constant.
* @param isDefault :: Flag to mark as default the value of an object associated with this reference: a tie or a constraint.
*
*/
void IFunction::addTies(const std::string& ties, bool isDefault)
{
Expression list;
list.parse(ties);
list.toList();
for(auto t = list.begin(); t != list.end(); ++t)
{
if (t->name() == "=" && t->size() >= 2)
{
size_t n = t->size() - 1;
const std::string value = (*t)[n].str();
for( size_t i = n; i != 0; )
{
--i;
this->tie( (*t)[i].name(), value, isDefault );
}
}
}
}
示例5: while
void Private::
ParseKeywords(
std::string const & keywords,
Table const & mapping,
IdSetTable & set_table,
Expression & rule)
{
if (keywords.empty() || mapping.empty())
return;
auto tmp_table = set_table;
auto tmp_exp = rule;
auto npos = std::string::npos;
auto beg = keywords.find_first_of( LeftBound, 0U);
auto end = keywords.find_first_of(RightBound, 0U);
bool valid = beg != npos && end != npos && beg < end;
while (valid && beg != npos && end != npos && beg < end) {
auto mid = keywords.find_first_of(Separator, beg);
valid = valid && mid < end;
auto caller_idx = npos;
if (valid) { /* caller */
auto len = mid - beg - 1U;
auto caller_beg = keywords.find_first_not_of(Space, beg + 1U, len);
auto caller_end = keywords.find_last_not_of (Space, mid - 1U, len);
valid = caller_beg != npos && caller_end != npos && caller_beg <= caller_end;
if (valid) {
auto is_keyword_complete = keywords.at(caller_beg) != Incomplete;
if (!is_keyword_complete)
caller_beg++;
auto word = keywords.substr(caller_beg, caller_end + 1U - caller_beg);
caller_idx = IndexKeywords(word, mapping, tmp_table, is_keyword_complete);
if (caller_idx == ~size_t(0U))
valid = false;
}
}
auto callee_idx = npos;
if (valid) { /* callee */
auto len = end - mid - 1U;
auto callee_beg = keywords.find_first_not_of(Space, mid + 1U, len);
auto callee_end = keywords.find_last_not_of (Space, end - 1U, len);
valid = callee_beg != npos && callee_end != npos && callee_beg <= callee_end;
if (valid) {
auto is_keyword_complete = keywords.at(callee_beg) != Incomplete;
if (!is_keyword_complete)
callee_beg++;
auto word = keywords.substr(callee_beg, callee_end + 1U - callee_beg);
callee_idx = IndexKeywords(word, mapping, tmp_table, is_keyword_complete);
if (callee_idx == ~size_t(0U))
valid = false;
}
}
if (valid) {
tmp_exp.push_back(std::make_pair(caller_idx, callee_idx));
beg = keywords.find_first_of( LeftBound, end);
end = keywords.find_first_of(RightBound, beg);
}
}
if (valid) {
set_table.insert(set_table.end(), tmp_table.begin(), tmp_table.end());
rule.insert(rule.end(), tmp_exp.begin(), tmp_exp.end());
}
}