Debian Codegraph @

Source/Control/Interface/SPARQL/CSPARQLXMLAnswerStreamingSerializer.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_CONTROL_INTERFACE_OWLLINK_CSPARQLXMLANSWERSTREAMINGSERIALIZER_H
22 #define KONCLUDE_CONTROL_INTERFACE_OWLLINK_CSPARQLXMLANSWERSTREAMINGSERIALIZER_H
23
24 // Libraries includes
25 #include <QString>
26 #include <QXmlStreamWriter>
27 #include <QMap>
28 #include <QVector>
29 #include <QBuffer>
30
31 // Namespace includes
32
33 #include "Reasoner/Query/CVariableBindingsAnswersStreamingResult.h"
34 #include "Reasoner/Query/CVariableBindingsAnswersResult.h"
35 #include "Reasoner/Query/CBooleanQueryResult.h"
36 #include "Reasoner/Query/CQueryStatistics.h"
37
38 #include "Reasoner/Kernel/Process/CProcessingStatistics.h"
39
40
41 // Other includes
42
43
44 // Logger includes
45 #include "Logger/CLogger.h"
46
47 using namespace Konclude::Logger;
48
49
50 namespace Konclude {
51
52 using namespace Reasoner::Query;
53 using namespace Reasoner::Kernel::Process;
54
55 namespace Control {
56
57 namespace Interface {
58
59 namespace SPARQL {
60
61 /*!
62 *
63 * \class CSPARQLXMLAnswerStreamingSerializer
64 * \author Andreas Steigmiller
65 * \version 0.1
66 * \brief TODO
67 *
68 */
69 class CSPARQLXMLAnswerStreamingSerializer {
70 // public methods
71 public:
72 //! Constructor
73 CSPARQLXMLAnswerStreamingSerializer(QByteArray* buffer = nullptr, bool writeHeaderAndFooter = true);
74
75 //! Destructor
76 virtual ~CSPARQLXMLAnswerStreamingSerializer();
77
78
79 cint64 getBufferWrittenSize();
80 QByteArray* updateWriteBuffer(QByteArray* buffer);
81
82
83 CSPARQLXMLAnswerStreamingSerializer* addResultSerialization(CBooleanQueryResult* booleanResult);
84 CSPARQLXMLAnswerStreamingSerializer* addResultSerialization(const QStringList& varList, CVariableBindingsAnswersResult* variableBindingsAnswersResult);
85 CSPARQLXMLAnswerStreamingSerializer* addResultStatistics(CQueryStatistics* queryStats);
86
87
88 CSPARQLXMLAnswerStreamingSerializer* addResultError(const QString& errorString, const QString &nodeString);
89
90
91 CSPARQLXMLAnswerStreamingSerializer* finish();
92
93 CSPARQLXMLAnswerStreamingSerializer* addResultStreamingStart(const QStringList& varList);
94 CSPARQLXMLAnswerStreamingSerializer* addResultStreamingBinding(const QStringList& varList, CVariableBindingsAnswerResult* bindings);
95
96
97 CSPARQLXMLAnswerStreamingSerializer* forceHeaderWritten();
98
99 // protected methods
100 protected:
101 virtual CSPARQLXMLAnswerStreamingSerializer* writeResultStreamingStart();
102 virtual CSPARQLXMLAnswerStreamingSerializer* writeResultStreamingEnd();
103
104
105
106 // protected variables
107 protected:
108 QBuffer* mCurrentBuffer;
109 QByteArray* mCurrentArray;
110 QXmlStreamWriter* mStreamWriter;
111
112 bool mWriteHeaderAndFooter;
113
114 bool mSparqlHeaderWritten;
115 bool mSparqlFooterWritten;
116 CVariableBindingsResultIterator* mVarBindIt = nullptr;
117
118 QString sparqlNS;
119 QString owlNS;
120 QString xsdNS;
121
122 // private methods
123 private:
124
125 // private variables
126 private:
127
128 };
129
130 }; // end namespace SPARQL
131
132 }; // end namespace Interface
133
134 }; // end namespace Control
135
136 }; // end namespace Konclude
137
138 #endif // KONCLUDE_CONTROL_INTERFACE_OWLLINK_CSPARQLXMLAnswerStreamingSerializer_H