LCOV - code coverage report
Current view: top level - lang/qt/src - dataprovider.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 4 100.0 %
Date: 2017-03-02 17:11:10 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* dataprovider.h
       2             :    Copyright (C) 2004 Klarälvdalens Datakonsult AB
       3             :     Copyright (c) 2016 Intevation GmbH
       4             : 
       5             :    This file is part of QGPGME.
       6             : 
       7             :    QGPGME is free software; you can redistribute it and/or modify it
       8             :    under the terms of the GNU Library General Public License as published
       9             :    by the Free Software Foundation; either version 2 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    QGPGME is distributed in the hope that it will be useful, but
      13             :    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 QGPGME; 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             : // -*- c++ -*-
      23             : #ifndef __QGPGME_DATAPROVIDER_H__
      24             : #define __QGPGME_DATAPROVIDER_H__
      25             : 
      26             : #include "qgpgme_export.h"
      27             : #include <interfaces/dataprovider.h>
      28             : #include <memory>
      29             : 
      30             : #include <QtCore/QByteArray>
      31             : 
      32             : 
      33             : class QIODevice;
      34             : 
      35             : namespace QGpgME
      36             : {
      37             : 
      38             : class QGPGME_EXPORT QByteArrayDataProvider : public GpgME::DataProvider
      39             : {
      40             : public:
      41             :     QByteArrayDataProvider();
      42             :     explicit QByteArrayDataProvider(const QByteArray &initialData);
      43             :     ~QByteArrayDataProvider();
      44             : 
      45          20 :     const QByteArray &data() const
      46             :     {
      47          20 :         return mArray;
      48             :     }
      49             : 
      50             : private:
      51             :     // these shall only be accessed through the dataprovider
      52             :     // interface, where they're public:
      53         225 :     bool isSupported(Operation) const
      54             :     {
      55         225 :         return true;
      56             :     }
      57             :     ssize_t read(void *buffer, size_t bufSize);
      58             :     ssize_t write(const void *buffer, size_t bufSize);
      59             :     off_t seek(off_t offset, int whence);
      60             :     void release();
      61             : 
      62             : private:
      63             :     QByteArray mArray;
      64             :     off_t mOff;
      65             : };
      66             : 
      67             : class QGPGME_EXPORT QIODeviceDataProvider : public GpgME::DataProvider
      68             : {
      69             : public:
      70             :     explicit QIODeviceDataProvider(const std::shared_ptr<QIODevice> &initialData);
      71             :     ~QIODeviceDataProvider();
      72             : 
      73             :     const std::shared_ptr<QIODevice> &ioDevice() const
      74             :     {
      75             :         return mIO;
      76             :     }
      77             : 
      78             : private:
      79             :     // these shall only be accessed through the dataprovider
      80             :     // interface, where they're public:
      81             :     bool isSupported(Operation) const;
      82             :     ssize_t read(void *buffer, size_t bufSize);
      83             :     ssize_t write(const void *buffer, size_t bufSize);
      84             :     off_t seek(off_t offset, int whence);
      85             :     void release();
      86             : 
      87             : private:
      88             :     const std::shared_ptr<QIODevice> mIO;
      89             :     bool mErrorOccurred : 1;
      90             :     bool mHaveQProcess  : 1;
      91             : };
      92             : 
      93             : } // namespace QGpgME
      94             : 
      95             : #endif

Generated by: LCOV version 1.13