本文整理汇总了C++中utree::front方法的典型用法代码示例。如果您正苦于以下问题:C++ utree::front方法的具体用法?C++ utree::front怎么用?C++ utree::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utree
的用法示例。
在下文中一共展示了utree::front方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator() (utree const& ut){
using spirit::utree_type;
typedef utree::const_iterator iterator;
int id = cur_id;
n_id++;
switch (ut.which()) {
case utree_type::reference_type:
out << prefix << id << " [label=\"[reference]\"];\n";
out << prefix << id << " -> " << prefix << cur_id << ";\n";
(*this)(ut.deref());
return;
case utree_type::range_type:
case utree_type::list_type:
{
iterator it, end;
int start_id = n_id;
if (annotations[ut.tag()].second == json_object) {
out << prefix << id << " [label=\"[object]\"];\n";
it = ut.front().begin();
end = ut.front().end();
n_id += ut.front().size();
} else {
if (annotations[ut.tag()].second == json_array) {
out << prefix << id << " [label=\"[array]\"];\n";
} else if (annotations[ut.tag()].second == json_pair) {
out << prefix << id << " [label=\"[pair]\"];\n";
} else {
BOOST_ASSERT(false);
return;
}
it = ut.begin();
end = ut.end();
n_id += ut.size();
}
for (int i=0; it != end; ++it, ++i) {
cur_id = start_id+i;
out << prefix << id << " -> " << prefix << cur_id << ";\n";
(*this)(*it);
}
return;
}
default:
break;
}
utree::visit(ut, *this);
}
示例2: eval_node
utree expression::eval_node(utree const& node)
{
//std::cout << node << " " << node.which() << " " << get_node_type(node) << "\n";
if (node.which() == spirit::utree_type::list_type) {
switch(get_node_type(node)) {
case CARTO_EXP_PLUS:
BOOST_ASSERT(node.size()==2);
return eval_add( eval_node(node.front()), eval_node(node.back()) );
case CARTO_EXP_MINUS:
BOOST_ASSERT(node.size()==2);
return eval_sub( eval_node(node.front()), eval_node(node.back()) );
case CARTO_EXP_TIMES:
BOOST_ASSERT(node.size()==2);
return eval_mult( eval_node(node.front()), eval_node(node.back()) );
case CARTO_EXP_DIVIDE:
BOOST_ASSERT(node.size()==2);
return eval_div( eval_node(node.front()), eval_node(node.back()) );
case CARTO_EXP_NEG:
BOOST_ASSERT(node.size()==1);
return eval_mult( utree(-1.0), eval_node(node.back()) );
case CARTO_EXP_FUNCTION:
return eval_function(node);
case CARTO_EXP_COLOR:
BOOST_ASSERT(node.size()==4);
return node;
//case exp_var:
// return eval_var(node);
default:
{
std::stringstream out;
out << "Invalid expression node type: " << get_node_type(node);
throw carto_error(out.str(), get_location(node));
}
}
} else if (get_node_type(node) == CARTO_EXP_VAR) {
return eval_var(node);
}
//} else {
// std::cout << "Shouldn't be here!\n";
// std::cout << "Node: " << node << "\n";
// std::cout << "Node which: " << node.which() << "\n";
// std::cout << "Node type: " << get_node_type(node) << "\n";
// if (node.which() == spirit::utree_type::list_type)
// std::cout << "Node size: " << node.size() << "\n";
//}
return node;
}
示例3: print_object
void print_object (utree const& ut) const {
typedef utree::const_iterator iterator;
iterator it = ut.front().begin(), end = ut.front().end();
(*this)('{');
(*this)(*it); ++it;
for (; it != end; ++it) {
out << ", ";
(*this)(*it);
}
(*this)('}');
}