Akonadi

parttypehelper.h
1/*
2 SPDX-FileCopyrightText: 2011 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "exception.h"
10#include "query.h"
11
12namespace Akonadi
13{
14namespace Server
15{
16class PartType;
17
18AKONADI_EXCEPTION_MAKE_INSTANCE(PartTypeException);
19
20/**
21 * Methods for dealing with the PartType table.
22 */
23namespace PartTypeHelper
24{
25/**
26 * Retrieve (or create) PartType for the given fully qualified name.
27 * @param fqName Fully qualified name (NS:NAME).
28 * @throws PartTypeException
29 */
30PartType fromFqName(const QString &fqName);
31
32/**
33 * Convenience overload of the above.
34 */
35PartType fromFqName(const QByteArray &fqName);
36
37/**
38 * Retrieve (or create) PartType for the given namespace and type name.
39 * @param ns Namespace
40 * @param typeName Part type name.
41 * @throws PartTypeException
42 */
43PartType fromFqName(const QString &ns, const QString &typeName);
44
45/**
46 * Returns a query condition that matches the given part.
47 * @param fqName fully-qualified part type name
48 * @throws PartTypeException
49 */
51
52/**
53 * Returns a query condition that matches the given part type list.
54 * @param fqNames fully qualified part type name list
55 * @throws PartTypeException
56 */
58
59/**
60 * Convenience overload for the above.
61 */
62template<template<typename> class T>
63Query::Condition conditionFromFqNames(const T<QByteArray> &fqNames)
64{
66 c.setSubQueryMode(Query::Or);
67 for (const QByteArray &fqName : fqNames) {
69 }
70 return c;
71}
72
73/**
74 * Parses a fully qualified part type name into namespace/name.
75 * @param fqName fully-qualified part type name
76 * @throws PartTypeException if @p fqName does not match the NS:NAME schema
77 * @internal
78 */
79std::pair<QString, QString> parseFqName(const QString &fqName);
80
81/**
82 * Returns full part name
83 */
84QString fullName(const PartType &type);
85
86} // namespace PartTypeHelper
87
88} // namespace Server
89} // namespace Akonadi
Represents a WHERE condition tree.
Definition query.h:62
void setSubQueryMode(LogicOperator op)
Set how sub-conditions should be combined, default is And.
Definition query.cpp:49
void addCondition(const Condition &condition)
Add a WHERE condition.
Definition query.cpp:54
Query::Condition conditionFromFqNames(const QStringList &fqNames)
Returns a query condition that matches the given part type list.
std::pair< QString, QString > parseFqName(const QString &fqName)
Parses a fully qualified part type name into namespace/name.
Query::Condition conditionFromFqName(const QString &fqName)
Returns a query condition that matches the given part.
PartType fromFqName(const QString &fqName)
Retrieve (or create) PartType for the given fully qualified name.
QString fullName(const PartType &type)
Returns full part name.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.