owlcpp  v0.3.3~
C++ library for working with OWL ontologies
 All Classes Namespaces Files Functions Macros Pages
print_node.hpp
Go to the documentation of this file.
1 
6 #ifndef PRINT_NODE_HPP_
7 #define PRINT_NODE_HPP_
8 #include <ostream>
9 #include "owlcpp/rdf/config.hpp"
10 #include "owlcpp/rdf/node_fwd.hpp"
11 #include "owlcpp/rdf/node_iri.hpp"
12 #include "owlcpp/rdf/print_id.hpp"
14 
15 namespace owlcpp{
16 class Triple_store;
17 
20 OWLCPP_RDF_DECL std::string to_string(Node const&);
21 
24 inline std::string to_string(Node_iri const& node) {
25  return to_string(node.ns_id()) + ':' + node.fragment();
26 }
27 
30 OWLCPP_RDF_DECL std::string to_string(Node_blank const& node);
31 
34 OWLCPP_RDF_DECL std::string to_string(Node_bool const& node);
35 
38 OWLCPP_RDF_DECL std::string to_string(Node_int const& node);
39 
42 OWLCPP_RDF_DECL std::string to_string(Node_unsigned const& node);
43 
46 OWLCPP_RDF_DECL std::string to_string(Node_double const& node);
47 
50 OWLCPP_RDF_DECL std::string to_string(Node_string const& node);
51 
54 OWLCPP_RDF_DECL std::string to_string_full(Node const&, Triple_store const&);
55 
58 OWLCPP_RDF_DECL std::string to_string_full(const Node_id, Triple_store const&);
59 
62 template<class Store> inline std::string
63 to_string_full(Node_iri const& node, Store const& store) {
64  if( node.fragment().empty() ) return store[node.ns_id()].str();
65  return store[node.ns_id()].str() + '#' + node.fragment();
66 }
67 
70 OWLCPP_RDF_DECL std::string to_string_pref(Node const&, Triple_store const&);
71 
74 OWLCPP_RDF_DECL std::string to_string_pref(const Node_id, Triple_store const&);
75 
78 template<class Store> inline std::string
79 to_string_pref(Node_iri const& node, Store const& store) {
80  const Ns_id nsid = node.ns_id();
81  const std::string pref = store.prefix(nsid);
82  if( pref.empty() ) return to_string(node);
83  return pref + ':' + node.fragment();
84 }
85 
88 OWLCPP_RDF_DECL std::string to_string(Node const&, Triple_store const&);
89 
92 OWLCPP_RDF_DECL std::string to_string(const Node_id, Triple_store const&);
93 
96 template<class Store> inline std::string
97 to_string(Node_iri const& node, Store const& store) {
98  const Ns_id nsid = node.ns_id();
99  const std::string pref = store.prefix(nsid);
100  if( pref.empty() ) return to_string_full<Store>(node, store);
101  return pref + ':' + node.fragment();
102 }
103 
106 template<class Ch, class Tr> inline std::basic_ostream<Ch,Tr>&
107  operator<<(std::basic_ostream<Ch,Tr>& os, Node const& node) {
108  return os << to_string(node);
109 }
110 
111 }//namespace owlcpp
112 #endif /* PRINT_NODE_HPP_ */