Add a None type for the Iid class (when the iid is completely empty)

This commit is contained in:
louiz’
2016-12-11 16:34:38 +01:00
parent 36252ad217
commit f653906f9d
3 changed files with 11 additions and 1 deletions
+4 -1
View File
@@ -34,9 +34,10 @@ Iid::Iid(const std::string& iid, const Bridge *bridge)
void Iid::set_type(const std::set<char>& chantypes)
{
if (this->local.empty() && this->server.empty())
this->type = Iid::Type::None;
if (this->local.empty())
return;
if (chantypes.count(this->local[0]) == 1)
this->type = Iid::Type::Channel;
else
@@ -105,6 +106,8 @@ namespace std {
{
if (iid.type == Iid::Type::Server)
return iid.get_server();
else if (iid.get_local().empty() && iid.get_server().empty())
return {};
else
return iid.get_encoded_local() + iid.separator + iid.get_server();
}
+1
View File
@@ -53,6 +53,7 @@ public:
Channel,
User,
Server,
None,
};
static constexpr char separator[]{"%"};
Iid(const std::string& iid, const std::set<char>& chantypes);