9 #ifndef LITERAL_DATATYPES_HPP_
10 #define LITERAL_DATATYPES_HPP_
12 #include "boost/cstdint.hpp"
13 #include "boost/lexical_cast.hpp"
14 #include "boost/numeric/conversion/cast.hpp"
21 namespace owlcpp{
namespace detail{
26 typedef bool value_type;
27 typedef owlcpp::terms::xsd_boolean default_datatype;
29 static value_type convert(std::string
const& str,
const Node_id dt) {
30 if( str ==
"true" )
return true;
31 if( str ==
"false" )
return false;
32 return boost::lexical_cast<value_type>(str);
35 template<
class T>
static value_type convert(
const T x,
const Node_id) {
36 return boost::numeric_cast<value_type>(x);
39 static std::string
const& name_str(
const Node_id) {
44 static std::string to_string(value_type
const v,
const Node_id) {
45 return v ?
"true" :
"false";
52 typedef boost::intmax_t value_type;
53 typedef owlcpp::terms::xsd_int default_datatype;
55 static value_type convert(std::string
const& str,
const Node_id dt) {
56 return boost::lexical_cast<value_type>(str);
59 template<
class T>
static value_type convert(
const T x,
const Node_id) {
60 return boost::numeric_cast<value_type>(x);
63 static std::string
const& name_str(
const Node_id) {
68 static std::string to_string(value_type
const v,
const Node_id) {
69 return boost::lexical_cast<std::string>(v);
76 typedef boost::uintmax_t value_type;
77 typedef owlcpp::terms::xsd_unsignedInt default_datatype;
79 static value_type convert(std::string
const& str,
const Node_id dt) {
80 return boost::numeric_cast<value_type>(
81 boost::lexical_cast<Datatype_int::value_type>(str)
85 template<
class T>
static value_type convert(
const T x,
const Node_id) {
86 return boost::numeric_cast<value_type>(x);
89 static std::string
const& name_str(
const Node_id) {
94 static std::string to_string(value_type
const v,
const Node_id) {
95 return boost::lexical_cast<std::string>(v);
102 typedef double value_type;
103 typedef owlcpp::terms::xsd_double default_datatype;
105 static value_type convert(std::string
const& str,
const Node_id dt) {
106 return boost::lexical_cast<value_type>(str);
109 template<
class T>
static value_type convert(
const T x,
const Node_id) {
110 return boost::numeric_cast<value_type>(x);
113 static std::string
const& name_str(
const Node_id) {
114 static const std::string name(
to_string_pref(default_datatype()));
118 static std::string to_string(value_type
const v,
const Node_id) {
119 return boost::lexical_cast<std::string>(v);
126 typedef std::string value_type;
127 typedef owlcpp::terms::xsd_string default_datatype;
129 static value_type
const& convert(std::string
const& str,
const Node_id dt) {
133 template<
class T>
static value_type convert(
const T x) {
return x;}
135 static std::string
const& name_str(
const Node_id) {
136 static const std::string name(
to_string_pref(default_datatype()));