diff --git a/base/configobject.cpp b/base/configobject.cpp index 61e1a05c6..fea51e131 100644 --- a/base/configobject.cpp +++ b/base/configobject.cpp @@ -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(ts)); + GetProperties()->Set("__tx", static_cast(ts)); } time_t ConfigObject::GetCommitTimestamp(void) const { long value = false; - GetProperties()->GetProperty("__tx", &value); + GetProperties()->Get("__tx", &value); return value; } diff --git a/base/configobject.h b/base/configobject.h index 82cb13136..ca8975d6a 100644 --- a/base/configobject.h +++ b/base/configobject.h @@ -47,13 +47,13 @@ public: template void SetProperty(const string& key, const T& value) { - GetProperties()->SetProperty(key, value); + GetProperties()->Set(key, value); } template 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 void SetTag(const string& key, const T& value) { - GetTags()->SetProperty(key, value); + GetTags()->Set(key, value); } template bool GetTag(const string& key, T *value) const { - return GetTags()->GetProperty(key, value); + return GetTags()->Get(key, value); } string GetType(void) const; diff --git a/base/dictionary.cpp b/base/dictionary.cpp index a83fa3bd1..8626916bb 100644 --- a/base/dictionary.cpp +++ b/base/dictionary.cpp @@ -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); diff --git a/base/dictionary.h b/base/dictionary.h index 561b14510..4aa17f987 100644 --- a/base/dictionary.h +++ b/base/dictionary.h @@ -45,7 +45,7 @@ public: * @returns true if the value was retrieved, false otherwise. */ template - 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(object); @@ -85,7 +85,7 @@ public: * @param value The value. */ template - void SetProperty(const string& key, const T& value) + void Set(const string& key, const T& value) { pair::iterator, bool> ret; ret = m_Data.insert(make_pair(key, value)); @@ -99,7 +99,7 @@ public: * @param value The value. */ template - 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 m_Data; diff --git a/cib/checkresult.cpp b/cib/checkresult.cpp index 92adcdc13..0b6fef00b 100644 --- a/cib/checkresult.cpp +++ b/cib/checkresult.cpp @@ -12,96 +12,96 @@ CheckResult::CheckResult(const MessagePart& message) void CheckResult::SetScheduleStart(time_t ts) { - SetProperty("schedule_start", static_cast(ts)); + Set("schedule_start", static_cast(ts)); } time_t CheckResult::GetScheduleStart(void) const { long value = 0; - GetProperty("schedule_start", &value); + Get("schedule_start", &value); return static_cast(value); } void CheckResult::SetScheduleEnd(time_t ts) { - SetProperty("schedule_end", static_cast(ts)); + Set("schedule_end", static_cast(ts)); } time_t CheckResult::GetScheduleEnd(void) const { long value = 0; - GetProperty("schedule_end", &value); + Get("schedule_end", &value); return static_cast(value); } void CheckResult::SetExecutionStart(time_t ts) { - SetProperty("execution_start", static_cast(ts)); + Set("execution_start", static_cast(ts)); } time_t CheckResult::GetExecutionStart(void) const { long value = 0; - GetProperty("execution_start", &value); + Get("execution_start", &value); return static_cast(value); } void CheckResult::SetExecutionEnd(time_t ts) { - SetProperty("execution_end", static_cast(ts)); + Set("execution_end", static_cast(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(state)); + Set("state", static_cast(state)); } ServiceState CheckResult::GetState(void) const { long value = StateUnknown; - GetProperty("state", &value); + Get("state", &value); return static_cast(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; } diff --git a/cib/macroprocessor.cpp b/cib/macroprocessor.cpp index 7a699585f..75865a7f6 100644 --- a/cib/macroprocessor.cpp +++ b/cib/macroprocessor.cpp @@ -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); diff --git a/cib/service.cpp b/cib/service.cpp index 595256fd2..ba9c4d68d 100644 --- a/cib/service.cpp +++ b/cib/service.cpp @@ -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; diff --git a/cib/servicestatusmessage.cpp b/cib/servicestatusmessage.cpp index c05134b48..80a800fb8 100644 --- a/cib/servicestatusmessage.cpp +++ b/cib/servicestatusmessage.cpp @@ -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(value); return true; } @@ -24,13 +24,13 @@ bool ServiceStatusMessage::GetState(ServiceState *state) const void ServiceStatusMessage::SetState(ServiceState state) { - SetProperty("state", static_cast(state)); + Set("state", static_cast(state)); } bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const { long value; - if (GetProperty("state_type", &value)) { + if (Get("state_type", &value)) { *type = static_cast(value); return true; } @@ -39,23 +39,23 @@ bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const void ServiceStatusMessage::SetStateType(ServiceStateType type) { - SetProperty("state_type", static_cast(type)); + Set("state_type", static_cast(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(ts)); + Set("next_check", static_cast(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()); -} \ No newline at end of file + Set("result", cr.GetDictionary()); +} diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp index e1dbb1bf0..b5165fd94 100644 --- a/components/checker/checkercomponent.cpp +++ b/components/checker/checkercomponent.cpp @@ -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(serviceMsg.GetDictionary()); diff --git a/components/cibsync/cibsynccomponent.cpp b/components/cibsync/cibsynccomponent.cpp index abda6c134..a962fec15 100644 --- a/components/cibsync/cibsynccomponent.cpp +++ b/components/cibsync/cibsynccomponent.cpp @@ -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); diff --git a/components/convenience/conveniencecomponent.cpp b/components/convenience/conveniencecomponent.cpp index 4e6d5f59f..733fe29aa 100644 --- a/components/convenience/conveniencecomponent.cpp +++ b/components/convenience/conveniencecomponent.cpp @@ -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", ¯os)) + if (service->Get("macros", ¯os)) 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); } } diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index e0b92d9de..84aa545d0 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -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() + "'"); diff --git a/components/discovery/discoverycomponent.cpp b/components/discovery/discoverycomponent.cpp index a1f598e0f..2b6080da7 100644 --- a/components/discovery/discoverycomponent.cpp +++ b/components/discovery/discoverycomponent.cpp @@ -301,13 +301,13 @@ void DiscoveryComponent::SendDiscoveryMessage(const string& method, const string set::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); diff --git a/components/discovery/discoverymessage.cpp b/components/discovery/discoverymessage.cpp index a50988557..475b9cfc1 100644 --- a/components/discovery/discoverymessage.cpp +++ b/components/discovery/discoverymessage.cpp @@ -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); -} \ No newline at end of file + Set("publications", value); +} diff --git a/dyn/config_parser.cc b/dyn/config_parser.cc index 1ea713bbc..911b4c68c 100644 --- a/dyn/config_parser.cc +++ b/dyn/config_parser.cc @@ -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; diff --git a/dyn/config_parser.yy b/dyn/config_parser.yy index 6bf6e9aee..4e3a19628 100644 --- a/dyn/config_parser.yy +++ b/dyn/config_parser.yy @@ -257,7 +257,7 @@ tuple: '(' tupleitem: simplevalue { - m_Array->AddUnnamedProperty(*$1); + m_Array->Add(*$1); delete $1; } diff --git a/dyn/expression.cpp b/dyn/expression.cpp index d6740bd77..cbca7eb42 100644 --- a/dyn/expression.cpp +++ b/dyn/expression.cpp @@ -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(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); } diff --git a/icinga/jsonrpcendpoint.cpp b/icinga/jsonrpcendpoint.cpp index 881516451..9dcc123eb 100644 --- a/icinga/jsonrpcendpoint.cpp +++ b/icinga/jsonrpcendpoint.cpp @@ -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); diff --git a/jsonrpc/messagepart.cpp b/jsonrpc/messagepart.cpp index d2cb6881e..7b3a2ef7e 100644 --- a/jsonrpc/messagepart.cpp +++ b/jsonrpc/messagepart.cpp @@ -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(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()); } /** diff --git a/jsonrpc/messagepart.h b/jsonrpc/messagepart.h index 80554cabf..276d3e928 100644 --- a/jsonrpc/messagepart.h +++ b/jsonrpc/messagepart.h @@ -52,9 +52,9 @@ public: * @returns true if the value was retrieved, false otherwise. */ template - 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 - 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 - 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; diff --git a/jsonrpc/requestmessage.h b/jsonrpc/requestmessage.h index 868e2c8bc..6f571c5e0 100644 --- a/jsonrpc/requestmessage.h +++ b/jsonrpc/requestmessage.h @@ -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); } }; diff --git a/jsonrpc/responsemessage.h b/jsonrpc/responsemessage.h index 8a6431085..39466409b 100644 --- a/jsonrpc/responsemessage.h +++ b/jsonrpc/responsemessage.h @@ -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); } /** diff --git a/test/base-dictionary.cpp b/test/base-dictionary.cpp index 071e745ee..2c56f8fa1 100644 --- a/test/base-dictionary.cpp +++ b/test/base-dictionary.cpp @@ -14,19 +14,19 @@ BOOST_AUTO_TEST_CASE(construct) BOOST_AUTO_TEST_CASE(getproperty) { Dictionary::Ptr dictionary = make_shared(); - 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::Ptr other = make_shared(); - 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->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); }