File indexing completed on 2025-02-16 06:55:38
0001 /* 0002 This file is part of the syndication library 0003 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef SYNDICATION_RDF_STATEMENT_H 0009 #define SYNDICATION_RDF_STATEMENT_H 0010 0011 #include <syndication/rdf/property.h> 0012 0013 class QString; 0014 0015 namespace Syndication 0016 { 0017 namespace RDF 0018 { 0019 //@cond PRIVATE 0020 class Statement; 0021 typedef QSharedPointer<Statement> StatementPtr; 0022 //@endcond 0023 0024 /** 0025 * An RDF statement, consisting of a triple 0026 * (subject, predicate, object). 0027 */ 0028 class Statement 0029 { 0030 friend class Model; 0031 0032 public: 0033 /** 0034 * creates a null statement 0035 */ 0036 Statement(); 0037 0038 /** 0039 * creates a copy of another statement 0040 * 0041 * @param other the statement to copy 0042 */ 0043 Statement(const Statement &other); 0044 0045 /** 0046 * creates a statement 0047 * Do not call this in your code, use Model::createStatement() instead. 0048 * 0049 * @param subject the subject resource of the statement 0050 * @param predicate the predicate of the statement 0051 * @param object the object node of the statement 0052 */ 0053 Statement(ResourcePtr subject, PropertyPtr predicate, NodePtr object); 0054 0055 /** 0056 * destructor 0057 */ 0058 virtual ~Statement(); 0059 0060 /** 0061 * assigns another statement 0062 * 0063 * @param other the statement to assign 0064 */ 0065 Statement &operator=(const Statement &other); 0066 0067 /** 0068 * returns whether two statements are equal. 0069 * Currently statements are equal, if they are from the same model (!) 0070 * and subject, predicate and object are equal. 0071 * 0072 * @param other the statement to compare to 0073 */ 0074 virtual bool operator==(const Statement &other) const; 0075 0076 /** 0077 * returns whether this statement is a null statement (i.e. was created 0078 * using Statement()) 0079 */ 0080 virtual bool isNull() const; 0081 0082 /** 0083 * the subject of the statement. 0084 */ 0085 virtual ResourcePtr subject() const; 0086 0087 /** 0088 * the predicate of the statement 0089 */ 0090 virtual PropertyPtr predicate() const; 0091 0092 /** 0093 * the object of the statement 0094 */ 0095 virtual NodePtr object() const; 0096 0097 /** 0098 * returns the object of this statement as resource, if possible. 0099 * 0100 * @return the object node as Resource, or @c null if the object 0101 * is not a resource 0102 */ 0103 virtual ResourcePtr asResource() const; 0104 0105 /** 0106 * returns the object of this statement as string, if possible. 0107 * 0108 * @return the literal text as QString, or a null string if the object 0109 * is not a literal 0110 */ 0111 virtual QString asString() const; 0112 0113 private: 0114 class StatementPrivate; 0115 QSharedPointer<StatementPrivate> d; 0116 }; 0117 0118 } // namespace RDF 0119 } // namespace Syndication 0120 0121 #endif // SYNDICATION_RDF_STATEMENT_H