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-11-29 15:07:43 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         109 : 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             :         UrlEncoding,
      83             :         UrlEscEncoding,
      84             :         Url0Encoding,
      85             :     };
      86             :     Encoding encoding() const;
      87             :     Error setEncoding(Encoding encoding);
      88             : 
      89             :     enum Type {
      90             :         Invalid,
      91             :         Unknown,
      92             :         PGPSigned,
      93             :         PGPOther,
      94             :         PGPKey,
      95             :         CMSSigned,
      96             :         CMSEncrypted,
      97             :         CMSOther,
      98             :         X509Cert,
      99             :         PKCS12,
     100             :         PGPEncrypted,
     101             :         PGPSignature,
     102             :     };
     103             :     Type type() const;
     104             : 
     105             :     char *fileName() const;
     106             :     Error setFileName(const char *name);
     107             : 
     108             :     ssize_t read(void *buffer, size_t length);
     109             :     ssize_t write(const void *buffer, size_t length);
     110             :     off_t seek(off_t offset, int whence);
     111             : 
     112             :     class Private;
     113          46 :     Private *impl()
     114             :     {
     115          46 :         return d.get();
     116             :     }
     117          21 :     const Private *impl() const
     118             :     {
     119          21 :         return d.get();
     120             :     }
     121             : private:
     122             :     std::shared_ptr<Private> d;
     123             : };
     124             : 
     125             : }
     126             : 
     127             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Data)
     128             : 
     129             : #endif // __GPGMEPP_DATA_H__

Generated by: LCOV version 1.11