knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
RDFNode.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #include <boost/algorithm/string/predicate.hpp>
7 #include "knowrob/terms/RDFNode.h"
8 #include "knowrob/integration/python/utils.h"
9 
10 namespace knowrob {
11  RDFNodeType rdfNodeTypeGuess(std::string_view str) {
12  if (str.empty()) return RDFNodeType::LITERAL;
13  if (str[0] == '_') return RDFNodeType::BLANK;
14  if (str[0] == '<') return RDFNodeType::IRI;
15  if (boost::algorithm::starts_with(str, "http://") ||
16  boost::algorithm::starts_with(str, "https://"))
17  return RDFNodeType::IRI;
18  if (boost::algorithm::starts_with(str, "genid")) return RDFNodeType::BLANK;
19  return RDFNodeType::LITERAL;
20  }
21 }
22 
23 namespace knowrob::py {
24  template<>
26  using namespace boost::python;
27  enum_<RDFNodeType>("RDFNodeType")
28  .value("BLANK", RDFNodeType::BLANK)
29  .value("IRI", RDFNodeType::IRI)
30  .value("LITERAL", RDFNodeType::LITERAL)
31  .export_values();
32  class_<RDFNode, std::shared_ptr<RDFNode>, boost::noncopyable>("RDFNode", no_init)
33  .def("rdfNodeType", &RDFNode::rdfNodeType);
34  }
35 }
auto rdfNodeType() const
Definition: RDFNode.h:31
void createType< RDFNode >()
Definition: RDFNode.cpp:25
RDFNodeType rdfNodeTypeGuess(std::string_view str)
Definition: RDFNode.cpp:11
RDFNodeType
Definition: RDFNode.h:15