本文整理汇总了C++中utree::tag方法的典型用法代码示例。如果您正苦于以下问题:C++ utree::tag方法的具体用法?C++ utree::tag怎么用?C++ utree::tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utree
的用法示例。
在下文中一共展示了utree::tag方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: parse_sexpr_list
bool parse_sexpr_list(
std::basic_istream<Char>& is,
utree& result,
std::string const& source_file)
{
// no white space skipping in the stream!
is.unsetf(std::ios::skipws);
typedef
boost::spirit::basic_istream_iterator<Char>
stream_iterator_type;
stream_iterator_type sfirst(is);
stream_iterator_type slast;
typedef boost::spirit::line_pos_iterator<stream_iterator_type>
iterator_type;
iterator_type first(sfirst);
iterator_type last(slast);
scheme::input::sexpr<iterator_type> p(source_file);
scheme::input::sexpr_white_space<iterator_type> ws;
using boost::spirit::qi::phrase_parse;
bool ok = phrase_parse(first, last, +p, ws, result);
result.tag(1); // line
return ok;
}
示例3: expand
// TODO: Refactor this code with the code in thunk
utree expand (utree const& arg, runtime_environment& env) const {
using boost::fusion::at_c;
if (prana::recursive_which(arg) == utree_type::function_type) {
BOOST_ASSERT(arg.tag() <= global_procedure_table->size());
// Load the argument's signature from the gpt.
signature const& sig = (*global_procedure_table)[arg.tag()];
// std::cout << at_c<3>(sig) << std::endl;
if ((at_c<3>(sig) == function_type::placeholder)/*||
(at_c<3>(sig) == function_type::reference)*/)
return env.invoke(arg);
}
return arg;
}
示例4: parse_zoom_value
double filter_printer::parse_zoom_value(utree const& ut)
{
if (ut.tag() != 0){
int node_type = annotations[ut.tag()].second;
if (node_type == filter_var_attr) {
return as<double>(parse_var(ut));
} else {
source_location loc = annotations[ut.tag()].first;
std::stringstream out;
out << "Invalid node type: " << node_type
<< " at " << loc.get_string();
throw config_error(out.str());
}
} else {
return as<double>(ut);
}
}
示例5: call
static type call (utree const& ut, parse_tree<Tag> const& pt) {
using fusion::at_c;
switch (ut.which()) {
case utree_type::reference_type:
return call(ut.deref());
case utree_type::range_type:
case utree_type::list_type:
return at_c<1>(pt.annotations()[ut.tag()]);
default:
return -1;
}
}
示例6: fix_color_range
utree expression::fix_color_range(utree const& node)
{
BOOST_ASSERT(is_color(node) == TRUE);
BOOST_ASSERT(node.size() == 4);
typedef utree::const_iterator iter;
utree ut;
ut.tag(node.tag());
for(iter it = node.begin(); it != node.end(); it++)
ut.push_back( fmod(as<double>(*it), 256) );
return ut;
}
示例7: first
typename boost::disable_if<boost::is_base_of<std::ios_base, Range>, bool>::type
parse_sexpr_list(
Range const& rng,
utree& result,
std::string const& source_file)
{
typedef boost::spirit::line_pos_iterator<typename Range::const_iterator>
iterator_type;
scheme::input::sexpr<iterator_type> p(source_file);
scheme::input::sexpr_white_space<iterator_type> ws;
iterator_type first(rng.begin());
iterator_type last(rng.end());
using boost::spirit::qi::phrase_parse;
bool ok = phrase_parse(first, last, +p, ws, result);
result.tag(1); // line
return ok;
}
示例8: parse_var
utree filter_printer::parse_var(utree const& ut)
{
BOOST_ASSERT(ut.size()==1);
BOOST_ASSERT( annotations[ut.tag()].second == filter_var
|| annotations[ut.tag()].second == filter_var_attr);
std::string key = detail::as<std::string>(ut);
//for (; it != end; ++it)
// key += detail::as<std::string>(*it);
utree value = env.vars.lookup(key);
if (value == utree::nil_type()) {
std::string err = std::string("Unknown variable: @")+key;
throw config_error(err);
}
return value;
}
示例9: get_location
source_location get_location(utree const& ut)
{
return tree.annotations()[ut.tag()].first;
}
示例10: get_node_type
int get_node_type(utree const& ut)
{
return( tree.annotations(ut.tag()).second );
}
示例11: operator
std::string filter_printer::operator() (utree const& ut)
{
using spirit::utree_type;
std::string out;
if (ut.tag() == 0) {
if (ut.which() == utree_type::list_type) {
utree::const_iterator it = ut.begin(), end = ut.end();
for (; it != end; ++it)
out += (*this)(*it);
} else {
out += as<std::string>(ut);
}
return out;
}
int const node_type = annotations[ut.tag()].second;
typedef utree::const_iterator iter;
iter it = ut.begin(),
end = ut.end();
if (node_type == filter_var || node_type == filter_var_attr) {
utree value = parse_var(ut);
if (node_type == filter_var_attr)
out += "[" + (*this)(value) + "]";
else
out += (*this)(value);
} else if (node_type == filter_and) {
BOOST_ASSERT(ut.size()==2);
std::string a = (*this)(*it); it++;
std::string b = (*this)(*it);
if (a == "" || b == "")
out += (a=="") ? a : b;
else
out += "(" + a + " and " + b + ")";
} else if (node_type == filter_or) {
BOOST_ASSERT(ut.size()==2);
std::string a = (*this)(*it); it++;
std::string b = (*this)(*it);
if (a == "" || b == "")
out += (a=="") ? a : b;
else
out += "(" + a + " or " + b + ")";
} else if (node_type == filter_not) {
BOOST_ASSERT(ut.size()==1);
std::string a = (*this)(*it);
if (a != "")
out += "(not " + a + ")";
} else if (node_type == filter_match) {
BOOST_ASSERT(ut.size()==2);
std::string a = (*this)(*it); it++;
std::string b = (*this)(*it);
out += a + ".match('" + b + "')";
} else if (node_type == filter_replace) {
BOOST_ASSERT(ut.size()==2);
std::string a = (*this)(*it); it++;
std::string b = (*this)(*it); it++;
std::string c = (*this)(*it);
out += a + ".replace('" + b + ", " + c + "')";
} else if (node_type == filter_attribute) {
//BOOST_ASSERT(ut.size()==1);
out += "[" + (*this)(*it) + "]";
} else if (node_type == filter_expression) {
} else if (node_type == filter_eq) {
BOOST_ASSERT(ut.size()==2);
std::string a = (*this)(*it); it++;
if (a == "[zoom]") {
int b = round(parse_zoom_value(*it));
rule.set_min_scale(zoom_ranges[b+1]);
rule.set_max_scale(zoom_ranges[b]);
} else {
std::string b = (*this)(*it);
out += "(" + a + " = " + b + ")";
}
} else if (node_type == filter_neq) {
BOOST_ASSERT(ut.size()==2);
//.........这里部分代码省略.........
示例12: 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;
carto_node_type nope_type = annotations[ut.tag()].second;
/*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();
}*/
out << prefix << id << " [label=\"[";
switch(node_type) {
case CARTO_UNDEFINED:
out << "";
break;
case CARTO_VARIABLE:
out << "variable";
break;
case CARTO_MIXIN:
OUT << "mixin";
break;
case CARTO_STYLE:
out << "style";
break;
case CARTO_FUNCTION:
out << "function";
break;
case CARTO_ATTRIBUTE:
out << "attribute";
break;
case CARTO_COLOR:
out << "color";
break;
case CARTO_FILTER:
out << "filter";
break;
default:
std::cout << node_type << std::endl;
BOOST_ASSERT(false);
//return;
}
out << "]\"];\n";
it = ut.begin();
end = ut.end();
n_id += ut.size();
if (node_type == CARTO_FILTER) {
for (int i=0; it != end; ++it, ++i) {
cur_id = start_id+i;
out << prefix << id << " -> " << prefix << cur_id << ";\n";
out << prefix << cur_id << " [label=\"";
generate_filter(*it,annotations,style_env(),out);
out << "\"];\n";
}
} else {
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);
}
示例13: 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();
}*/
out << prefix << id << " [label=\"[";
switch(annotations[ut.tag()].second) {
case carto_undefined:
out << "";
break;
case carto_variable:
out << "variable";
break;
case carto_mixin:
out << "mixin";
break;
case carto_style:
out << "style";
break;
case carto_function:
out << "function";
break;
case carto_attribute:
out << "attribute";
break;
case carto_color:
out << "color";
break;
case carto_filter:
out << "filter";
break;
default:
std::cout << annotations[ut.tag()].second << std::endl;
BOOST_ASSERT(false);
//return;
}
out << "]\"];\n";
it = ut.begin();
end = ut.end();
n_id += ut.size();
if (annotations[ut.tag()].second == carto_filter) {
for (int i=0; it != end; ++it, ++i) {
cur_id = start_id+i;
out << prefix << id << " -> " << prefix << cur_id << ";\n";
out << prefix << cur_id << " [label=\"";
generate_filter(*it,annotations,style_env(),out);
out << "\"];\n";
}
} else {
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);
}