diff options
| author | Ingo Klöcker <[email protected]> | 2023-02-09 08:55:38 +0000 | 
|---|---|---|
| committer | Ingo Klöcker <[email protected]> | 2023-02-09 08:56:18 +0000 | 
| commit | 3aaed9cfbfd6821b2e812fbdd24448953d6ca279 (patch) | |
| tree | b50363b184cc1d2b9852b2dbf328904554293e5c /lang/cpp/src | |
| parent | tests: Stop daemons after setting up test environment (diff) | |
| download | gpgme-3aaed9cfbfd6821b2e812fbdd24448953d6ca279.tar.gz gpgme-3aaed9cfbfd6821b2e812fbdd24448953d6ca279.zip | |
cpp: Improve debug output of some enums
* lang/cpp/src/verificationresult.cpp (operator<<): Fix output of
Signature::PKAStatus which doesn't represent flags. Print corresponding
name of enum value if Signature::Summary or Notation::Flags are 0.
--
GnuPG-bug-id: 6368
Diffstat (limited to 'lang/cpp/src')
| -rw-r--r-- | lang/cpp/src/verificationresult.cpp | 51 | 
1 files changed, 32 insertions, 19 deletions
| diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp index bfe82e30..1c657721 100644 --- a/lang/cpp/src/verificationresult.cpp +++ b/lang/cpp/src/verificationresult.cpp @@ -544,32 +544,41 @@ std::ostream &GpgME::operator<<(std::ostream &os, const VerificationResult &resu  std::ostream &GpgME::operator<<(std::ostream &os, Signature::PKAStatus pkaStatus)  { -#define OUTPUT( x ) if ( !(pkaStatus & (GpgME::Signature:: x)) ) {} else do { os << #x " "; } while(0)      os << "GpgME::Signature::PKAStatus("; -    OUTPUT(UnknownPKAStatus); -    OUTPUT(PKAVerificationFailed); -    OUTPUT(PKAVerificationSucceeded); +    switch (pkaStatus) { +#define OUTPUT( x ) case GpgME::Signature:: x: os << #x; break +        OUTPUT(UnknownPKAStatus); +        OUTPUT(PKAVerificationFailed); +        OUTPUT(PKAVerificationSucceeded);  #undef OUTPUT +    default: +        os << "??? (" << static_cast<int>(pkaStatus) << ')'; +        break; +    }      return os << ')';  }  std::ostream &GpgME::operator<<(std::ostream &os, Signature::Summary summary)  { -#define OUTPUT( x ) if ( !(summary & (GpgME::Signature:: x)) ) {} else do { os << #x " "; } while(0)      os << "GpgME::Signature::Summary("; -    OUTPUT(Valid); -    OUTPUT(Green); -    OUTPUT(Red); -    OUTPUT(KeyRevoked); -    OUTPUT(KeyExpired); -    OUTPUT(SigExpired); -    OUTPUT(KeyMissing); -    OUTPUT(CrlMissing); -    OUTPUT(CrlTooOld); -    OUTPUT(BadPolicy); -    OUTPUT(SysError); -    OUTPUT(TofuConflict); +    if (summary == Signature::None) { +        os << "None"; +    } else { +#define OUTPUT( x ) if ( !(summary & (GpgME::Signature:: x)) ) {} else do { os << #x " "; } while(0) +        OUTPUT(Valid); +        OUTPUT(Green); +        OUTPUT(Red); +        OUTPUT(KeyRevoked); +        OUTPUT(KeyExpired); +        OUTPUT(SigExpired); +        OUTPUT(KeyMissing); +        OUTPUT(CrlMissing); +        OUTPUT(CrlTooOld); +        OUTPUT(BadPolicy); +        OUTPUT(SysError); +        OUTPUT(TofuConflict);  #undef OUTPUT +    }      return os << ')';  } @@ -603,10 +612,14 @@ std::ostream &GpgME::operator<<(std::ostream &os, const Signature &sig)  std::ostream &GpgME::operator<<(std::ostream &os, Notation::Flags flags)  {      os << "GpgME::Notation::Flags("; +    if (flags == Notation::NoFlags) { +        os << "NoFlags"; +    } else {  #define OUTPUT( x ) if ( !(flags & (GpgME::Notation:: x)) ) {} else do { os << #x " "; } while(0) -    OUTPUT(HumanReadable); -    OUTPUT(Critical); +        OUTPUT(HumanReadable); +        OUTPUT(Critical);  #undef OUTPUT +    }      return os << ')';  } | 
