diff --git a/src/net/message.cpp b/src/net/message.cpp index 1024bcba..09fe6321 100644 --- a/src/net/message.cpp +++ b/src/net/message.cpp @@ -29,6 +29,8 @@ #include "vmime/net/message.hpp" +#include + namespace vmime { namespace net { @@ -52,6 +54,94 @@ size_t messagePart::getPartCount() const } + +// message::uid + + +message::uid::uid() +{ +} + + +message::uid::uid(const string& uid) + : m_str(uid) +{ +} + + +message::uid::uid(const unsigned long uid) +{ + std::ostringstream oss; + oss.imbue(std::locale::classic()); + oss << uid; + + m_str = oss.str(); +} + + +message::uid::uid(const char* uid) + : m_str(uid) +{ +} + + +message::uid::uid(const uid& other) +{ + m_str = other.m_str; +} + + +message::uid& message::uid::operator=(const uid& other) +{ + m_str = other.m_str; + return *this; +} + + +message::uid& message::uid::operator=(const string& uid) +{ + m_str = uid; + return *this; +} + + +message::uid& message::uid::operator=(const unsigned long uid) +{ + std::ostringstream oss; + oss.imbue(std::locale::classic()); + oss << uid; + + m_str = oss.str(); + + return *this; +} + + +message::uid::operator string() const +{ + return m_str; +} + + +bool message::uid::empty() const +{ + return m_str.empty(); +} + + +bool message::uid::operator==(const uid& other) const +{ + return m_str == other.m_str; +} + + +std::ostream& operator<<(std::ostream& os, const message::uid& uid) +{ + os << static_cast (uid); + return os; +} + + } // net } // vmime diff --git a/vmime/net/message.hpp b/vmime/net/message.hpp index 76bfb16b..de5e884a 100644 --- a/vmime/net/message.hpp +++ b/vmime/net/message.hpp @@ -177,7 +177,30 @@ public: /** The type for an unique message identifier. */ - typedef string uid; + class uid + { + public: + + uid(); + uid(const string& uid); + uid(const unsigned long uid); + uid(const char* uid); + uid(const uid& other); + + uid& operator=(const uid& other); + uid& operator=(const string& uid); + uid& operator=(const unsigned long uid); + + operator string() const; + + bool empty() const; + + bool operator==(const uid& other) const; + + private: + + string m_str; + }; /** Return the MIME structure of the message (must fetch before). * @@ -315,6 +338,9 @@ public: }; +VMIME_EXPORT std::ostream& operator<<(std::ostream& os, const message::uid& uid); + + } // net } // vmime