diff options
| author | Vincent Richard <[email protected]> | 2013-08-16 08:49:13 +0000 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2013-08-16 08:49:13 +0000 |
| commit | 439642caea38ad45683e33573284154c5d9368e7 (patch) | |
| tree | 9fc630acd2b0fb6c7b542175bde399b44cdddad0 /src/net/message.cpp | |
| parent | Added support for enhanced status codes (RFC-3463). (diff) | |
| download | vmime-439642caea38ad45683e33573284154c5d9368e7.tar.gz vmime-439642caea38ad45683e33573284154c5d9368e7.zip | |
Made 'message::uid' a class to prevent implicit conversions between 'long' and 'string'.
Diffstat (limited to 'src/net/message.cpp')
| -rw-r--r-- | src/net/message.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
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 <sstream> + 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 <string>(uid); + return os; +} + + } // net } // vmime |
