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.
This commit is contained in:
parent
59fcabbdf5
commit
5a5b0d4996
@ -254,3 +254,17 @@ std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
|
|||||||
delete ctx;
|
delete ctx;
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
@ -114,6 +114,9 @@ public:
|
|||||||
* Protocol proto. Returns an empty list on error.*/
|
* Protocol proto. Returns an empty list on error.*/
|
||||||
std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
|
std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
|
||||||
|
|
||||||
|
/** Return a copy of the data as std::string. Sets seek pos to 0 */
|
||||||
|
std::string toString();
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
Private *impl()
|
Private *impl()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user