6 #ifndef QUERY_NODE_HPP_
7 #define QUERY_NODE_HPP_
8 #include "boost/lexical_cast.hpp"
9 #include "boost/numeric/conversion/cast.hpp"
22 Node const& node = ts[nid];
23 return is_empty(node.ns_id());
26 inline Node_literal
const& to_literal(Node
const& node) {
28 return dynamic_cast<Node_literal const&
>(node);
29 }
catch(std::bad_cast&) {
30 BOOST_THROW_EXCEPTION(
32 << Rdf_err::msg_t(
"literal node is required")
33 << Rdf_err::str1_t(to_string(node))
46 Out operator()()
const {
return out_;}
48 void visit_impl(
Node_iri const& node) {
49 BOOST_THROW_EXCEPTION(
51 << Rdf_err::msg_t(
"error converting IRI node to value")
52 << Rdf_err::str1_t(to_string(node))
57 BOOST_THROW_EXCEPTION(
59 << Rdf_err::msg_t(
"error converting blank node to value")
60 << Rdf_err::str1_t(to_string(node))
65 out_ = boost::numeric_cast<Out>(node.value());
68 void visit_impl(
Node_int const& node) {
69 out_ = boost::numeric_cast<Out>(node.value());
73 out_ = boost::numeric_cast<Out>(node.value());
77 out_ = boost::numeric_cast<Out>(node.value());
81 out_ = boost::lexical_cast<Out>(node.value());
92 std::string operator()()
const {
return out_;}
94 void visit_impl(
Node_iri const& node) {
103 out_ = node.value_str();
106 void visit_impl(
Node_int const& node) {
107 out_ = node.value_str();
111 out_ = node.value_str();
115 out_ = node.value_str();
127 Node const& node = ts[nid];
132 BOOST_THROW_EXCEPTION(
134 << Rdf_err::msg_t(
"conversion error")
135 << Rdf_err::str1_t(to_string(node))
136 << Rdf_err::nested_t(boost::current_exception())