Msg: C++11
This commit is contained in:
32
src/Msg.cpp
32
src/Msg.cpp
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user