This file is indexed.

/usr/include/nepomuk/comparisonterm.h is in kdelibs5-dev 4:4.13.0-0ubuntu1.

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
/*
   This file is part of the Nepomuk KDE project.
   Copyright (C) 2009-2010 Sebastian Trueg <trueg@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) version 3, or any
   later version accepted by the membership of KDE e.V. (or its
   successor approved by the membership of KDE e.V.), which shall
   act as a proxy defined in Section 6 of version 3 of the license.

   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
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _NEPOMUK_QUERY_COMPARISON_TERM_H_
#define _NEPOMUK_QUERY_COMPARISON_TERM_H_

#include "simpleterm.h"

#include "nepomukquery_export.h"

namespace Nepomuk {
    namespace Types {
        class Property;
    }

    namespace Query {
        /**
         * \class ComparisonTerm comparisonterm.h Nepomuk/Query/ComparisonTerm
         *
         * \brief A term matching the value of a property.
         *
         * The %ComparisonTerm is the most important term in the query API. It can be
         * used to match the values of properties. As such its core components are
         * a property(), a comparator() (see Comparator for details) and a subTerm().
         * The latter can be any other term including AndTerm, OrTerm, or even an invalid
         * term. The matching is done as follows:
         *
         * \li A LiteralTerm as subTerm() is directly matched to the value of a literal
         * property (see also Nepomuk::Types::Property::literalRangeType()) or to the
         * labels of related resources in case of a property that has a resource range.
         * \li An invalid sub term simply matches any resource or value, effectively
         * acting as a wildcard.
         * \li Any other term type will be used as a sort of subquery to match the
         * related resources. This means that the property() needs to have a resource
         * range.
         *
         * In addition to these basic features %ComparisonTerm has a few tricks up its
         * sleeve:
         *
         * \li By forcing the variable name via setVariableName() it is possible to
         * include a value matched by the term in the resulting SPARQL query (Query::toSparqlQuery())
         * or accessing it via Result::additionalBinding().
         * \li It is possible to set an aggregate function via setAggregateFunction()
         * to count or sum up the results instead of returning the actual values.
         * \li Using setSortWeight() the sorting of the results in the final query
         * can be influenced in a powerful way - especially when combined with setAggregateFunction().
         *
         * \author Sebastian Trueg <trueg@kde.org>
         *
         * \since 4.4
         */
        class NEPOMUKQUERY_EXPORT ComparisonTerm : public SimpleTerm
        {
        public:
            /**
             * %ComparisonTerm supports different ways to compare values.
             */
            enum Comparator {
                /**
                 * A LiteralTerm sub-term is matched against string literal values.
                 * Case is ignored. The literal value can contain wildcards like *.
                 */
                Contains,

                /**
                 * A LiteralTerm sub-term is matched against a string literal value
                 * using the literal term's value as a regular expression.
                 * It is highly recommended to prefer Contains over Regexp
                 * as the latter will result in much slower SPARQL REGEX filters.
                 */
                Regexp,

                /**
                 * A sub-term is matched one-to-one. Sub-terms can be any other term type.
                 */
                Equal,

                /**
                 * A LiteralTerm sub-term is matched to greater literal values.
                 */
                Greater,

                /**
                 * A LiteralTerm sub-term is matched to smaller literal values.
                 */
                Smaller,

                /**
                 * A LiteralTerm sub-term is matched to greater or equal literal values.
                 */
                GreaterOrEqual,

                /**
                 * A LiteralTerm sub-term is matched to smaller or equal literal values.
                 */
                SmallerOrEqual
            };

            /**
             * Aggregate functions which can be applied to a comparison term to influence
             * the value they return.
             *
             * \sa setAggregateFunction()
             *
             * \since 4.5
             */
            enum AggregateFunction {
                /**
                 * Do not use any aggregate function.
                 */
                NoAggregateFunction = 0,

                /**
                 * Count the number of matching results instead
                 * of returning the results themselves.
                 * For counting the results of a complete query use
                 * Query::CreateCountQuery.
                 */
                Count,

                /**
                 * The same as Count except that no two similar results
                 * are counted twice.
                 */
                DistinctCount,

                /**
                 * Return the maximum value of all results instead
                 * of the results themselves.
                 * Does only make sense for numerical values.
                 */
                Max,

                /**
                 * Return the minimum value of all results instead
                 * of the results themselves.
                 * Does only make sense for numerical values.
                 */
                Min,

                /**
                 * Return the sum of all result values instead
                 * of the results themselves.
                 * Does only make sense for numerical values.
                 */
                Sum,

                /**
                 * The same as Sum except that no two similar results
                 * are added twice.
                 */
                DistinctSum,

                /**
                 * Return the average value of all results instead
                 * of the results themselves.
                 * Does only make sense for numerical values.
                 */
                Average,

                /**
                 * The same as Average except that no two similar results
                 * are counted twice.
                 */
                DistinctAverage
            };

            /**
             * Default constructor: creates a comparison term that matches all properties.
             */
            ComparisonTerm();

            /**
             * Copy constructor.
             */
            ComparisonTerm( const ComparisonTerm& term );

            /**
             * Convinience constructor which covers most simple use cases.
             *
             * \param property The property that should be matched. An invalid property will act as a wildcard.
             * \param term The sub term to match to.
             * \param comparator The Comparator to use for comparison. Not all Comparators make sense
             * with all sub term types.
             */
            ComparisonTerm( const Types::Property& property, const Term& term, Comparator comparator = Contains );

            /**
             * Destructor.
             */
            ~ComparisonTerm();

            /**
             * Assignment operator.
             */
            ComparisonTerm& operator=( const ComparisonTerm& term );

            /**
             * The Comparator used by ComparisonTerm Terms.
             *
             * \sa setComparator
             */
            Comparator comparator() const;

            /**
             * A property used for ComparisonTerm Terms.
             * An invalid property will act as a wildcard.
             *
             * \sa setProperty
             */
            Types::Property property() const;

            /**
             * Set the comparator
             */
            void setComparator( Comparator );

            /**
             * Set the property for ComparisonTerm
             * Terms. An invalid property will act as a wildcard.
             *
             * \sa property
             */
            void setProperty( const Types::Property& );

            /**
             * Set the variable name that is to be used for the
             * variable to match to. The variable will then be added
             * to the set of variables returned in the results and can
             * be read via Result::additionalBinding(). Setting
             * the variable name can be seen as a less restricted variant
             * of Query::addRequestProperty().
             *
             * When manually setting the variable name on more
             * than one ComparisonTerm there is no guarantee for the
             * uniqueness of variable names anymore which can result
             * in unwanted query results. However, this can also be
             * used deliberately in case one needs to compare the
             * same variable twice:
             *
             * \code
             * ComparisonTerm ct1( prop1, Term() );
             * ComparisonTerm ct1( prop2, Term() );
             * ct1.setVariableName( "myvar" );
             * ct2.setVariableName( "myvar" );
             * \endcode
             *
             * The above example would result in a SPARQL query
             * pattern along the lines of
             *
             * \code
             * ?r <prop1> ?myVar .
             * ?r <prop2> ?myVar .
             * \endcode
             *
             * Be aware that the variable name does not apply
             * to sub terms of types ResourceTerm or LiteralTerm.
             * In those cases the value will be ignored. The only exception
             * are LiteralTerm sub terms that are compared other than
             * with equals.
             *
             * \param name The name of the variable to be used when requesting
             * the binding via Result::additionalBinding()
             *
             * \sa Result::additionalBinding(), Query::HandleInverseProperties, \ref examples_query
             *
             * \since 4.5
             */
            void setVariableName( const QString& name );

            /**
             * The variable name set in setVariableName() or an empty
             * string if none has been set.
             *
             * \sa setVariableName()
             *
             * \since 4.5
             */
            QString variableName() const;

            /**
             * Set an aggregate function which changes the
             * result. The typical usage is to count the results instead of actually
             * returning them. For counting the results of a complete query use
             * Query::CreateCountQuery.
             *
             * \sa aggregateFunction()
             *
             * \since 4.5
             */
            void setAggregateFunction( AggregateFunction function );

            /**
             * The aggregate function to be used with the additional binding set in
             * setVariableName().
             *
             * \sa setAggregateFunction()
             *
             * \since 4.5
             */
            AggregateFunction aggregateFunction() const;

            /**
             * Set the sort weight of this property. By default all ComparisonTerms have
             * a weight of 0 which means that they are ignored for sorting. By setting \p
             * weight to a value different from 0 (typically higher than 0) the comparison
             * subterm will be used for sorting.
             *
             * Be aware that as with the variableName() sorting does not apply to sub
             * terms of types ResourceTerm or LiteralTerm.
             * In those cases the value will be ignored. The only exception
             * are LiteralTerm sub terms that are compared other than
             * with equals.
             *
             * \param weight The new sort weight. If different from 0 this term will be
             * used for sorting in the Query.
             * \param sortOrder The sort order to use for this term.
             *
             * \sa sortWeight()
             *
             * \since 4.5
             */
            void setSortWeight( int weight, Qt::SortOrder sortOrder = Qt::AscendingOrder );

            /**
             * \return The sort weight as set in setSortWeight() or 0 if
             * sorting is disabled for this term.
             *
             * \since 4.5
             */
            int sortWeight() const;

            /**
             * \return The sort order as set in setSortWeight().
             *
             * \since 4.5
             */
            Qt::SortOrder sortOrder() const;

            /**
             * \return \p true if the comparison is inverted.
             * \sa setInverted
             *
             * \since 4.5
             */
            bool isInverted() const;

            /**
             * Invert the comparison, i.e. make the subterm the subject
             * of the term and match to objects of the term.
             *
             * A typical example would be:
             *
             * \code
             * ComparisonTerm term( Soprano::Vocabulary::NAO::hasTag(),
             *                      ResourceTerm( somefile ) );
             * term.setInverted(true);
             * \endcode
             *
             * which would yield a query like the following:
             *
             * \code
             * select ?r where { <somefile> nao:hasTag ?r . }
             * \endcode
             *
             * to get all tags attached to a file.
             *
             * Be aware that this does only make sense with
             * sub terms that match to resources. When using
             * LiteralTerm as a sub term \p invert is ignored.
             *
             * \sa inverted()
             *
             * \since 4.5
             */
            void setInverted( bool invert );

            /**
             * Create an inverted copy of this %ComparisonTerm.
             * This is a convenience method to allow inline creation of
             * inverted comparison terms when creating queries in a
             * single line of code.
             *
             * Be aware that calling this method twice wil result in
             * a non-inverted comparison term:
             *
             * \code
             * // always true:
             * (term.inverted().inverted() == term);
             * \endcode
             *
             * \sa setInverted()
             *
             * \since 4.5
             */
            ComparisonTerm inverted() const;
        };
    }
}

#endif