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: 2018-11-15 08:49:49 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* dataprovider.h
       2             :    Copyright (C) 2004 Klarälvdalens Datakonsult AB
       3             :     Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
       4             :     Software engineering by Intevation GmbH
       5             : 
       6             :    This file is part of QGPGME.
       7             : 
       8             :    QGPGME is free software; you can redistribute it and/or modify it
       9             :    under the terms of the GNU Library General Public License as published
      10             :    by the Free Software Foundation; either version 2 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    QGPGME is distributed in the hope that it will be useful, but
      14             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU Library General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU Library General Public License
      19             :    along with QGPGME; see the file COPYING.LIB.  If not, write to the
      20             :    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      21             :    Boston, MA 02110-1301, USA. */
      22             : 
      23             : // -*- c++ -*-
      24             : #ifndef __QGPGME_DATAPROVIDER_H__
      25             : #define __QGPGME_DATAPROVIDER_H__
      26             : 
      27             : #include "qgpgme_export.h"
      28             : #include <interfaces/dataprovider.h>
      29             : #include <memory>
      30             : 
      31             : #include <QtCore/QByteArray>
      32             : 
      33             : 
      34             : class QIODevice;
      35             : 
      36             : namespace QGpgME
      37             : {
      38             : 
      39             : class QGPGME_EXPORT QByteArrayDataProvider : public GpgME::DataProvider
      40             : {
      41             : public:
      42             :     QByteArrayDataProvider();
      43             :     explicit QByteArrayDataProvider(const QByteArray &initialData);
      44             :     ~QByteArrayDataProvider();
      45             : 
      46          53 :     const QByteArray &data() const
      47             :     {
      48          53 :         return mArray;
      49             :     }
      50             : 
      51             : private:
      52             :     // these shall only be accessed through the dataprovider
      53             :     // interface, where they're public:
      54         305 :     bool isSupported(Operation) const
      55             :     {
      56         305 :         return true;
      57             :     }
      58             :     ssize_t read(void *buffer, size_t bufSize);
      59             :     ssize_t write(const void *buffer, size_t bufSize);
      60             :     off_t seek(off_t offset, int whence);
      61             :     void release();
      62             : 
      63             : private:
      64             :     QByteArray mArray;
      65             :     off_t mOff;
      66             : };
      67             : 
      68             : class QGPGME_EXPORT QIODeviceDataProvider : public GpgME::DataProvider
      69             : {
      70             : public:
      71             :     explicit QIODeviceDataProvider(const std::shared_ptr<QIODevice> &initialData);
      72             :     ~QIODeviceDataProvider();
      73             : 
      74             :     const std::shared_ptr<QIODevice> &ioDevice() const
      75             :     {
      76             :         return mIO;
      77             :     }
      78             : 
      79             : private:
      80             :     // these shall only be accessed through the dataprovider
      81             :     // interface, where they're public:
      82             :     bool isSupported(Operation) const;
      83             :     ssize_t read(void *buffer, size_t bufSize);
      84             :     ssize_t write(const void *buffer, size_t bufSize);
      85             :     off_t seek(off_t offset, int whence);
      86             :     void release();
      87             : 
      88             : private:
      89             :     const std::shared_ptr<QIODevice> mIO;
      90             :     bool mErrorOccurred : 1;
      91             :     bool mHaveQProcess  : 1;
      92             : };
      93             : 
      94             : } // namespace QGpgME
      95             : 
      96             : #endif

Generated by: LCOV version 1.13