File indexing completed on 2024-11-24 04:44:39
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 * SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef RDF_H 0007 #define RDF_H 0008 0009 #include <QString> 0010 0011 #include <vector> 0012 0013 class QIODevice; 0014 0015 /** Universal RDF Dataset Normalization Algorithm 2015 (URDNA2015) 0016 * @note This is far from a complete implementation of the full spec, this barely 0017 * covers enough for the needs of DIVOC JWS verification. 0018 */ 0019 namespace Rdf 0020 { 0021 class Term { 0022 public: 0023 enum Type { 0024 Undefined, 0025 IRI, 0026 Literal, 0027 BlankNode, 0028 } type = Undefined; 0029 QString value; 0030 QString literalType; 0031 0032 bool operator<(const Term &other) const; 0033 bool operator==(const Term &other) const; 0034 }; 0035 0036 class Quad { 0037 public: 0038 Term subject; 0039 Term predicate; 0040 Term object; 0041 // ### graph - not relevant for us 0042 0043 bool operator<(const Quad &other) const; 0044 }; 0045 0046 /** Apply the Universal RDF Dataset Normalization Algorithm 2015 (URDNA2015) to @p quads. */ 0047 void normalize(std::vector<Rdf::Quad> &quads); 0048 0049 /** Write list of RDF quads to @p out. */ 0050 QByteArray serialize(const std::vector<Rdf::Quad> &quads); 0051 void serialize(QIODevice *out, const std::vector<Rdf::Quad> &quads); 0052 void serialize(QIODevice *out, const Rdf::Quad &quad); 0053 void serialize(QIODevice *out, const Rdf::Term &term); 0054 0055 } 0056 0057 #endif // RDF_H