Added function to return email address as a string.

This commit is contained in:
Vincent Richard 2013-06-09 22:17:56 +02:00
parent abf7dec38b
commit d65d02cf09
2 changed files with 22 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include "vmime/platform.hpp"
#include "vmime/parserHelpers.hpp"
#include "vmime/utility/outputStreamAdapter.hpp"
#include "vmime/utility/outputStreamStringAdapter.hpp"
#include "vmime/utility/stringUtils.hpp"
@ -510,4 +511,18 @@ bool emailAddress::isEmpty() const
}
const string emailAddress::toString() const
{
std::ostringstream oss;
utility::outputStreamAdapter adapter(oss);
generationContext ctx(generationContext::getDefaultContext());
ctx.setMaxLineLength(lineLengthLimits::infinite);
generateImpl(ctx, adapter, 0, NULL);
return oss.str();
}
} // vmime

View File

@ -78,6 +78,13 @@ public:
*/
bool isEmpty() const;
/** Returns the email address as a string, by joining components.
* (ie. the local name, followed by a @ then the domain name.)
*
* @return email address as a string
*/
const string toString() const;
// Comparison
bool operator==(const class emailAddress& eml) const;
bool operator!=(const class emailAddress& eml) const;