This file is indexed.

/usr/include/soprano/node.h is in libsoprano-dev 2.9.4+dfsg1-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
/*
 * This file is part of Soprano Project.
 *
 * Copyright (C) 2006-2007 Daniele Galdi <daniele.galdi@gmail.com>
 * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef SOPRANO_NODE_H
#define SOPRANO_NODE_H

#include <QtCore/QUrl>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QTextStream>

#include "soprano_export.h"
#include "literalvalue.h"
#include "languagetag.h"
#include "sopranomacros.h"

namespace Soprano
{
    /**
     * \class Node node.h Soprano/Node
     *
     * \brief A Node represents one RDF resource.
     *
     * Nodes are the cornerstone of RDF data in %Soprano. Four Nodes form one Statement and a Model
     * is essentially a set of Statements.
     *
     * A Node can have one of four types: EmptyNode, ResourceNode, LiteralNode, and BlankNode.
     * Resource nodes are identified through their URI (uri()), literal nodes have a LiteralValue (literal()),
     * and blank nodes have a string identifier.
     *
     * Empty nodes can be used as wildcards in methods such as Model::listStatements.
     *
     * \author Daniele Galdi <daniele.galdi@gmail.com><br>Sebastian Trueg <trueg@kde.org>
     */
    class SOPRANO_EXPORT Node
    {
    public:
        enum Type {
            EmptyNode    = 0, /**< An empty node, can be used as a wildcard in commands like Model::listStatements. */
            ResourceNode = 1, /**< A resource node has a URI which can be accessed via uri() */
            LiteralNode  = 2, /**< A literal node has a literal value and an optional language. */
            BlankNode    = 3  /**< A blank node has an identifier string */
        };

        /**
         * \name Constructors
         */
        //@{
        /**
         * Default costructor.
         * Creates an empty node.
         *
         * \sa createEmptyNode()
         */
        Node();

        // This constructor is non-explicit for a reason: it makes creating
        // Statements much much easier and more readable
        /**
         * Creates a resource node.
         *
         * \param uri The URI of the node. If empty the type will be ignored
         *            and an empty node will be created.
         *
         * \sa createResourceNode()
         */
        Node( const QUrl &uri );

        /**
         * Creates a blank node.
         *
         * \param id An identifier for the blank node.
         *
         * \sa createBlankNode()
         */
        explicit Node( const QString& id );

        /**
         * Creates a literal node.
         *
         * \param value The value of a node. If empty the node will become
         *              an empty node.
         *
         * \sa createLiteralNode()
         *
         * \since 2.3
         */
        Node( const LiteralValue& value );

        /**
         * Creates a literal node.
         *
         * \param value The value of a node. If empty the node will become
         *              an empty node.
         * \param language The language of the literal value.
         *
         * \sa createLiteralNode()
         *
         * \deprecated Use Soprano::Node::Node( const LiteralValue& ) and
         *             Soprano::LiteralValue::createPlainLiteral( const QString&, const LanguageTag& )
         */
        SOPRANO_CONSTRUCTOR_DEPRECATED Node( const LiteralValue& value,
                                             const QString& language );

        /**
         * Copy constructor.
         */
        Node( const Node &other );

        ~Node();
        //@}

        /**
         * \name Operators
         */
        //@{
        Node& operator=( const Node& other );

        /**
         * Assigns \p resource to this node and makes it a ResourceNode.
         */
        Node& operator=( const QUrl& resource );

        /**
         * Assigns \p literal to this node and makes it a LiteralNode.
         */
        Node& operator=( const LiteralValue& literal );

        /**
         * Comparision operator.
         * \return \p true if this node and \p other are equal.
         */
        bool operator==( const Node& other ) const;

        /**
         * Comparision operator.
         * \return \p true if this node and \p other differ.
         */
        bool operator!=( const Node& other ) const;

        /**
         * Comparision operator.
         * \return \p true if this node is a ResourceNode and
         * has URI \p uri.
         */
        bool operator==( const QUrl& uri ) const;

        /**
         * Comparision operator.
         * \return \p true if this node is a LiteralNode and
         * has literal value \p other.
         */
        bool operator==( const LiteralValue& other ) const;

        /**
         * Match this node against template node \a other. The only difference
         * to operator== is that empty nodes are matched as wildcards,
         * i.e. they match any other node.
         *
         * Be aware that the following is NOT always true since only \a other
         * is treated a a wildcard:
         *
         * \code
         * // NOT always true:
         * a.matches(b) == b.matches(a)
         * \endcode
         *
         * \return \p true if this node matches other, \p false if not.
         *
         * \sa Statement::matches
         */
        bool matches( const Node& other ) const;
        //@}

        /**
         * \name Type information
         */
        //@{
        /**
         * \return The node type.
         */
        Type type() const;

        /**
         * \return \p true if the node is empty.
         */
        bool isEmpty() const;

        /**
         * \return \p true if the node is a ResourceNode, LiteralNode or BlankNode.
         */
        bool isValid() const ;

        /**
         * \return \p true if the node is a LiteralNode.
         */
        bool isLiteral() const;

        /**
         * \return \p true if the node is a ResourceNode.
         */
        bool isResource() const;

        /**
         * \return \p true if the node is a BlankNode (anonymous).
         */
        bool isBlank() const;
        //@}

        /**
         * \name Resource nodes
         */
        //@{
        /**
         * \return The URI if the node is a ResourceNode.
         *         An null QUrl otherwise.
         */
        QUrl uri() const;
        //@}

        /**
         * \name Blank nodes
         */
        //@{
        /**
         * Retrieve a blank node's identifier.
         * \return The node's identifier if it is a BlankNode, a null
         * string otherwise.
         */
        QString identifier() const;
        //@}

        /**
         * \name Literal nodes
         */
        //@{
        /**
         * \return The literal value if the node is a LiteralNode.
         *         An null QString otherwise.
         */
        LiteralValue literal() const;

        /**
         * \return The datatype URI of a literal node, i.e. the XML schema type
         *         or an empty value if the node is not a LiteralNode.
         * \sa LiteralValue::dataTypeUri
         */
        QUrl dataType() const;

        /**
         * Each literal value can have an associated language, thus each property
         * can be stored for different languages. An empty language refers to the
         * default language.
         *
         * \return A string representing the language of the literal value
         *         or an empty string if the node is not a literal.
         *
         * \deprecated Language exists on the Soprano::LiteralValue. Use Soprano::Node::literal() and
         *             Soprano::LiteralValue::language().
         */
        QString language() const;
        //@}

        /**
         * \name Conversion
         */
        //@{
        /**
         * Converts the Node to a string.
         *
         * \return A String representation of the Node, suitable for storage,
         * not really suitable for user readable strings.
         *
         * \sa LiteralValue::toString(), QUrl::toString(), toN3()
         */
        QString toString() const;

        /**
         * Convert a Node into N3 notation to be used in SPARQL graph patterns.
         *
         * Examples:
         * \code
         * <http://soprano.sourceforce.net/>
         * "Hello World"^^<http://www.w3.org/2001/XMLSchema#string>
         * "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>
         * _:blankNode
         * \endcode
         *
         * \return A string representing the node in N3 encoding or an empty
         * string for invalid nodes.
         *
         * \sa resourceToN3(), literalToN3(), blankToN3(), fromN3(), toString()
         *
         * \since 2.2
         */
        QString toN3() const;
        //@}

        /**
         * Convenience method to create an empty node.
         * Using this method instead of the default constructor
         * may result in better readable code.
         *
         * \return An empty Node.
         */
        static Node createEmptyNode();

        /**
         * Convenience method to create a resource node.
         * Using this method instead of the constructor
         * may result in better readable code.
         *
         * \param uri The URI of the node. If empty the type will be ignored
         *            and an empty node will be created.
         *
         * \return A resource Node or an empty Node if the specified URI is empty.
         */
        static Node createResourceNode( const QUrl& uri );

        /**
         * Convenience method to create a blank node.
         * Using this method instead of the constructor
         * may result in better readable code.
         *
         * If you need to create a new blank node which is not
         * used in the model yet and, thus, has a unique identifier
         * see Model::createBlankNode().
         *
         * \param id An identifier for the blank node.
         *
         * \return A blank node or an empty Node if the specified
         * identifier was empty.
         */
        static Node createBlankNode( const QString& id );

        /**
         * Convenience method to create a literal node.
         * Using this method instead of the constructor
         * may result in better readable code.
         *
         * \param value The value of a node. If empty the node will become
         *              an empty node.
         *
         * \return A literal node or an empty node if the specified value
         * was empty.
         *
         * \since 2.3
         */
        static Node createLiteralNode( const LiteralValue& value );

        /**
         * Convenience method to create a literal node.
         * Using this method instead of the constructor
         * may result in better readable code.
         *
         * \param value The value of a node. If empty the node will become
         *              an empty node.
         * \param language The language of the literal value.
         *
         * \return A literal node or an empty node if the specified value
         * was empty.
         *
         * \deprecated Use Soprano::Node::createLiteralNode( const LiteralValue& ) and
         *             Soprano::LiteralValue::createPlainLiteral( const QString&, const LanguageTag& )
         */
        static SOPRANO_DEPRECATED Node createLiteralNode( const LiteralValue& value, const QString& language );

        /**
         * Format a resource URI as N3 string to be used in SPARQL queries.
         *
         * \return A string representing the resource in N3 encoding or an empty
         * string for invalid URIs.
         *
         * Example:
         * \code
         * <http://soprano.sourceforce.net/>
         * \endcode
         *
         * \sa toN3(), fromN3()
         *
         * \since 2.3
         */
        static QString resourceToN3( const QUrl& resource );

        /**
         * Format a blank node identifier as N3 string to be used in SPARQL queries.
         *
         * \return A string representing the blank identifier in N3 encoding or an empty
         * string for invalid/empty ids.
         *
         * Example:
         * \code
         * _:blankNode
         * \endcode
         *
         * \sa toN3(), fromN3()
         *
         * \since 2.3
         */
        static QString blankToN3( const QString& blank );

        /**
         * Format a literal value as N3 string to be used in SPARQL queries.
         *
         * \return A string representing the literal in N3 encoding or an empty
         * string for invalid literals.
         *
         * Examples:
         * \code
         * "Hello World"^^<http://www.w3.org/2001/XMLSchema#string>
         * "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>
         * \endcode
         *
         * \sa toN3(), fromN3()
         *
         * \since 2.3
         */
        static QString literalToN3( const LiteralValue& literal );

        /**
         * Parsing flags to infuence the behaviour of the parser in
         * fromN3() and fromN3Stream().
         *
         * \since 2.5
         */
        enum N3ParserFlag {
            /**
             * No parsing flags, default behaviour.
             */
            NoFlags = 0x0,

            /**
             * Use strict literal parsing, i.e. do not treat
             * \p true and \p false as boolean literals or
             * do not handle numbers as literals if they do
             * not contain a literal type.
             */
            StrictLiteralTypes = 0x1,

            /**
             * Use strict URI parsing.
             *
             * \sa QUrl::StrictMode
             */
            StrictUris = 0x2,

            /**
             * Do not make use of m_prefixes
             */
            IgnorePrefixes = 0x4
        };
        Q_DECLARE_FLAGS( N3ParserFlags, N3ParserFlag )

        /**
         * Convert a node from its N3 representation.
         *
         * \param n3 The N3 representation of the node.
         *
         * \return A %Node representing the parsed version of \p n3 or an invalid %Node in case
         * parsing failed.
         *
         * \sa resourceToN3(), literalToN3(), blankToN3(), toN3()
         *
         * \since 2.5
         */
        static Node fromN3( const QString& n3, N3ParserFlags flags = NoFlags );

        /**
         * Read a node from its N3 representation on a stream.
         *
         * \param stream The stream from which the N3 representation of the node will be read.
         *
         * \return A %Node representing the parsed version of \p n3 or an invalid %Node in case
         * parsing failed.
         *
         * \sa resourceToN3(), literalToN3(), blankToN3(), toN3()
         *
         * \since 2.5
         */
        static Node fromN3Stream( QTextStream& stream, N3ParserFlags flags = NoFlags );

    private:
        class NodeData;
        class ResourceNodeData;
        class BNodeData;
        class LiteralNodeData;
        QSharedDataPointer<NodeData> d;
    };

    /**
     * \relates Soprano::Node
     */
    SOPRANO_EXPORT uint qHash( const Node& node );
}

/**
 * \relates Soprano::Node
 */
SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& );

/**
 * Default Soprano::Node stream operator. The operator serializes the Node
 * based on the N-Triples standard, except that it uses Unicode strings.
 *
 * \sa Soprano::Node::toN3()
 *
 * \relates Soprano::Node
 */
SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Node& );

/**
 * Read a node from an N3 encoded string.
 *
 * \sa Soprano::Node::fromN3()
 *
 * \since 2.5
 */
SOPRANO_EXPORT QTextStream& operator>>( QTextStream& s, Soprano::Node& );

#if QT_VERSION < 0x040700
SOPRANO_EXPORT uint qHash( const QUrl& url );
#endif

Q_DECLARE_OPERATORS_FOR_FLAGS( Soprano::Node::N3ParserFlags )

#endif // SOPRANO_NODE_H