diff options
author | Andre Heinecke <[email protected]> | 2018-02-09 15:03:37 +0000 |
---|---|---|
committer | Andre Heinecke <[email protected]> | 2018-02-09 15:11:03 +0000 |
commit | 5a5b0d4996c17bfbc69b90f89fec23732f92813a (patch) | |
tree | eabf012fd46261ae63b217b4bf11625db19b5fa3 /lang/cpp/src/data.cpp | |
parent | Fix for BSD Make. (diff) | |
download | gpgme-5a5b0d4996c17bfbc69b90f89fec23732f92813a.tar.gz gpgme-5a5b0d4996c17bfbc69b90f89fec23732f92813a.zip |
cpp: Add conveniance Data::toString
* lang/cpp/src/data.h, lang/cpp/src/data.cpp: Add Data::toString.
--
I'm lazy and like to waste memory.
Diffstat (limited to 'lang/cpp/src/data.cpp')
-rw-r--r-- | lang/cpp/src/data.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp index 32ca561b..52b8da24 100644 --- a/lang/cpp/src/data.cpp +++ b/lang/cpp/src/data.cpp @@ -254,3 +254,17 @@ std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const delete ctx; return ret; } + +std::string GpgME::Data::toString() +{ + std::string ret; + char buf[4096]; + size_t nread; + seek (0, SEEK_SET); + while ((nread = read (buf, 4096)) > 0) + { + ret += std::string (buf, nread); + } + seek (0, SEEK_SET); + return ret; +} |