MailImporter

mailimporter_utils.h
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QString>
10
11namespace MailImporter
12{
13/**
14 * Glorified QString[N] for (a) understandability (b) older gcc compatibility.
15 */
16template<unsigned int size>
18{
19public:
20 typedef QString NString[size];
21 /** Constructor. Need a default constructor for QValueList. */
25
26 /** Constructor. Turn N QStrings into a folder structure
27 * description.
28 */
29 FolderStructureBase(const NString &s)
30 {
31 for (unsigned int i = 0; i < size; i++) {
32 d[i] = s[i];
33 }
34 }
35
36 /** Copy Constructor. */
38 {
39 for (unsigned int i = 0; i < size; i++) {
40 d[i] = s[i];
41 }
42 }
43
44 /** Assignment operator. Does the same thing as
45 * the copy constructor.
46 */
48 {
49 for (unsigned int i = 0; i < size; i++) {
50 d[i] = s[i];
51 }
52 return *this;
53 }
54
55 /** Access the different fields. There doesn't seem to
56 * be a real semantics for the fields.
57 */
58 const QString operator[](unsigned int i) const
59 {
60 if (i < size) {
61 return d[i];
62 } else {
63 return QString();
64 }
65 }
66
67 /** Access the different fields, for writing. */
68 QString &operator[](unsigned int i)
69 {
70 Q_ASSERT(i < size);
71 if (i < size) {
72 return d[i];
73 } else {
74 return d[0];
75 }
76 }
77
78private:
79 QString d[size];
80};
81}
Glorified QString[N] for (a) understandability (b) older gcc compatibility.
const QString operator[](unsigned int i) const
Access the different fields.
QString & operator[](unsigned int i)
Access the different fields, for writing.
FolderStructureBase & operator=(const FolderStructureBase &s)
Assignment operator.
FolderStructureBase(const FolderStructureBase &s)
Copy Constructor.
FolderStructureBase(const NString &s)
Constructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.