LCOV - code coverage report
Current view: top level - lang/cpp/src - data.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 12 50.0 %
Date: 2016-09-12 13:07:23 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /*
       2             :   data.h - wraps a gpgme data object
       3             :   Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
       4             : 
       5             :   This file is part of GPGME++.
       6             : 
       7             :   GPGME++ is free software; you can redistribute it and/or
       8             :   modify it under the terms of the GNU Library General Public
       9             :   License as published by the Free Software Foundation; either
      10             :   version 2 of the License, or (at your option) any later version.
      11             : 
      12             :   GPGME++ is distributed in the hope that it will be useful,
      13             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :   GNU Library General Public License for more details.
      16             : 
      17             :   You should have received a copy of the GNU Library General Public License
      18             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      19             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      20             :   Boston, MA 02110-1301, USA.
      21             : */
      22             : 
      23             : #ifndef __GPGMEPP_DATA_H__
      24             : #define __GPGMEPP_DATA_H__
      25             : 
      26             : #include "global.h"
      27             : 
      28             : #include <sys/types.h> // for size_t, off_t
      29             : #include <cstdio> // FILE
      30             : #include <algorithm>
      31             : #include <memory>
      32             : 
      33             : namespace GpgME
      34             : {
      35             : 
      36             : class DataProvider;
      37             : class Error;
      38             : 
      39         103 : class GPGMEPP_EXPORT Data
      40             : {
      41             :     struct Null {
      42           6 :                 Null() {}
      43             :         };
      44             : public:
      45             :     /* implicit */ Data(const Null &);
      46             :     Data();
      47             :     explicit Data(gpgme_data_t data);
      48             : 
      49             :     // Memory-Based Data Buffers:
      50             :     Data(const char *buffer, size_t size, bool copy = true);
      51             :     explicit Data(const char *filename);
      52             :     Data(const char *filename, off_t offset, size_t length);
      53             :     Data(std::FILE *fp, off_t offset, size_t length);
      54             :     // File-Based Data Buffers:
      55             :     explicit Data(std::FILE *fp);
      56             :     explicit Data(int fd);
      57             :     // Callback-Based Data Buffers:
      58             :     explicit Data(DataProvider *provider);
      59             : 
      60             :     static const Null null;
      61             : 
      62           0 :     const Data &operator=(Data other)
      63             :     {
      64           0 :         swap(other);
      65           0 :         return *this;
      66             :     }
      67             : 
      68           0 :     void swap(Data &other)
      69             :     {
      70             :         using std::swap;
      71           0 :         swap(this->d, other.d);
      72           0 :     }
      73             : 
      74             :     bool isNull() const;
      75             : 
      76             :     enum Encoding {
      77             :         AutoEncoding,
      78             :         BinaryEncoding,
      79             :         Base64Encoding,
      80             :         ArmorEncoding,
      81             :         MimeEncoding
      82             :     };
      83             :     Encoding encoding() const;
      84             :     Error setEncoding(Encoding encoding);
      85             : 
      86             :     enum Type {
      87             :         Invalid,
      88             :         Unknown,
      89             :         PGPSigned,
      90             :         PGPOther,
      91             :         PGPKey,
      92             :         CMSSigned,
      93             :         CMSEncrypted,
      94             :         CMSOther,
      95             :         X509Cert,
      96             :         PKCS12,
      97             :         PGPEncrypted,
      98             :         PGPSignature,
      99             :     };
     100             :     Type type() const;
     101             : 
     102             :     char *fileName() const;
     103             :     Error setFileName(const char *name);
     104             : 
     105             :     ssize_t read(void *buffer, size_t length);
     106             :     ssize_t write(const void *buffer, size_t length);
     107             :     off_t seek(off_t offset, int whence);
     108             : 
     109             :     class Private;
     110          44 :     Private *impl()
     111             :     {
     112          44 :         return d.get();
     113             :     }
     114          20 :     const Private *impl() const
     115             :     {
     116          20 :         return d.get();
     117             :     }
     118             : private:
     119             :     std::shared_ptr<Private> d;
     120             : };
     121             : 
     122             : }
     123             : 
     124             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Data)
     125             : 
     126             : #endif // __GPGMEPP_DATA_H__

Generated by: LCOV version 1.11