knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
String.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 "knowrob/terms/String.h"
7 #include "knowrob/integration/python/utils.h"
8 
9 using namespace knowrob;
10 
11 bool StringBase::isSameString(const StringBase &other) const {
12  return stringForm() == other.stringForm();
13 }
14 
15 void StringBase::write(std::ostream &os) const {
16  os << '"' << stringForm() << '"';
17 }
18 
19 namespace knowrob::py {
20  template<>
22  using namespace boost::python;
23  class_<StringBase, std::shared_ptr<StringBase>, bases<XSDAtomic>, boost::noncopyable>
24  ("StringTerm", no_init)
25  .def("isSameString", &StringBase::isSameString);
26  class_<String, std::shared_ptr<String>, bases<StringBase>>
27  ("String", init<std::string_view>())
28  .def("__str__", &String::stringForm)
29  .def("__repr__", &String::stringForm);
30  class_<StringView, std::shared_ptr<StringView>, bases<StringBase>>
31  ("StringView", init<std::string_view>())
32  .def("__str__", &StringView::stringForm)
33  .def("__repr__", &StringView::stringForm);
34  }
35 }
virtual std::string_view stringForm() const =0
void write(std::ostream &os) const override
Definition: String.cpp:15
bool isSameString(const StringBase &other) const
Definition: String.cpp:11
std::string_view stringForm() const override
Definition: String.h:44
void createType< String >()
Definition: String.cpp:21