Made 'message::uid' a class to prevent implicit conversions between 'long' and 'string'.
This commit is contained in:
parent
8cd361ff8c
commit
439642caea
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user