/usr/include/nepomuk/term.h is in kdelibs5-dev 4:4.8.2-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 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 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | /*
This file is part of the Nepomuk KDE project.
Copyright (C) 2007-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 Library General Public
License version 2 as published by the Free Software Foundation.
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 _NEPOMUK_SEARCH_TERM_H_
#define _NEPOMUK_SEARCH_TERM_H_
#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtCore/QSharedDataPointer>
#include <Soprano/LiteralValue>
#include "nepomukquery_export.h"
namespace Nepomuk {
class Variant;
namespace Types {
class Property;
}
namespace Query {
class LiteralTerm;
class ResourceTerm;
class NegationTerm;
class AndTerm;
class OrTerm;
class ComparisonTerm;
class ResourceTypeTerm;
class OptionalTerm;
class TermPrivate;
/**
* \class Term term.h Nepomuk/Query/Term
*
* \brief The base class for all term types.
*
* Queries are build from Term instances. A Term can have one of multiple
* types and subterms. See Term::Type for details on the different Term types.
*
* \author Sebastian Trueg <trueg@kde.org>
*
* \since 4.4
*/
class NEPOMUKQUERY_EXPORT Term
{
public:
/**
* The type of a term identifying its meaning.
*
* \sa type()
*/
enum Type {
/**
* An invalid term matching nothing
*/
Invalid,
/**
* A literal term is the simplest form of %Term. It simply contains a literal
* value.
*
* \sa LiteralTerm
*/
Literal,
/**
* A resource term matches one resource by URI.
*
* \sa ResourceTerm
*/
Resource,
/**
* Match all resources that match all sub terms.
*
* \sa AndTerm
*/
And,
/**
* Match all resources that match one of the sub terms.
*
* \sa OrTerm
*/
Or,
/**
* A comparison. The comparison operator needs to be specified in addition.
* A single subterm specifies the resource or value to match.
*
* \sa ComparisonTerm
*/
Comparison,
/**
* Matches all resources of a specific type.
*
* \sa ResourceTypeTerm
*/
ResourceType,
/**
* A negation term inverts the meaning of its sub term.
*
* \sa NegationTerm
*/
Negation,
/**
* An optional term which marks its sub term as optional.
*
* \sa OptionalTerm
*
* \since 4.5
*/
Optional
};
/**
* Constructs an invalid term.
*/
Term();
/**
* Copy constructor.
*/
Term( const Term& other );
/**
* Destructor
*/
~Term();
/**
* Copy operator.
*/
Term& operator=( const Term& other );
/**
* \return \p true if the term is valid. A valid
* term can be used to construct a Query.
*/
bool isValid() const;
/**
* \return the Term type.
*/
Type type() const;
/**
* Optimizes the term without changing its meaning. This removes
* redundant terms such as NegationTerm and OptionalTerm nestings and flattens
* AndTerm and OrTerm hierarchies.
*
* \return An optimized version of this term.
*
* \since 4.6
*
* \sa Query::optimized()
*/
Term optimized() const;
/**
* \return \p true if this term is a LiteralTerm.
*/
bool isLiteralTerm() const;
/**
* \return \p true if this term is a ResourceTerm.
*/
bool isResourceTerm() const;
/**
* \return \p true if this term is a NegationTerm.
*/
bool isNegationTerm() const;
/**
* \return \p true if this term is a OptionalTerm.
*
* \since 4.5
*/
bool isOptionalTerm() const;
/**
* \return \p true if this term is an AndTerm.
*/
bool isAndTerm() const;
/**
* \return \p true if this term is an OrTerm.
*/
bool isOrTerm() const;
/**
* \return \p true if this term is a ComparisonTerm.
*/
bool isComparisonTerm() const;
/**
* \return \p true if this term is a ResourceTypeTerm.
*/
bool isResourceTypeTerm() const;
/**
* Interpret this term as a LiteralTerm.
*
* \return A copy of this term if its type
* is Literal, a new LiteralTerm otherwise.
*/
LiteralTerm toLiteralTerm() const;
/**
* Interpret this term as a ResourceTerm.
*
* \return A copy of this term if its type
* is Resource, a new ResourceTerm otherwise.
*/
ResourceTerm toResourceTerm() const;
/**
* Interpret this term as a NegationTerm.
*
* \return A copy of this term if its type
* is Negation, a new NegationTerm otherwise.
*/
NegationTerm toNegationTerm() const;
/**
* Interpret this term as a OptionalTerm.
*
* \return A copy of this term if its type
* is Optional, a new OptionalTerm otherwise.
*
* \since 4.5
*/
OptionalTerm toOptionalTerm() const;
/**
* Interpret this term as a AndTerm.
*
* \return A copy of this term if its type
* is And, a new AndTerm otherwise.
*/
AndTerm toAndTerm() const;
/**
* Interpret this term as a OrTerm.
*
* \return A copy of this term if its type
* is Or, a new OrTerm otherwise.
*/
OrTerm toOrTerm() const;
/**
* Interpret this term as a ComparisonTerm.
*
* \return A copy of this term if its type
* is Comparison, a new ComparisonTerm otherwise.
*/
ComparisonTerm toComparisonTerm() const;
/**
* Interpret this term as a ResourceTypeTerm.
*
* \return A copy of this term if its type
* is ClassType, a new ResourceTypeTerm otherwise.
*/
ResourceTypeTerm toResourceTypeTerm() const;
/**
* Convert this term into a LiteralTerm.
* If type is not Literal it will be changed
* and the result is a new LiteralTerm.
*
* \return A reference to this term as a LiteralTerm.
*/
LiteralTerm& toLiteralTerm();
/**
* Convert this term into a ResourceTerm.
* If type is not Resource it will be changed
* and the result is a new ResourceTerm.
*
* \return A reference to this term as a ResourceTerm.
*/
ResourceTerm& toResourceTerm();
/**
* Convert this term into a NegationTerm.
* If type is not Negation it will be changed
* and the result is a new NegationTerm.
*
* \return A reference to this term as a NegationTerm.
*/
NegationTerm& toNegationTerm();
/**
* Convert this term into a OptionalTerm.
* If type is not Optional it will be changed
* and the result is a new OptionalTerm.
*
* \return A reference to this term as a OptionalTerm.
*
* \since 4.5
*/
OptionalTerm& toOptionalTerm();
/**
* Convert this term into a AndTerm.
* If type is not And it will be changed
* and the result is a new AndTerm.
*
* \return A reference to this term as a AndTerm.
*/
AndTerm& toAndTerm();
/**
* Convert this term into a OrTerm.
* If type is not Or it will be changed
* and the result is a new OrTerm.
*
* \return A reference to this term as a OrTerm.
*/
OrTerm& toOrTerm();
/**
* Convert this term into a ComparisonTerm.
* If type is not Comparison it will be changed
* and the result is a new ComparisonTerm.
*
* \return A reference to this term as a ComparisonTerm.
*/
ComparisonTerm& toComparisonTerm();
/**
* Convert this term into a ResourceTypeTerm.
* If type is not ClassType it will be changed
* and the result is a new ResourceTypeTerm.
*
* \return A reference to this term as a ResourceTypeTerm.
*/
ResourceTypeTerm& toResourceTypeTerm();
/**
* Encode the Term in a string. Be aware that this does NOT create a SPARQL
* query. The returned string can be used to serialize terms that can later
* be read via fromString().
*
* \sa fromString()
*
* \since 4.5
*/
QString toString() const;
/**
* Parse a Term that has been encoded as a string via toString().
*
* \warning This method can NOT parse SPARQL syntax.
*
* \sa toString()
*
* \since 4.5
*/
static Term fromString( const QString& s );
/**
* Construct a Term from a Variant value. This is a convenience method
* that simplifies handling Nepomuk values. However, list variants are
* not supported and will result in an invalid Term.
*
* \return A ResourceTerm in case \p variant is a resource, a LiteralTerm
* if \p variant is a supported literal value, or an invalid Term if \p
* variant is invalid or a list.
*
* \since 4.6
*/
static Term fromVariant( const Variant& variant );
/**
* Create a term using a Types::Property and a Variant. Sadly this cannot be modelled
* as an operator since it would clash with Entity::operator==().
*
* \param property The property to be used in the ComparisonTerm.
* \param variant The value to be compared to. Either ResourceTerm or LiteralTerm is used. List
* variants (Variant::isList()) are handled via an AndTerm meaning all values need to match.
*
* \since 4.6
*
* \relates ComparisonTerm
*/
static Term fromProperty( const Types::Property& property, const Variant& variant );
/**
* Comparison operator.
*
* \return \p true if this term is equal to \p term.
*/
bool operator==( const Term& term ) const;
/**
* Comparison operator.
*
* \return \p true if this term differs from \p term.
*
* \since 4.6
*/
bool operator!=( const Term& term ) const;
// FIXME: the compiler does not find this operator!
QDebug operator<<( QDebug ) const;
/** \cond protected_term_members */
protected:
Term( TermPrivate* );
QSharedDataPointer<TermPrivate> d_ptr;
friend class TermPrivate;
friend class GroupTermPrivate;
friend class AndTermPrivate;
friend class OrTermPrivate;
friend class ComparisonTermPrivate;
friend class NegationTermPrivate;
friend class OptionalTermPrivate;
friend class Query;
friend class QueryPrivate;
/** \endcond */
};
/**
* Logical and operator which combines two terms into
* one term matching both \p term1 and \p term2.
*
* \relates AndTerm
*
* \since 4.6
*/
NEPOMUKQUERY_EXPORT Term operator&&( const Term& term1, const Term& term2 );
/**
* Logical or operator which combines two terms into
* one term matching either \p term1 or \p term2.
*
* \relates OrTerm
*
* \since 4.6
*/
NEPOMUKQUERY_EXPORT Term operator||( const Term& term1, const Term& term2 );
/**
* Logical negation operator which negates the meaning of
* one term.
*
* \sa NegationTerm::negateTerm()
* \relates NegationTerm
*
* \since 4.6
*/
NEPOMUKQUERY_EXPORT Term operator!( const Term& term );
/**
* Comparision operator for simple creation of ComparisonTerm objects using the
* ComparisonTerm::Smaller comparator.
*
* \return A ComparisonTerm equvalent to:
*
* \code
* ComparisonTerm( property, term, ComparisonTerm::Smaller );
* \endcode
*
* \since 4.6
*
* \relates ComparisonTerm
*/
NEPOMUKQUERY_EXPORT ComparisonTerm operator<( const Types::Property& property, const Term& term );
/**
* Comparision operator for simple creation of ComparisonTerm objects using the
* ComparisonTerm::Greater comparator.
*
* \return A ComparisonTerm equvalent to:
*
* \code
* ComparisonTerm( property, term, ComparisonTerm::Greater );
* \endcode
*
* \since 4.6
*
* \relates ComparisonTerm
*/
NEPOMUKQUERY_EXPORT ComparisonTerm operator>( const Types::Property& property, const Term& term );
/**
* Comparision operator for simple creation of ComparisonTerm objects using the
* ComparisonTerm::SmallerOrEqual comparator.
*
* \return A ComparisonTerm equvalent to:
*
* \code
* ComparisonTerm( property, term, ComparisonTerm::SmallerOrEqual );
* \endcode
*
* \since 4.6
*
* \relates ComparisonTerm
*/
NEPOMUKQUERY_EXPORT ComparisonTerm operator<=( const Types::Property& property, const Term& term );
/**
* Comparision operator for simple creation of ComparisonTerm objects using the
* ComparisonTerm::GreaterOrEqual comparator.
*
* \return A ComparisonTerm equvalent to:
*
* \code
* ComparisonTerm( property, term, ComparisonTerm::GreaterOrEqual );
* \endcode
*
* \since 4.6
*
* \relates ComparisonTerm
*/
NEPOMUKQUERY_EXPORT ComparisonTerm operator>=( const Types::Property& property, const Term& term );
/**
* Comparision operator for simple creation of ComparisonTerm objects using the
* ComparisonTerm::Equal comparator.
*
* \return A ComparisonTerm equvalent to:
*
* \code
* ComparisonTerm( property, term, ComparisonTerm::Equal );
* \endcode
*
* \since 4.6
*
* \relates ComparisonTerm
*/
NEPOMUKQUERY_EXPORT ComparisonTerm operator==( const Types::Property& property, const Term& term );
/**
* Comparision operator for simple creation of negated ComparisionTerm objects using the
* ComparisonTerm::Equal comparator.
*
* \since 4.6
*
* \return A Term equvalent to:
*
* \code
* NegationTerm::negateTerm( ComparisonTerm( property, term, ComparisonTerm::Equal ) );
* \endcode
*
* \relates ComparisonTerm
*
* \sa NegationTerm
*/
NEPOMUKQUERY_EXPORT Term operator!=( const Types::Property& property, const Term& term );
NEPOMUKQUERY_EXPORT uint qHash( const Nepomuk::Query::Term& );
}
}
/** \cond hide_nepomuk_term_clone_from_doxygen */
// there is a hand written instantiation of clone()
template<> Nepomuk::Query::TermPrivate* QSharedDataPointer<Nepomuk::Query::TermPrivate>::clone();
/** \endcond */
// FIXME: the compiler does not find the operator in the class
NEPOMUKQUERY_EXPORT QDebug operator<<( QDebug, const Nepomuk::Query::Term& );
#endif
|