Blame lang/qt/src/dn.h

Packit Service 672cf4
/*
Packit Service 672cf4
    dn.h
Packit Service 672cf4
Packit Service 672cf4
    This file is part of qgpgme, the Qt API binding for gpgme
Packit Service 672cf4
    Copyright (c) 2004 Klarälvdalens Datakonsult AB
Packit Service 672cf4
    Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Packit Service 672cf4
    Software engineering by Intevation GmbH
Packit Service 672cf4
Packit Service 672cf4
    QGpgME is free software; you can redistribute it and/or
Packit Service 672cf4
    modify it under the terms of the GNU General Public License as
Packit Service 672cf4
    published by the Free Software Foundation; either version 2 of the
Packit Service 672cf4
    License, or (at your option) any later version.
Packit Service 672cf4
Packit Service 672cf4
    QGpgME is distributed in the hope that it will be useful,
Packit Service 672cf4
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 672cf4
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 672cf4
    General Public License for more details.
Packit Service 672cf4
Packit Service 672cf4
    You should have received a copy of the GNU General Public License
Packit Service 672cf4
    along with this program; if not, write to the Free Software
Packit Service 672cf4
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit Service 672cf4
Packit Service 672cf4
    In addition, as a special exception, the copyright holders give
Packit Service 672cf4
    permission to link the code of this program with any edition of
Packit Service 672cf4
    the Qt library by Trolltech AS, Norway (or with modified versions
Packit Service 672cf4
    of Qt that use the same license as Qt), and distribute linked
Packit Service 672cf4
    combinations including the two.  You must obey the GNU General
Packit Service 672cf4
    Public License in all respects for all of the code used other than
Packit Service 672cf4
    Qt.  If you modify this file, you may extend this exception to
Packit Service 672cf4
    your version of the file, but you are not obligated to do so.  If
Packit Service 672cf4
    you do not wish to do so, delete this exception statement from
Packit Service 672cf4
    your version.
Packit Service 672cf4
*/
Packit Service 672cf4
#ifndef QGPGME_DN_H
Packit Service 672cf4
#define QGPGME_DN_H
Packit Service 672cf4
Packit Service 672cf4
#include "qgpgme_export.h"
Packit Service 672cf4
Packit Service 672cf4
#include <QString>
Packit Service 672cf4
#include <QStringList>
Packit Service 672cf4
Packit Service 672cf4
#include <QVector>
Packit Service 672cf4
Packit Service 672cf4
namespace QGpgME
Packit Service 672cf4
{
Packit Service 672cf4
Packit Service 672cf4
/**
Packit Service 672cf4
   @short DN parser and reorderer
Packit Service 672cf4
*/
Packit Service 672cf4
class QGPGME_EXPORT DN
Packit Service 672cf4
{
Packit Service 672cf4
public:
Packit Service 672cf4
    class Attribute;
Packit Service 672cf4
    typedef QVector<Attribute> AttributeList;
Packit Service 672cf4
    typedef AttributeList::const_iterator const_iterator;
Packit Service 672cf4
Packit Service 672cf4
    DN();
Packit Service 672cf4
    explicit DN(const QString &dn;;
Packit Service 672cf4
    explicit DN(const char *utf8DN);
Packit Service 672cf4
    DN(const DN &other);
Packit Service 672cf4
    ~DN();
Packit Service 672cf4
Packit Service 672cf4
    const DN &operator=(const DN &other);
Packit Service 672cf4
Packit Service 672cf4
    /** @return the value in rfc-2253-escaped form */
Packit Service 672cf4
    static QString escape(const QString &value);
Packit Service 672cf4
Packit Service 672cf4
    /** @return the DN in a reordered form, according to the settings in
Packit Service 672cf4
        the [DN] group of the application's config file */
Packit Service 672cf4
    QString prettyDN() const;
Packit Service 672cf4
    /** @return the DN in the original form */
Packit Service 672cf4
    QString dn() const;
Packit Service 672cf4
    /**
Packit Service 672cf4
       \overload
Packit Service 672cf4
       Uses \a sep as separator (default: ,)
Packit Service 672cf4
    */
Packit Service 672cf4
    QString dn(const QString &sep) const;
Packit Service 672cf4
Packit Service 672cf4
    QString operator[](const QString &attr) const;
Packit Service 672cf4
Packit Service 672cf4
    void append(const Attribute &attr);
Packit Service 672cf4
Packit Service 672cf4
    const_iterator begin() const;
Packit Service 672cf4
    const_iterator end() const;
Packit Service 672cf4
Packit Service 6c01f9
    /** Set the order in which prettyDN will reorder the Attirbutes. */
Packit Service 672cf4
    void setAttributeOrder(const QStringList &order) const;
Packit Service 672cf4
Packit Service 672cf4
    /** Get the used attribute order. */
Packit Service 672cf4
    const QStringList & attributeOrder() const;
Packit Service 672cf4
Packit Service 672cf4
private:
Packit Service 672cf4
    void detach();
Packit Service 672cf4
private:
Packit Service 672cf4
    class Private;
Packit Service 672cf4
    Private *d;
Packit Service 672cf4
};
Packit Service 672cf4
Packit Service 672cf4
class QGPGME_EXPORT DN::Attribute
Packit Service 672cf4
{
Packit Service 672cf4
public:
Packit Service 672cf4
    typedef DN::AttributeList List;
Packit Service 672cf4
Packit Service 672cf4
    explicit Attribute(const QString &name = QString(), const QString &value = QString())
Packit Service 672cf4
        : mName(name.toUpper()), mValue(value) {}
Packit Service 672cf4
    Attribute(const Attribute &other)
Packit Service 672cf4
        : mName(other.name()), mValue(other.value()) {}
Packit Service 672cf4
Packit Service 672cf4
    const Attribute &operator=(const Attribute &other)
Packit Service 672cf4
    {
Packit Service 672cf4
        if (this != &other) {
Packit Service 672cf4
            mName = other.name();
Packit Service 672cf4
            mValue = other.value();
Packit Service 672cf4
        }
Packit Service 672cf4
        return *this;
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
    const QString &name() const
Packit Service 672cf4
    {
Packit Service 672cf4
        return mName;
Packit Service 672cf4
    }
Packit Service 672cf4
    const QString &value() const
Packit Service 672cf4
    {
Packit Service 672cf4
        return mValue;
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
    void setValue(const QString &value)
Packit Service 672cf4
    {
Packit Service 672cf4
        mValue = value;
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
private:
Packit Service 672cf4
    QString mName;
Packit Service 672cf4
    QString mValue;
Packit Service 672cf4
};
Packit Service 672cf4
} // namespace QGpgME
Packit Service 672cf4
#endif // QGPGME_DN_H