From 5a5b0d4996c17bfbc69b90f89fec23732f92813a Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Fri, 9 Feb 2018 16:03:37 +0100 Subject: 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. --- lang/cpp/src/data.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lang/cpp/src/data.cpp') 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::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; +} -- cgit v1.2.3