Renamed Dictionary::{Set,Get}Property -> Dictionary::{Set,Get}

This commit is contained in:
Gunnar Beutner 2012-07-09 16:19:56 +02:00
parent 8d27f66b83
commit 777f39c1ef
23 changed files with 139 additions and 139 deletions

View File

@ -52,62 +52,62 @@ Dictionary::Ptr ConfigObject::GetTags(void) const
string ConfigObject::GetType(void) const
{
string type;
GetProperties()->GetProperty("__type", &type);
GetProperties()->Get("__type", &type);
return type;
}
string ConfigObject::GetName(void) const
{
string name;
GetProperties()->GetProperty("__name", &name);
GetProperties()->Get("__name", &name);
return name;
}
void ConfigObject::SetLocal(bool value)
{
GetProperties()->SetProperty("__local", value ? 1 : 0);
GetProperties()->Set("__local", value ? 1 : 0);
}
bool ConfigObject::IsLocal(void) const
{
bool value = false;
GetProperties()->GetProperty("__local", &value);
GetProperties()->Get("__local", &value);
return value;
}
void ConfigObject::SetAbstract(bool value)
{
GetProperties()->SetProperty("__abstract", value ? 1 : 0);
GetProperties()->Set("__abstract", value ? 1 : 0);
}
bool ConfigObject::IsAbstract(void) const
{
bool value = false;
GetProperties()->GetProperty("__abstract", &value);
GetProperties()->Get("__abstract", &value);
return value;
}
void ConfigObject::SetSource(const string& value)
{
GetProperties()->SetProperty("__source", value);
GetProperties()->Set("__source", value);
}
string ConfigObject::GetSource(void) const
{
string value;
GetProperties()->GetProperty("__source", &value);
GetProperties()->Get("__source", &value);
return value;
}
void ConfigObject::SetCommitTimestamp(time_t ts)
{
GetProperties()->SetProperty("__tx", static_cast<long>(ts));
GetProperties()->Set("__tx", static_cast<long>(ts));
}
time_t ConfigObject::GetCommitTimestamp(void) const
{
long value = false;
GetProperties()->GetProperty("__tx", &value);
GetProperties()->Get("__tx", &value);
return value;
}

View File

@ -47,13 +47,13 @@ public:
template<typename T>
void SetProperty(const string& key, const T& value)
{
GetProperties()->SetProperty(key, value);
GetProperties()->Set(key, value);
}
template<typename T>
bool GetProperty(const string& key, T *value) const
{
return GetProperties()->GetProperty(key, value);
return GetProperties()->Get(key, value);
}
Dictionary::Ptr GetTags(void) const;
@ -61,13 +61,13 @@ public:
template<typename T>
void SetTag(const string& key, const T& value)
{
GetTags()->SetProperty(key, value);
GetTags()->Set(key, value);
}
template<typename T>
bool GetTag(const string& key, T *value) const
{
return GetTags()->GetProperty(key, value);
return GetTags()->Get(key, value);
}
string GetType(void) const;

View File

@ -67,7 +67,7 @@ bool Dictionary::Contains(const string& key) const
*
* @param key The key.
*/
void Dictionary::RemoveProperty(const string& key)
void Dictionary::Remove(const string& key)
{
Dictionary::Iterator it;
it = m_Data.find(key);

View File

@ -45,7 +45,7 @@ public:
* @returns true if the value was retrieved, false otherwise.
*/
template<typename T>
bool GetProperty(const string& key, T *value) const
bool Get(const string& key, T *value) const
{
ConstIterator i = m_Data.find(key);
@ -64,11 +64,11 @@ public:
* @param[out] value Pointer to the value.
* @returns true if the value was retrieved, false otherwise.
*/
bool GetProperty(const string& key, Dictionary::Ptr *value)
bool Get(const string& key, Dictionary::Ptr *value)
{
Object::Ptr object;
if (!GetProperty(key, &object))
if (!Get(key, &object))
return false;
*value = dynamic_pointer_cast<Dictionary>(object);
@ -85,7 +85,7 @@ public:
* @param value The value.
*/
template<typename T>
void SetProperty(const string& key, const T& value)
void Set(const string& key, const T& value)
{
pair<typename map<string, Variant>::iterator, bool> ret;
ret = m_Data.insert(make_pair(key, value));
@ -99,7 +99,7 @@ public:
* @param value The value.
*/
template<typename T>
void AddUnnamedProperty(const T& value)
void Add(const T& value)
{
Iterator it;
string key;
@ -113,7 +113,7 @@ public:
it = m_Data.find(key);
} while (it != m_Data.end());
SetProperty(key, value);
Set(key, value);
}
bool Contains(const string& key) const;
@ -123,7 +123,7 @@ public:
long GetLength(void) const;
void RemoveProperty(const string& key);
void Remove(const string& key);
private:
map<string, Variant> m_Data;

View File

@ -12,96 +12,96 @@ CheckResult::CheckResult(const MessagePart& message)
void CheckResult::SetScheduleStart(time_t ts)
{
SetProperty("schedule_start", static_cast<long>(ts));
Set("schedule_start", static_cast<long>(ts));
}
time_t CheckResult::GetScheduleStart(void) const
{
long value = 0;
GetProperty("schedule_start", &value);
Get("schedule_start", &value);
return static_cast<time_t>(value);
}
void CheckResult::SetScheduleEnd(time_t ts)
{
SetProperty("schedule_end", static_cast<long>(ts));
Set("schedule_end", static_cast<long>(ts));
}
time_t CheckResult::GetScheduleEnd(void) const
{
long value = 0;
GetProperty("schedule_end", &value);
Get("schedule_end", &value);
return static_cast<time_t>(value);
}
void CheckResult::SetExecutionStart(time_t ts)
{
SetProperty("execution_start", static_cast<long>(ts));
Set("execution_start", static_cast<long>(ts));
}
time_t CheckResult::GetExecutionStart(void) const
{
long value = 0;
GetProperty("execution_start", &value);
Get("execution_start", &value);
return static_cast<time_t>(value);
}
void CheckResult::SetExecutionEnd(time_t ts)
{
SetProperty("execution_end", static_cast<long>(ts));
Set("execution_end", static_cast<long>(ts));
}
time_t CheckResult::GetExecutionEnd(void) const
{
long value = 0;
GetProperty("execution_end", &value);
Get("execution_end", &value);
return value;
}
void CheckResult::SetState(ServiceState state)
{
SetProperty("state", static_cast<long>(state));
Set("state", static_cast<long>(state));
}
ServiceState CheckResult::GetState(void) const
{
long value = StateUnknown;
GetProperty("state", &value);
Get("state", &value);
return static_cast<ServiceState>(value);
}
void CheckResult::SetOutput(string output)
{
SetProperty("output", output);
Set("output", output);
}
string CheckResult::GetOutput(void) const
{
string value;
GetProperty("output", &value);
Get("output", &value);
return value;
}
void CheckResult::SetPerformanceDataRaw(const string& pd)
{
SetProperty("performance_data_raw", pd);
Set("performance_data_raw", pd);
}
string CheckResult::GetPerformanceDataRaw(void) const
{
string value;
GetProperty("performance_data_raw", &value);
Get("performance_data_raw", &value);
return value;
}
void CheckResult::SetPerformanceData(const Dictionary::Ptr& pd)
{
SetProperty("performance_data", pd);
Set("performance_data", pd);
}
Dictionary::Ptr CheckResult::GetPerformanceData(void) const
{
Dictionary::Ptr value;
GetProperty("performance_data", &value);
Get("performance_data", &value);
return value;
}

View File

@ -17,7 +17,7 @@ string MacroProcessor::ResolveMacros(const string& str, const Dictionary::Ptr& m
string name = result.substr(pos_first + 1, pos_second - pos_first - 1);
string value;
if (!macros || !macros->GetProperty(name, &value))
if (!macros || !macros->Get(name, &value))
throw runtime_error("Macro '" + name + "' is not defined.");
result.replace(pos_first, pos_second - pos_first + 1, value);

View File

@ -106,7 +106,7 @@ void Service::GetDependenciesRecursive(const Dictionary::Ptr& result) const {
if (result->Contains(it->second))
continue;
result->SetProperty(it->second, it->second);
result->Set(it->second, it->second);
Service service = Service::GetByName(it->second);
service.GetDependenciesRecursive(result);
@ -383,7 +383,7 @@ Dictionary::Ptr Service::ResolveDependencies(Host host, const Dictionary::Ptr& d
else
name = it->first;
result->SetProperty(name, name);
result->Set(name, name);
}
return result;

View File

@ -4,18 +4,18 @@ using namespace icinga;
bool ServiceStatusMessage::GetService(string *service) const
{
return GetProperty("service", service);
return Get("service", service);
}
void ServiceStatusMessage::SetService(const string& service)
{
SetProperty("service", service);
Set("service", service);
}
bool ServiceStatusMessage::GetState(ServiceState *state) const
{
long value;
if (GetProperty("state", &value)) {
if (Get("state", &value)) {
*state = static_cast<ServiceState>(value);
return true;
}
@ -24,13 +24,13 @@ bool ServiceStatusMessage::GetState(ServiceState *state) const
void ServiceStatusMessage::SetState(ServiceState state)
{
SetProperty("state", static_cast<long>(state));
Set("state", static_cast<long>(state));
}
bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
{
long value;
if (GetProperty("state_type", &value)) {
if (Get("state_type", &value)) {
*type = static_cast<ServiceStateType>(value);
return true;
}
@ -39,23 +39,23 @@ bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
void ServiceStatusMessage::SetStateType(ServiceStateType type)
{
SetProperty("state_type", static_cast<long>(type));
Set("state_type", static_cast<long>(type));
}
bool ServiceStatusMessage::GetCurrentCheckAttempt(long *attempt) const
{
return GetProperty("current_attempt", attempt);
return Get("current_attempt", attempt);
}
void ServiceStatusMessage::SetCurrentCheckAttempt(long attempt)
{
SetProperty("current_attempt", attempt);
Set("current_attempt", attempt);
}
bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
{
long value;
if (GetProperty("next_check", &value)) {
if (Get("next_check", &value)) {
*ts = value;
return true;
}
@ -64,13 +64,13 @@ bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
void ServiceStatusMessage::SetNextCheck(time_t ts)
{
SetProperty("next_check", static_cast<long>(ts));
Set("next_check", static_cast<long>(ts));
}
bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
{
Dictionary::Ptr obj;
if (GetProperty("result", &obj)) {
if (Get("result", &obj)) {
*cr = CheckResult(MessagePart(obj));
return true;
}
@ -79,5 +79,5 @@ bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
void ServiceStatusMessage::SetCheckResult(CheckResult cr)
{
SetProperty("result", cr.GetDictionary());
Set("result", cr.GetDictionary());
}

View File

@ -184,7 +184,7 @@ void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender,
return;
MessagePart serviceMsg;
if (!params.GetProperty("service", &serviceMsg))
if (!params.Get("service", &serviceMsg))
return;
ConfigObject::Ptr object = boost::make_shared<ConfigObject>(serviceMsg.GetDictionary());

View File

@ -153,11 +153,11 @@ RequestMessage CIBSyncComponent::MakeObjectMessage(const ConfigObject::Ptr& obje
MessagePart params;
msg.SetParams(params);
params.SetProperty("name", object->GetName());
params.SetProperty("type", object->GetType());
params.Set("name", object->GetName());
params.Set("type", object->GetType());
if (includeProperties)
params.SetProperty("properties", object->GetProperties());
params.Set("properties", object->GetProperties());
return msg;
}
@ -216,15 +216,15 @@ void CIBSyncComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender,
return;
string name;
if (!params.GetProperty("name", &name))
if (!params.Get("name", &name))
return;
string type;
if (!params.GetProperty("type", &type))
if (!params.Get("type", &type))
return;
MessagePart properties;
if (!params.GetProperty("properties", &properties))
if (!params.Get("properties", &properties))
return;
ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
@ -276,11 +276,11 @@ void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
return;
string name;
if (!params.GetProperty("name", &name))
if (!params.Get("name", &name))
return;
string type;
if (!params.GetProperty("type", &type))
if (!params.Get("type", &type))
return;
ConfigObject::Ptr object = ConfigObject::GetObject(type, name);

View File

@ -57,32 +57,32 @@ void ConvenienceComponent::HostAddedHandler(const ConfigItem::Ptr& item)
void ConvenienceComponent::CopyServiceAttributes(const ConfigObject::Ptr& host, const Dictionary::Ptr& service, const ConfigItemBuilder::Ptr& builder)
{
Dictionary::Ptr macros;
if (service->GetProperty("macros", &macros))
if (service->Get("macros", &macros))
builder->AddExpression("macros", OperatorPlus, macros);
long checkInterval;
if (service->GetProperty("check_interval", &checkInterval))
if (service->Get("check_interval", &checkInterval))
builder->AddExpression("check_interval", OperatorSet, checkInterval);
long retryInterval;
if (service->GetProperty("retry_interval", &retryInterval))
if (service->Get("retry_interval", &retryInterval))
builder->AddExpression("retry_interval", OperatorSet, retryInterval);
Dictionary::Ptr sgroups;
if (service->GetProperty("servicegroups", &sgroups))
if (service->Get("servicegroups", &sgroups))
builder->AddExpression("servicegroups", OperatorPlus, sgroups);
Dictionary::Ptr checkers;
if (service->GetProperty("checkers", &checkers))
if (service->Get("checkers", &checkers))
builder->AddExpression("checkers", OperatorSet, checkers);
Dictionary::Ptr dependencies;
if (service->GetProperty("dependencies", &dependencies))
if (service->Get("dependencies", &dependencies))
builder->AddExpression("dependencies", OperatorPlus,
Service::ResolveDependencies(host, dependencies));
Dictionary::Ptr hostchecks;
if (service->GetProperty("hostchecks", &hostchecks))
if (service->Get("hostchecks", &hostchecks))
builder->AddExpression("dependencies", OperatorPlus,
Service::ResolveDependencies(host, hostchecks));
}
@ -134,7 +134,7 @@ void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
throw invalid_argument("Service description invalid.");
string parent;
if (!service->GetProperty("service", &parent))
if (!service->Get("service", &parent))
parent = svcname;
builder->AddParent(parent);
@ -147,7 +147,7 @@ void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item)
ConfigItem::Ptr serviceItem = builder->Compile();
serviceItem->Commit();
newServices->SetProperty(name, serviceItem);
newServices->Set(name, serviceItem);
}
}

View File

@ -96,7 +96,7 @@ void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Serv
request.SetMethod("checker::AssignService");
MessagePart params;
params.SetProperty("service", service.GetConfigObject()->GetProperties());
params.Set("service", service.GetConfigObject()->GetProperties());
request.SetParams(params);
Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");

View File

@ -301,13 +301,13 @@ void DiscoveryComponent::SendDiscoveryMessage(const string& method, const string
set<string>::iterator i;
MessagePart subscriptions;
for (i = info->Subscriptions.begin(); i != info->Subscriptions.end(); i++)
subscriptions.AddUnnamedProperty(*i);
subscriptions.Add(*i);
params.SetSubscriptions(subscriptions);
MessagePart publications;
for (i = info->Publications.begin(); i != info->Publications.end(); i++)
publications.AddUnnamedProperty(*i);
publications.Add(*i);
params.SetPublications(publications);

View File

@ -12,50 +12,50 @@ DiscoveryMessage::DiscoveryMessage(const MessagePart& message)
bool DiscoveryMessage::GetIdentity(string *value) const
{
return GetProperty("identity", value);
return Get("identity", value);
}
void DiscoveryMessage::SetIdentity(const string& value)
{
SetProperty("identity", value);
Set("identity", value);
}
bool DiscoveryMessage::GetNode(string *value) const
{
return GetProperty("node", value);
return Get("node", value);
}
void DiscoveryMessage::SetNode(const string& value)
{
SetProperty("node", value);
Set("node", value);
}
bool DiscoveryMessage::GetService(string *value) const
{
return GetProperty("service", value);
return Get("service", value);
}
void DiscoveryMessage::SetService(const string& value)
{
SetProperty("service", value);
Set("service", value);
}
bool DiscoveryMessage::GetSubscriptions(MessagePart *value) const
{
return GetProperty("subscriptions", value);
return Get("subscriptions", value);
}
void DiscoveryMessage::SetSubscriptions(MessagePart value)
{
SetProperty("subscriptions", value);
Set("subscriptions", value);
}
bool DiscoveryMessage::GetPublications(MessagePart *value) const
{
return GetProperty("publications", value);
return Get("publications", value);
}
void DiscoveryMessage::SetPublications(MessagePart value)
{
SetProperty("publications", value);
Set("publications", value);
}

View File

@ -1768,7 +1768,7 @@ yyreduce:
/* Line 1806 of yacc.c */
#line 259 "config_parser.yy"
{
m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant));
m_Array->Add(*(yyvsp[(1) - (1)].variant));
delete (yyvsp[(1) - (1)].variant);
}
break;

View File

@ -257,7 +257,7 @@ tuple: '('
tupleitem: simplevalue
{
m_Array->AddUnnamedProperty(*$1);
m_Array->Add(*$1);
delete $1;
}

View File

@ -60,7 +60,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
break;
case OperatorPlus:
dictionary->GetProperty(m_Key, &oldValue);
dictionary->Get(m_Key, &oldValue);
if (oldValue.GetType() == VariantObject)
dict = dynamic_pointer_cast<Dictionary>(oldValue.GetObject());
@ -82,7 +82,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
} else if (valueDict) {
Dictionary::Iterator it;
for (it = valueDict->Begin(); it != valueDict->End(); it++) {
dict->SetProperty(it->first, it->second);
dict->Set(it->first, it->second);
}
} else {
stringstream message;
@ -96,5 +96,5 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
throw runtime_error("Not yet implemented.");
}
dictionary->SetProperty(m_Key, newValue);
dictionary->Set(m_Key, newValue);
}

View File

@ -91,15 +91,15 @@ void JsonRpcEndpoint::NewMessageHandler(const MessagePart& message)
return;
}
RequestMessage request = message;
string method;
if (!message.GetProperty("method", &method))
if (!request.GetMethod(&method))
return;
if (!HasPublication(method))
return;
RequestMessage request = message;
string id;
if (request.GetID(&id))
GetEndpointManager()->SendAnycastMessage(sender, request);

View File

@ -81,13 +81,13 @@ Dictionary::Ptr MessagePart::GetDictionaryFromJson(json_t *json)
for (cJSON *i = json->child; i != NULL; i = i->next) {
switch (i->type) {
case cJSON_Number:
dictionary->SetProperty(i->string, i->valueint);
dictionary->Set(i->string, i->valueint);
break;
case cJSON_String:
dictionary->SetProperty(i->string, i->valuestring);
dictionary->Set(i->string, i->valuestring);
break;
case cJSON_Object:
dictionary->SetProperty(i->string, GetDictionaryFromJson(i));
dictionary->Set(i->string, GetDictionaryFromJson(i));
break;
default:
break;
@ -176,10 +176,10 @@ Dictionary::Ptr MessagePart::GetDictionary(void) const
* @param[out] The value.
* @returns true if the value was retrieved, false otherwise.
*/
bool MessagePart::GetProperty(string key, MessagePart *value) const
bool MessagePart::Get(string key, MessagePart *value) const
{
Object::Ptr object;
if (!GetDictionary()->GetProperty(key, &object))
if (!GetDictionary()->Get(key, &object))
return false;
Dictionary::Ptr dictionary = dynamic_pointer_cast<Dictionary>(object);
@ -196,9 +196,9 @@ bool MessagePart::GetProperty(string key, MessagePart *value) const
* @param key The name of the property.
* @param value The value.
*/
void MessagePart::SetProperty(string key, const MessagePart& value)
void MessagePart::Set(string key, const MessagePart& value)
{
GetDictionary()->SetProperty(key, value.GetDictionary());
GetDictionary()->Set(key, value.GetDictionary());
}
/**
@ -206,9 +206,9 @@ void MessagePart::SetProperty(string key, const MessagePart& value)
*
* @param value The value.
*/
void MessagePart::AddUnnamedProperty(const MessagePart& value)
void MessagePart::Add(const MessagePart& value)
{
GetDictionary()->AddUnnamedProperty(value.GetDictionary());
GetDictionary()->Add(value.GetDictionary());
}
/**

View File

@ -52,9 +52,9 @@ public:
* @returns true if the value was retrieved, false otherwise.
*/
template<typename T>
bool GetProperty(string key, T *value) const
bool Get(string key, T *value) const
{
return GetDictionary()->GetProperty(key, value);
return GetDictionary()->Get(key, value);
}
/**
@ -64,13 +64,13 @@ public:
* @param value The value.
*/
template<typename T>
void SetProperty(string key, const T& value)
void Set(string key, const T& value)
{
GetDictionary()->SetProperty(key, value);
GetDictionary()->Set(key, value);
}
bool GetProperty(string key, MessagePart *value) const;
void SetProperty(string key, const MessagePart& value);
bool Get(string key, MessagePart *value) const;
void Set(string key, const MessagePart& value);
/**
* Adds an item to the message using an automatically generated property name.
@ -78,12 +78,12 @@ public:
* @param value The value.
*/
template<typename T>
void AddUnnamedProperty(const T& value)
void Add(const T& value)
{
GetDictionary()->AddUnnamedProperty(value);
GetDictionary()->Add(value);
}
void AddUnnamedProperty(const MessagePart& value);
void Add(const MessagePart& value);
bool Contains(const string& key) const;

View File

@ -53,7 +53,7 @@ public:
*/
inline bool GetVersion(string *value) const
{
return GetProperty("jsonrpc", value);
return Get("jsonrpc", value);
}
/**
@ -63,7 +63,7 @@ public:
*/
inline void SetVersion(const string& value)
{
SetProperty("jsonrpc", value);
Set("jsonrpc", value);
}
/**
@ -74,7 +74,7 @@ public:
*/
inline bool GetMethod(string *value) const
{
return GetProperty("method", value);
return Get("method", value);
}
/**
@ -84,7 +84,7 @@ public:
*/
inline void SetMethod(const string& value)
{
SetProperty("method", value);
Set("method", value);
}
/**
@ -95,7 +95,7 @@ public:
*/
inline bool GetParams(MessagePart *value) const
{
return GetProperty("params", value);
return Get("params", value);
}
/**
@ -105,7 +105,7 @@ public:
*/
inline void SetParams(const MessagePart& value)
{
SetProperty("params", value);
Set("params", value);
}
/**
@ -116,7 +116,7 @@ public:
*/
inline bool GetID(string *value) const
{
return GetProperty("id", value);
return Get("id", value);
}
/**
@ -126,7 +126,7 @@ public:
*/
inline void SetID(const string& value)
{
SetProperty("id", value);
Set("id", value);
}
};

View File

@ -53,7 +53,7 @@ public:
*/
inline bool GetVersion(string *value) const
{
return GetProperty("jsonrpc", value);
return Get("jsonrpc", value);
}
/**
@ -63,7 +63,7 @@ public:
*/
inline void SetVersion(const string& value)
{
SetProperty("jsonrpc", value);
Set("jsonrpc", value);
}
/**
@ -74,7 +74,7 @@ public:
*/
bool GetResult(MessagePart *value) const
{
return GetProperty("result", value);
return Get("result", value);
}
/**
@ -84,7 +84,7 @@ public:
*/
void SetResult(const MessagePart& value)
{
SetProperty("result", value);
Set("result", value);
}
/**
@ -95,7 +95,7 @@ public:
*/
bool GetError(string *value) const
{
return GetProperty("error", value);
return Get("error", value);
}
/**
@ -105,7 +105,7 @@ public:
*/
void SetError(const string& value)
{
SetProperty("error", value);
Set("error", value);
}
/**
@ -116,7 +116,7 @@ public:
*/
bool GetID(string *value) const
{
return GetProperty("id", value);
return Get("id", value);
}
/**
@ -126,7 +126,7 @@ public:
*/
void SetID(const string& value)
{
SetProperty("id", value);
Set("id", value);
}
/**

View File

@ -14,19 +14,19 @@ BOOST_AUTO_TEST_CASE(construct)
BOOST_AUTO_TEST_CASE(getproperty)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
dictionary->SetProperty("test1", 7);
dictionary->SetProperty("test2", "hello world");
dictionary->Set("test1", 7);
dictionary->Set("test2", "hello world");
long test1;
BOOST_REQUIRE(dictionary->GetProperty("test1", &test1));
BOOST_REQUIRE(dictionary->Get("test1", &test1));
BOOST_REQUIRE(test1 == 7);
string test2;
BOOST_REQUIRE(dictionary->GetProperty("test2", &test2));
BOOST_REQUIRE(dictionary->Get("test2", &test2));
BOOST_REQUIRE(test2 == "hello world");
long test3;
BOOST_REQUIRE(!dictionary->GetProperty("test3", &test3));
BOOST_REQUIRE(!dictionary->Get("test3", &test3));
}
BOOST_AUTO_TEST_CASE(getproperty_dict)
@ -34,22 +34,22 @@ BOOST_AUTO_TEST_CASE(getproperty_dict)
Dictionary::Ptr dictionary = make_shared<Dictionary>();
Dictionary::Ptr other = make_shared<Dictionary>();
dictionary->SetProperty("test1", other);
dictionary->Set("test1", other);
Dictionary::Ptr test1;
BOOST_REQUIRE(dictionary->GetProperty("test1", &test1));
BOOST_REQUIRE(dictionary->Get("test1", &test1));
BOOST_REQUIRE(other == test1);
Dictionary::Ptr test2;
BOOST_REQUIRE(!dictionary->GetProperty("test2", &test2));
BOOST_REQUIRE(!dictionary->Get("test2", &test2));
}
BOOST_AUTO_TEST_CASE(unnamed)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
dictionary->AddUnnamedProperty("test1");
dictionary->AddUnnamedProperty("test2");
dictionary->AddUnnamedProperty("test3");
dictionary->Add("test1");
dictionary->Add("test2");
dictionary->Add("test3");
BOOST_REQUIRE(distance(dictionary->Begin(), dictionary->End()) == 3);
}