QGpgME  2.1.0-unknown
Qt API for GpgME
dn.h
1 /*
2  dn.h
3 
4  This file is part of qgpgme, the Qt API binding for gpgme
5  Copyright (c) 2004 Klarälvdalens Datakonsult AB
6  Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
7  Software engineering by Intevation GmbH
8  Copyright (c) 2024 g10 Code GmbH
9  Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
10 
11  QGpgME is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 2 of the
14  License, or (at your option) any later version.
15 
16  QGpgME is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 
25  In addition, as a special exception, the copyright holders give
26  permission to link the code of this program with any edition of
27  the Qt library by Trolltech AS, Norway (or with modified versions
28  of Qt that use the same license as Qt), and distribute linked
29  combinations including the two. You must obey the GNU General
30  Public License in all respects for all of the code used other than
31  Qt. If you modify this file, you may extend this exception to
32  your version of the file, but you are not obligated to do so. If
33  you do not wish to do so, delete this exception statement from
34  your version.
35 */
36 #ifndef QGPGME_DN_H
37 #define QGPGME_DN_H
38 
39 #include "qgpgme_export.h"
40 
41 #include <QMetaType>
42 #include <QString>
43 #include <QStringList>
44 
45 #include <QVector>
46 
47 namespace QGpgME
48 {
49 
53 class QGPGME_EXPORT DN
54 {
55 public:
56  class Attribute;
57  typedef QVector<Attribute> AttributeList;
58  typedef AttributeList::const_iterator const_iterator;
59 
60  DN();
61  explicit DN(const QString &dn);
62  explicit DN(const char *utf8DN);
63  DN(const DN &other);
64  ~DN();
65 
66  const DN &operator=(const DN &other);
67 
69  static QString escape(const QString &value);
70 
72  QString prettyDN() const;
74  QString dn() const;
79  QString dn(const QString &sep) const;
80 
84  QStringList prettyAttributes() const;
85 
86  QString operator[](const QString &attr) const;
87 
88  void append(const Attribute &attr);
89 
90  const_iterator begin() const;
91  const_iterator end() const;
92 
94  void setAttributeOrder(const QStringList &order) const;
95 
97  const QStringList & attributeOrder() const;
98 
99 private:
100  void detach();
101 private:
102  class Private;
103  Private *d;
104 };
105 
106 class QGPGME_EXPORT DN::Attribute
107 {
108 public:
109  typedef DN::AttributeList List;
110 
111  explicit Attribute(const QString &name = QString(), const QString &value = QString())
112  : mName(name.toUpper()), mValue(value) {}
113  Attribute(const Attribute &other)
114  : mName(other.name()), mValue(other.value()) {}
115 
116  const Attribute &operator=(const Attribute &other)
117  {
118  if (this != &other) {
119  mName = other.name();
120  mValue = other.value();
121  }
122  return *this;
123  }
124 
125  const QString &name() const
126  {
127  return mName;
128  }
129  const QString &value() const
130  {
131  return mValue;
132  }
133 
134  void setValue(const QString &value)
135  {
136  mValue = value;
137  }
138 
139 private:
140  QString mName;
141  QString mValue;
142 };
143 } // namespace QGpgME
144 
145 Q_DECLARE_METATYPE(QGpgME::DN::Attribute);
146 
147 #endif // QGPGME_DN_H
Definition: dn.cpp:80
DN parser and reorderer.
Definition: dn.h:53
Definition: abstractimportjob.h:48