Blame lang/cpp/src/data.h

Packit Service 672cf4
/*
Packit Service 672cf4
  data.h - wraps a gpgme data object
Packit Service 672cf4
  Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
Packit Service 672cf4
Packit Service 672cf4
  This file is part of GPGME++.
Packit Service 672cf4
Packit Service 672cf4
  GPGME++ is free software; you can redistribute it and/or
Packit Service 672cf4
  modify it under the terms of the GNU Library General Public
Packit Service 672cf4
  License as published by the Free Software Foundation; either
Packit Service 672cf4
  version 2 of the License, or (at your option) any later version.
Packit Service 672cf4
Packit Service 672cf4
  GPGME++ 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
Packit Service 672cf4
  GNU Library General Public License for more details.
Packit Service 672cf4
Packit Service 672cf4
  You should have received a copy of the GNU Library General Public License
Packit Service 672cf4
  along with GPGME++; see the file COPYING.LIB.  If not, write to the
Packit Service 672cf4
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit Service 672cf4
  Boston, MA 02110-1301, USA.
Packit Service 672cf4
*/
Packit Service 672cf4
Packit Service 672cf4
#ifndef __GPGMEPP_DATA_H__
Packit Service 672cf4
#define __GPGMEPP_DATA_H__
Packit Service 672cf4
Packit Service 672cf4
#include "global.h"
Packit Service 672cf4
#include "key.h"
Packit Service 672cf4
Packit Service 672cf4
#include <sys/types.h> // for size_t, off_t
Packit Service 672cf4
#include <cstdio> // FILE
Packit Service 672cf4
#include <algorithm>
Packit Service 672cf4
#include <memory>
Packit Service 672cf4
Packit Service 672cf4
namespace GpgME
Packit Service 672cf4
{
Packit Service 672cf4
Packit Service 672cf4
class DataProvider;
Packit Service 672cf4
class Error;
Packit Service 672cf4
Packit Service 672cf4
class GPGMEPP_EXPORT Data
Packit Service 672cf4
{
Packit Service 672cf4
    struct Null {
Packit Service 672cf4
		Null() {}
Packit Service 672cf4
	};
Packit Service 672cf4
public:
Packit Service 672cf4
    /* implicit */ Data(const Null &);
Packit Service 672cf4
    Data();
Packit Service 672cf4
    explicit Data(gpgme_data_t data);
Packit Service 672cf4
Packit Service 672cf4
    // Memory-Based Data Buffers:
Packit Service 672cf4
    Data(const char *buffer, size_t size, bool copy = true);
Packit Service 672cf4
    explicit Data(const char *filename);
Packit Service 672cf4
    Data(const char *filename, off_t offset, size_t length);
Packit Service 672cf4
    Data(std::FILE *fp, off_t offset, size_t length);
Packit Service 672cf4
    // File-Based Data Buffers:
Packit Service 672cf4
    explicit Data(std::FILE *fp);
Packit Service 672cf4
    explicit Data(int fd);
Packit Service 672cf4
    // Callback-Based Data Buffers:
Packit Service 672cf4
    explicit Data(DataProvider *provider);
Packit Service 672cf4
Packit Service 672cf4
    static const Null null;
Packit Service 672cf4
Packit Service 672cf4
    const Data &operator=(Data other)
Packit Service 672cf4
    {
Packit Service 672cf4
        swap(other);
Packit Service 672cf4
        return *this;
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
    void swap(Data &other)
Packit Service 672cf4
    {
Packit Service 672cf4
        using std::swap;
Packit Service 672cf4
        swap(this->d, other.d);
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
    bool isNull() const;
Packit Service 672cf4
Packit Service 672cf4
    enum Encoding {
Packit Service 672cf4
        AutoEncoding,
Packit Service 672cf4
        BinaryEncoding,
Packit Service 672cf4
        Base64Encoding,
Packit Service 672cf4
        ArmorEncoding,
Packit Service 672cf4
        MimeEncoding,
Packit Service 672cf4
        UrlEncoding,
Packit Service 672cf4
        UrlEscEncoding,
Packit Service 672cf4
        Url0Encoding,
Packit Service 672cf4
    };
Packit Service 672cf4
    Encoding encoding() const;
Packit Service 672cf4
    Error setEncoding(Encoding encoding);
Packit Service 672cf4
Packit Service 672cf4
    enum Type {
Packit Service 672cf4
        Invalid,
Packit Service 672cf4
        Unknown,
Packit Service 672cf4
        PGPSigned,
Packit Service 672cf4
        PGPOther,
Packit Service 672cf4
        PGPKey,
Packit Service 672cf4
        CMSSigned,
Packit Service 672cf4
        CMSEncrypted,
Packit Service 672cf4
        CMSOther,
Packit Service 672cf4
        X509Cert,
Packit Service 672cf4
        PKCS12,
Packit Service 672cf4
        PGPEncrypted,
Packit Service 672cf4
        PGPSignature,
Packit Service 672cf4
    };
Packit Service 672cf4
    Type type() const;
Packit Service 672cf4
Packit Service 672cf4
    char *fileName() const;
Packit Service 672cf4
    Error setFileName(const char *name);
Packit Service 672cf4
Packit Service 672cf4
    ssize_t read(void *buffer, size_t length);
Packit Service 672cf4
    ssize_t write(const void *buffer, size_t length);
Packit Service 672cf4
    off_t seek(off_t offset, int whence);
Packit Service 672cf4
Packit Service 672cf4
    /** Try to parse the data to a key object using the
Packit Service 672cf4
     * Protocol proto. Returns an empty list on error.*/
Packit Service 672cf4
    std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
Packit Service 672cf4
Packit Service 672cf4
    class Private;
Packit Service 672cf4
    Private *impl()
Packit Service 672cf4
    {
Packit Service 672cf4
        return d.get();
Packit Service 672cf4
    }
Packit Service 672cf4
    const Private *impl() const
Packit Service 672cf4
    {
Packit Service 672cf4
        return d.get();
Packit Service 672cf4
    }
Packit Service 672cf4
private:
Packit Service 672cf4
    std::shared_ptr<Private> d;
Packit Service 672cf4
};
Packit Service 672cf4
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Data)
Packit Service 672cf4
Packit Service 672cf4
#endif // __GPGMEPP_DATA_H__