summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-05-07 07:33:49 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-05-09 10:27:55 (GMT)
commit6db4b8979b4a7ca72305266a464c571fb648358b (patch)
tree88e9743b97220d2ab20d964c44143e0c76d74c3c /Sluift/ElementConvertors/PresenceConvertor.cpp
parent47ba7eb4a5d3a48f4aa554ff07d20cc7c8682bae (diff)
downloadswift-contrib-6db4b8979b4a7ca72305266a464c571fb648358b.zip
swift-contrib-6db4b8979b4a7ca72305266a464c571fb648358b.tar.bz2
Fix compiler warnings in Sluift convertors.
Change-Id: I26a212dcf17af79696c0446a88fb2272e890f007
Diffstat (limited to 'Sluift/ElementConvertors/PresenceConvertor.cpp')
-rw-r--r--Sluift/ElementConvertors/PresenceConvertor.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Sluift/ElementConvertors/PresenceConvertor.cpp b/Sluift/ElementConvertors/PresenceConvertor.cpp
index ea6bbb8..3725dd2 100644
--- a/Sluift/ElementConvertors/PresenceConvertor.cpp
+++ b/Sluift/ElementConvertors/PresenceConvertor.cpp
@@ -29,66 +29,68 @@ boost::shared_ptr<Presence> PresenceConvertor::doConvertFromLua(lua_State* L) {
}
lua_pop(L, 1);
return result;
}
void PresenceConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Presence> stanza) {
pushStanza(L, stanza, convertors);
const std::string type = convertPresenceTypeToString(stanza->getType());
lua_pushstring(L, type.c_str());
lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> PresenceConvertor::getDocumentation() const {
return Documentation(
"Presence",
"This table has the following fields:\n\n"
"- `type`: string\n"
"- `id`: string\n"
"- `from`: string\n"
"- `to`: string\n"
"- `payloads`: array<@{Payload}>\n"
);
}
std::string PresenceConvertor::convertPresenceTypeToString(Presence::Type type) {
switch (type) {
case Presence::Available: return "available";
case Presence::Error: return "error";
case Presence::Probe: return "probe";
case Presence::Subscribe: return "subscribe";
case Presence::Subscribed: return "subscribed";
case Presence::Unavailable: return "unavailable";
case Presence::Unsubscribe: return "unsubscribe";
case Presence::Unsubscribed: return "unsubscribed";
}
+ assert(false);
+ return "";
}
Presence::Type PresenceConvertor::convertPresenceTypeFromString(const std::string& type) {
if (type == "available") {
return Presence::Available;
}
else if (type == "error") {
return Presence::Error;
}
else if (type == "probe") {
return Presence::Probe;
}
else if (type == "subscribe") {
return Presence::Subscribe;
}
else if (type == "subscribed") {
return Presence::Subscribed;
}
else if (type == "unavailable") {
return Presence::Unavailable;
}
else if (type == "unsubscribe") {
return Presence::Unsubscribe;
}
else if (type == "unsubscribed") {
return Presence::Unsubscribed;
}
else {
throw Lua::Exception("Illegal presence type: '" + type + "'");
}
}