LCOV - code coverage report
Current view: top level - lang/cpp/src - error.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 6 100.0 %
Date: 2018-11-15 08:49:49 Functions: 9 10 90.0 %

          Line data    Source code
       1             : /*
       2             :   error.h - wraps a gpgme error
       3             :   Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
       4             :   2016 Bundesamt für Sicherheit in der Informationstechnik
       5             :   Software engineering by Intevation GmbH
       6             : 
       7             :   This file is part of GPGME++.
       8             : 
       9             :   GPGME++ is free software; you can redistribute it and/or
      10             :   modify it under the terms of the GNU Library General Public
      11             :   License as published by the Free Software Foundation; either
      12             :   version 2 of the License, or (at your option) any later version.
      13             : 
      14             :   GPGME++ is distributed in the hope that it will be useful,
      15             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :   GNU Library General Public License for more details.
      18             : 
      19             :   You should have received a copy of the GNU Library General Public License
      20             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      21             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      22             :   Boston, MA 02110-1301, USA.
      23             : */
      24             : 
      25             : // -*- c++ -*-
      26             : #ifndef __GPGMEPP_ERROR_H__
      27             : #define __GPGMEPP_ERROR_H__
      28             : 
      29             : #include "global.h"
      30             : 
      31             : #include <string>
      32             : #include <iosfwd>
      33             : 
      34             : #include <gpg-error.h>
      35             : 
      36             : #ifndef GPGMEPP_ERR_SOURCE_DEFAULT
      37             : # define GPGMEPP_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
      38             : #endif
      39             : 
      40             : namespace GpgME
      41             : {
      42             : 
      43        1548 : class GPGMEPP_EXPORT Error
      44             : {
      45             : public:
      46         308 :     Error() : mErr(0), mMessage() {}
      47         343 :     explicit Error(unsigned int e) : mErr(e), mMessage() {}
      48             : 
      49             :     const char *source() const;
      50             :     const char *asString() const;
      51             : 
      52             :     int code() const;
      53             :     int sourceID() const;
      54             : 
      55             :     bool isCanceled() const;
      56             : 
      57          41 :     unsigned int encodedError() const
      58             :     {
      59          41 :         return mErr;
      60             :     }
      61             :     int toErrno() const;
      62             : 
      63             :     static bool hasSystemError();
      64             :     static Error fromSystemError(unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
      65             :     static void setSystemError(gpg_err_code_t err);
      66             :     static void setErrno(int err);
      67             :     static Error fromErrno(int err, unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
      68             :     static Error fromCode(unsigned int err, unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
      69             : 
      70         338 :     GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(mErr  &&!isCanceled())
      71             : private:
      72             :     unsigned int mErr;
      73             :     mutable std::string mMessage;
      74             : };
      75             : 
      76             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Error &err);
      77             : 
      78             : } // namespace GpgME
      79             : 
      80             : #endif /* __GPGMEPP_ERROR_H__ */

Generated by: LCOV version 1.13