icinga2/jsonrpc/message.cpp

74 lines
1.5 KiB
C++

#include "i2-jsonrpc.h"
using namespace icinga;
Message::Message(void)
{
m_Dictionary = make_shared<Dictionary>();
}
Message::Message(const Dictionary::Ptr& dictionary)
{
m_Dictionary = dictionary;
}
Message::Message(const Message& message)
{
m_Dictionary = message.GetDictionary();
}
Dictionary::Ptr Message::GetDictionary(void) const
{
return m_Dictionary;
}
bool Message::GetPropertyString(string key, string *value) const
{
return GetDictionary()->GetPropertyString(key, value);
}
bool Message::GetPropertyInteger(string key, long *value) const
{
return GetDictionary()->GetPropertyInteger(key, value);
}
bool Message::GetPropertyMessage(string key, Message *value) const
{
Dictionary::Ptr dictionary;
if (!GetDictionary()->GetPropertyDictionary(key, &dictionary))
return false;
*value = Message(dictionary);
return true;
}
void Message::SetPropertyString(string key, const string& value)
{
GetDictionary()->SetProperty(key, value);
}
void Message::SetPropertyInteger(string key, long value)
{
GetDictionary()->SetProperty(key, value);
}
void Message::SetPropertyMessage(string key, const Message& value)
{
GetDictionary()->SetProperty(key, Variant(value.GetDictionary()));
}
void Message::AddUnnamedPropertyString(const string& value)
{
GetDictionary()->AddUnnamedPropertyString(value);
}
void Message::AddUnnamedPropertyInteger(long value)
{
GetDictionary()->AddUnnamedPropertyInteger(value);
}
void Message::AddUnnamedPropertyMessage(const Message& value)
{
GetDictionary()->AddUnnamedPropertyDictionary(value.GetDictionary());
}