diff options
author | iAndrew5 <abyzhynar@luxoft.com> | 2015-10-16 18:09:35 +0300 |
---|---|---|
committer | iAndrew5 <abyzhynar@luxoft.com> | 2015-10-28 16:55:59 +0200 |
commit | 7762404a0d8dc67c6b1943bac4aeaea2d75a46f5 (patch) | |
tree | d8886526e639bce8c16f7eb00b6086369fe22a65 /src/components/rpc_base | |
parent | 8e25392dfd13ac5bbaa62497c71039eca84e81d9 (diff) | |
download | sdl_core-7762404a0d8dc67c6b1943bac4aeaea2d75a46f5.tar.gz |
Added UT for SQL PT Representation
Added some new code to policy, rpc_base, utils and application_manager
components
Diffstat (limited to 'src/components/rpc_base')
-rw-r--r-- | src/components/rpc_base/include/rpc_base/rpc_base.h | 8 | ||||
-rw-r--r-- | src/components/rpc_base/include/rpc_base/rpc_base_inl.h | 21 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h index 1792262a0f..da0a7f2388 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base.h @@ -229,10 +229,10 @@ class String : public PrimitiveType { explicit String(const Json::Value* value); explicit String(dbus::MessageReader* reader); String(const Json::Value* value, const std::string& def_value); - bool operator<(String new_val); + bool operator<(const String& new_val) const; String& operator=(const std::string& new_val); String& operator=(const String& new_val); - bool operator==(const String& rhs); + bool operator==(const String& rhs) const; operator const std::string& () const; Json::Value ToJsonValue() const; void ToDbusWriter(dbus::MessageWriter* writer) const; @@ -254,7 +254,7 @@ class Enum : public PrimitiveType { explicit Enum(const Json::Value* value); explicit Enum(dbus::MessageReader* reader); Enum(const Json::Value* value, EnumType def_value); - Enum& operator=(EnumType new_val); + Enum& operator=(const EnumType& new_val); operator EnumType() const; Json::Value ToJsonValue() const; void ToDbusWriter(dbus::MessageWriter* writer) const; @@ -393,6 +393,8 @@ class Optional { const T& operator*() const; T* operator->(); const T* operator->() const; + + void assign_if_valid(const Optional<T>& value); // For pointer-like 'if (optional_value)' tests // Better than operator bool because bool can be implicitly // casted to integral types diff --git a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h index 9a59e169c2..eb374188c3 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base_inl.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base_inl.h @@ -187,7 +187,10 @@ Integer<T, minval, maxval>& Integer<T, minval, maxval>::operator=(IntType new_va template<typename T, T minval, T maxval> Integer<T, minval, maxval>& Integer<T, minval, maxval>::operator=(const Integer& new_val) { this->value_ = new_val.value_; - this->value_state_= range_.Includes(new_val.value_) ? kValid : kInvalid; + if (new_val.is_initialized()) { + this->value_state_= range_.Includes(new_val.value_) ? kValid : kInvalid; + } + return *this; } @@ -266,7 +269,7 @@ String<minlen, maxlen>::String(const char* value) } template<size_t minlen, size_t maxlen> -bool String<minlen, maxlen>::operator<(String new_val) { +bool String<minlen, maxlen>::operator<(const String& new_val) const { return value_ < new_val.value_; } @@ -279,13 +282,16 @@ String<minlen, maxlen>& String<minlen, maxlen>::operator=(const std::string& new template<size_t minlen, size_t maxlen> String<minlen, maxlen>& String<minlen, maxlen>::operator=(const String& new_val) { + if(*this == new_val) { + return *this; + } value_.assign(new_val.value_); value_state_ = new_val.value_state_; return *this; } template<size_t minlen, size_t maxlen> -bool String<minlen, maxlen>::operator==(const String& rhs) { +bool String<minlen, maxlen>::operator==(const String& rhs) const { return value_ == rhs.value_; } @@ -310,7 +316,7 @@ Enum<T>::Enum(EnumType value) } template<typename T> -Enum<T>& Enum<T>::operator=(EnumType new_val) { +Enum<T>& Enum<T>::operator=(const EnumType& new_val) { value_ = new_val; value_state_ = IsValidEnum(value_) ? kValid : kInvalid; return *this; @@ -604,6 +610,13 @@ const T* Optional<T>::operator->() const { } template<typename T> +void Optional<T>::assign_if_valid(const Optional<T>& value) { + if (value.is_initialized()) { + value_ = value.value_; + } +} + +template<typename T> Optional<T>::operator const void*() const { return is_initialized() ? &value_ : NULL; } |