6 #include "knowrob/semweb/Triple.h"
7 #include "knowrob/integration/python/utils.h"
8 #include "knowrob/Logger.h"
15 std::istringstream(str.data()) >> result;
22 std::istringstream(str.data()) >> std::fixed >> result;
28 std::istringstream(str.data()) >> std::boolalpha >> result;
72 static const auto a_true =
"true";
73 static const auto a_false =
"false";
82 std::ostringstream os;
87 std::ostringstream os;
211 if (
end() != other.
end()) {
212 return end() < other.
end();
228 if (
end() != other.
end())
return false;
276 bool sameEnd =
end() == other.
end();
277 bool sameTime = sameBegin && sameEnd;
301 }
else if (other.
begin()) {
304 if (
end() && other.
end()) {
306 }
else if (other.
end()) {
312 }
else if (!other.
begin().has_value()) {
315 if (
end() && other.
end()) {
317 }
else if (!other.
end().has_value()) {
335 os <<
',' <<
" g=" <<
graph().value();
347 os <<
',' <<
" b=" <<
begin().value();
350 os <<
',' <<
" e=" <<
end().value();
357 struct TripleWrap :
public Triple, boost::python::wrapper<Triple> {
358 explicit TripleWrap(PyObject *p) :
Triple(), self(p) {}
360 void setSubject(std::string_view subject)
override { call_method<void>(
self,
"setSubject", subject); }
362 void setPredicate(std::string_view
predicate)
override { call_method<void>(
self,
"setPredicate",
predicate); }
364 void setObjectIRI(std::string_view
object)
override { call_method<void>(
self,
"setObjectIRI",
object); }
366 void setSubjectBlank(std::string_view str)
override { call_method<void>(
self,
"setSubjectBlank", str); }
368 void setObjectBlank(std::string_view str)
override { call_method<void>(
self,
"setObjectBlank", str); }
370 std::string_view subject()
const override {
return call_method<std::string_view>(
self,
"subject"); }
372 std::string_view
predicate()
const override {
return call_method<std::string_view>(
self,
"predicate"); }
374 void setGraph(std::string_view graph)
override { call_method<void>(
self,
"setGraph", graph); }
376 void setPerspective(std::string_view perspective)
override {
377 call_method<void>(
self,
"setPerspective", perspective);
380 std::optional<std::string_view> graph()
const override {
381 return call_method<std::optional<std::string_view>>(
self,
"graph");
384 std::optional<std::string_view> perspective()
const override {
385 return call_method<std::optional<std::string_view>>(
self,
"perspective");
388 std::string_view valueAsString()
const override {
return call_method<std::string_view>(
self,
"valueAsString"); }
397 class_<Triple, std::shared_ptr<TripleWrap>, boost::noncopyable>
399 .def(
"__eq__", &Triple::operator==)
431 class_<TripleCopy, std::shared_ptr<TripleCopy>, bases<Triple>>
432 (
"TripleCopy", init<>())
433 .def(init<std::string_view, std::string_view, std::string_view>());
434 class_<TripleView, std::shared_ptr<TripleView>, bases<Triple>>
435 (
"TripleView", init<>())
436 .def(init<std::string_view, std::string_view, std::string_view>());
437 class_<TriplePtr>(
"TriplePtr", init<>())
438 .def(
"get", &
TriplePtr::get, return_value_policy<reference_existing_object>());
T xsdConvFixed(std::string_view str)
bool xsdConvBool(std::string_view str)
T xsdConv(std::string_view str)
virtual std::string_view valueAsString() const =0
void write(std::ostream &os) const override
virtual short valueAsShort() const =0
virtual std::optional< std::string_view > perspective() const =0
virtual void setDoubleValue(double v)=0
virtual unsigned int valueAsUnsignedInt() const =0
virtual void setSubject(std::string_view subject)=0
virtual std::optional< std::string_view > graph() const =0
std::optional< double > end_
bool isXSDLiteral() const
virtual double valueAsDouble() const =0
virtual void setGraph(std::string_view graph)=0
virtual void setIntValue(int v)=0
virtual void setStringValue(std::string_view v)=0
virtual void setUnsignedLongValue(unsigned long v)=0
void setConfidence(double confidence)
virtual std::string_view subject() const =0
bool isSubjectIRI() const
std::optional< double > confidence_
virtual float valueAsFloat() const =0
bool operator==(const Triple &other) const
virtual void setPerspective(std::string_view perspective)=0
void setIsUncertain(bool isUncertain)
virtual void setLongValue(long v)=0
void setIsOccasional(bool isOccasional)
bool isSubjectBlank() const
std::optional< double > begin_
bool mergeFrame(const Triple &other)
virtual std::string_view predicate() const =0
void setBegin(double begin)
virtual long valueAsLong() const =0
std::string createStringValue() const
virtual void setObjectIRI(std::string_view object)=0
virtual void setUnsignedIntValue(unsigned int v)=0
bool operator<(const Triple &other) const
virtual unsigned short valueAsUnsignedShort() const =0
virtual void setObjectBlank(std::string_view str)=0
virtual unsigned long valueAsUnsignedLong() const =0
virtual void setUnsignedShortValue(unsigned short v)=0
virtual void setSubjectBlank(std::string_view str)=0
virtual void setPredicate(std::string_view predicate)=0
virtual void setShortValue(short v)=0
bool isOccasional() const
bool isObjectBlank() const
virtual int valueAsInt() const =0
virtual bool valueAsBoolean() const =0
virtual void setBooleanValue(bool v)=0
void setXSDValue(std::string_view v, XSDType type)
void createType< Triple >()
XSDType
The XSDType enum Enumeration of the XSD types.