Msg: C++11

This commit is contained in:
Paul Beckingham
2016-02-03 19:47:34 -05:00
parent 1579705fec
commit 9720e7dab4
3 changed files with 34 additions and 45 deletions

View File

@@ -29,32 +29,12 @@
#include <Lexer.h>
#include <text.h>
////////////////////////////////////////////////////////////////////////////////
Msg::Msg ()
: _payload ("")
{
// All messages are marked with the version number, so that the messages may
// be properly evaluated in context.
_header["client"] = PACKAGE_STRING;
}
////////////////////////////////////////////////////////////////////////////////
Msg::~Msg ()
{
}
////////////////////////////////////////////////////////////////////////////////
void Msg::set (const std::string& name, const std::string& value)
{
_header[name] = value;
}
////////////////////////////////////////////////////////////////////////////////
void Msg::setPayload (const std::string& payload)
{
_payload = payload;
}
////////////////////////////////////////////////////////////////////////////////
std::string Msg::get (const std::string& name) const
{
@@ -65,6 +45,12 @@ std::string Msg::get (const std::string& name) const
return "";
}
////////////////////////////////////////////////////////////////////////////////
void Msg::setPayload (const std::string& payload)
{
_payload = payload;
}
////////////////////////////////////////////////////////////////////////////////
std::string Msg::getPayload () const
{
@@ -72,17 +58,19 @@ std::string Msg::getPayload () const
}
////////////////////////////////////////////////////////////////////////////////
void Msg::all (std::vector <std::string>& names) const
std::vector <std::string> Msg::all () const
{
std::vector <std::string> names;
for (auto& i : _header)
names.push_back (i.first);
return names;
}
////////////////////////////////////////////////////////////////////////////////
std::string Msg::serialize () const
{
std::string output;
for (auto& i : _header)
output += i.first + ": " + i.second + "\n";