diff options
Diffstat (limited to 'lang')
| -rw-r--r-- | lang/cpp/src/key.cpp | 16 | ||||
| -rw-r--r-- | lang/cpp/src/key.h | 15 | 
2 files changed, 31 insertions, 0 deletions
| diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index 4531a2bf..947405fb 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -878,6 +878,22 @@ const char *UserID::Signature::policyURL() const      return 0;  } +std::string UserID::addrSpecFromString(const char *userid) +{ +    if (!userid) { +        return std::string(); +    } +    char *normalized = gpgme_addrspec_from_uid (userid); +    std::string ret(normalized); +    gpgme_free(normalized); +    return ret; +} + +std::string UserID::addrSpec() const +{ +    return addrSpecFromString(email()); +} +  std::ostream &operator<<(std::ostream &os, const UserID &uid)  {      os << "GpgME::UserID("; diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index f193093c..3f596a82 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -320,6 +320,21 @@ public:       * @returns The TOFU stats or a null TofuInfo.       */      GpgME::TofuInfo tofuInfo() const; + +    /*! Wrapper around gpgme_addrspec_from_uid. +     * +     * The input string should match the format of +     * a user id string. +     * +     * @returns a normalized mail address if found +     * or an empty string. */ +    static std::string addrSpecFromString(const char *uid); + +    /*! Wrapper around gpgme_addrspec_from_uid. +     * +     * @returns a normalized mail address for this userid +     * or an empty string. */ +    std::string addrSpec() const;  private:      shared_gpgme_key_t key;      gpgme_user_id_t uid; | 
