| 1 | /* |
| 2 | This file is part of the syndication library |
| 3 | SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef SYNDICATION_RDF_STATEMENT_H |
| 9 | #define SYNDICATION_RDF_STATEMENT_H |
| 10 | |
| 11 | #include <syndication/rdf/property.h> |
| 12 | |
| 13 | class QString; |
| 14 | |
| 15 | namespace Syndication |
| 16 | { |
| 17 | namespace RDF |
| 18 | { |
| 19 | //@cond PRIVATE |
| 20 | class Statement; |
| 21 | typedef QSharedPointer<Statement> StatementPtr; |
| 22 | //@endcond |
| 23 | |
| 24 | /*! |
| 25 | * An RDF statement, consisting of a triple |
| 26 | * (subject, predicate, object). |
| 27 | */ |
| 28 | class Statement |
| 29 | { |
| 30 | friend class Model; |
| 31 | |
| 32 | public: |
| 33 | /*! |
| 34 | * creates a null statement |
| 35 | */ |
| 36 | Statement(); |
| 37 | |
| 38 | /*! |
| 39 | * creates a copy of another statement |
| 40 | * |
| 41 | * \a other the statement to copy |
| 42 | */ |
| 43 | Statement(const Statement &other); |
| 44 | |
| 45 | /*! |
| 46 | * creates a statement |
| 47 | * Do not call this in your code, use Model::createStatement() instead. |
| 48 | * |
| 49 | * \a subject the subject resource of the statement |
| 50 | * \a predicate the predicate of the statement |
| 51 | * \a object the object node of the statement |
| 52 | */ |
| 53 | Statement(ResourcePtr subject, PropertyPtr predicate, NodePtr object); |
| 54 | |
| 55 | /*! |
| 56 | * destructor |
| 57 | */ |
| 58 | virtual ~Statement(); |
| 59 | |
| 60 | /*! |
| 61 | * assigns another statement |
| 62 | * |
| 63 | * \a other the statement to assign |
| 64 | */ |
| 65 | Statement &operator=(const Statement &other); |
| 66 | |
| 67 | /*! |
| 68 | * returns whether two statements are equal. |
| 69 | * Currently statements are equal, if they are from the same model (!) |
| 70 | * and subject, predicate and object are equal. |
| 71 | * |
| 72 | * \a other the statement to compare to |
| 73 | */ |
| 74 | virtual bool operator==(const Statement &other) const; |
| 75 | |
| 76 | /*! |
| 77 | * returns whether this statement is a null statement (i.e. was created |
| 78 | * using Statement()) |
| 79 | */ |
| 80 | virtual bool isNull() const; |
| 81 | |
| 82 | /*! |
| 83 | * the subject of the statement. |
| 84 | */ |
| 85 | virtual ResourcePtr subject() const; |
| 86 | |
| 87 | /*! |
| 88 | * the predicate of the statement |
| 89 | */ |
| 90 | virtual PropertyPtr predicate() const; |
| 91 | |
| 92 | /*! |
| 93 | * the object of the statement |
| 94 | */ |
| 95 | virtual NodePtr object() const; |
| 96 | |
| 97 | /*! |
| 98 | * returns the object of this statement as resource, if possible. |
| 99 | * |
| 100 | * @return the object node as Resource, or @c null if the object |
| 101 | * is not a resource |
| 102 | */ |
| 103 | virtual ResourcePtr asResource() const; |
| 104 | |
| 105 | /*! |
| 106 | * returns the object of this statement as string, if possible. |
| 107 | * |
| 108 | * @return the literal text as QString, or a null string if the object |
| 109 | * is not a literal |
| 110 | */ |
| 111 | virtual QString asString() const; |
| 112 | |
| 113 | private: |
| 114 | class StatementPrivate; |
| 115 | QSharedPointer<StatementPrivate> d; |
| 116 | }; |
| 117 | |
| 118 | } // namespace RDF |
| 119 | } // namespace Syndication |
| 120 | |
| 121 | #endif // SYNDICATION_RDF_STATEMENT_H |
| 122 | |