summaryrefslogtreecommitdiff
path: root/src/components/smart_objects/include/smart_objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/smart_objects/include/smart_objects')
-rw-r--r--src/components/smart_objects/include/smart_objects/always_false_schema_item.h1
-rw-r--r--src/components/smart_objects/include/smart_objects/always_true_schema_item.h1
-rw-r--r--src/components/smart_objects/include/smart_objects/array_schema_item.h9
-rw-r--r--src/components/smart_objects/include/smart_objects/bool_schema_item.h5
-rw-r--r--src/components/smart_objects/include/smart_objects/default_shema_item.h18
-rw-r--r--src/components/smart_objects/include/smart_objects/enum_schema_item.h61
-rw-r--r--src/components/smart_objects/include/smart_objects/errors.h3
-rw-r--r--src/components/smart_objects/include/smart_objects/number_schema_item.h88
-rw-r--r--src/components/smart_objects/include/smart_objects/object_schema_item.h9
-rw-r--r--src/components/smart_objects/include/smart_objects/schema_item.h11
-rw-r--r--src/components/smart_objects/include/smart_objects/schema_item_parameter.h16
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_object.h132
-rw-r--r--src/components/smart_objects/include/smart_objects/string_schema_item.h10
13 files changed, 219 insertions, 145 deletions
diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
index c4babbf8b4..dfbf4ba43e 100644
--- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
@@ -54,6 +54,7 @@ class CAlwaysFalseSchemaItem : public ISchemaItem {
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
+
private:
CAlwaysFalseSchemaItem();
DISALLOW_COPY_AND_ASSIGN(CAlwaysFalseSchemaItem);
diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
index 1b5fa8a765..3dd598d7bd 100644
--- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
@@ -54,6 +54,7 @@ class CAlwaysTrueSchemaItem : public ISchemaItem {
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object) OVERRIDE;
+
private:
CAlwaysTrueSchemaItem();
DISALLOW_COPY_AND_ASSIGN(CAlwaysTrueSchemaItem);
diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h
index 6454693b38..0d3a651d56 100644
--- a/src/components/smart_objects/include/smart_objects/array_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h
@@ -57,8 +57,10 @@ class CArraySchemaItem : public ISchemaItem {
**/
static utils::SharedPtr<CArraySchemaItem> create(
const ISchemaItemPtr ElementSchemaItem = CAlwaysTrueSchemaItem::create(),
- const TSchemaItemParameter<size_t>& MinSize = TSchemaItemParameter<size_t>(),
- const TSchemaItemParameter<size_t>& MaxSize = TSchemaItemParameter<size_t>());
+ const TSchemaItemParameter<size_t>& MinSize =
+ TSchemaItemParameter<size_t>(),
+ const TSchemaItemParameter<size_t>& MaxSize =
+ TSchemaItemParameter<size_t>());
/**
* @brief Validate smart object.
@@ -77,7 +79,8 @@ class CArraySchemaItem : public ISchemaItem {
* @param RemoveFakeParameters contains true if need to remove fake parameters
* from smart object otherwise contains false.
**/
- void applySchema(SmartObject& Object, const bool RemoveFakeParameters) OVERRIDE;
+ void applySchema(SmartObject& Object,
+ const bool RemoveFakeParameters) OVERRIDE;
/**
* @brief Unapply schema.
diff --git a/src/components/smart_objects/include/smart_objects/bool_schema_item.h b/src/components/smart_objects/include/smart_objects/bool_schema_item.h
index bb0dbd6653..eca5a0e063 100644
--- a/src/components/smart_objects/include/smart_objects/bool_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/bool_schema_item.h
@@ -50,13 +50,14 @@ class CBoolSchemaItem : public CDefaultSchemaItem<bool> {
* @return Shared pointer to a new schema item.
**/
static utils::SharedPtr<CBoolSchemaItem> create(
- const TSchemaItemParameter<bool>& DefaultValue =
- TSchemaItemParameter<bool>());
+ const TSchemaItemParameter<bool>& DefaultValue =
+ TSchemaItemParameter<bool>());
private:
explicit CBoolSchemaItem(const TSchemaItemParameter<bool>& DefaultValue);
SmartType getSmartType() const OVERRIDE;
bool getDefaultValue() const OVERRIDE;
+
private:
DISALLOW_COPY_AND_ASSIGN(CBoolSchemaItem);
};
diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h
index 5065e27684..857354a4e6 100644
--- a/src/components/smart_objects/include/smart_objects/default_shema_item.h
+++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h
@@ -45,7 +45,7 @@ namespace NsSmartObjects {
/**
* @brief Default schema item.
**/
-template<typename Type>
+template <typename Type>
class CDefaultSchemaItem : public ISchemaItem {
public:
typedef TSchemaItemParameter<Type> ParameterType;
@@ -93,17 +93,17 @@ class CDefaultSchemaItem : public ISchemaItem {
DISALLOW_COPY_AND_ASSIGN(CDefaultSchemaItem<Type>);
};
-template<typename Type>
+template <typename Type>
CDefaultSchemaItem<Type>::CDefaultSchemaItem(const ParameterType& DefaultValue)
- : mDefaultValue(DefaultValue) {
-}
+ : mDefaultValue(DefaultValue) {}
-template<typename Type>
+template <typename Type>
Errors::eType CDefaultSchemaItem<Type>::validate(const SmartObject& Object) {
- return (getSmartType() == Object.getType()) ? Errors::OK : Errors::INVALID_VALUE;
+ return (getSmartType() == Object.getType()) ? Errors::OK
+ : Errors::INVALID_VALUE;
}
-template<typename Type>
+template <typename Type>
bool CDefaultSchemaItem<Type>::setDefaultValue(SmartObject& Object) {
Type value;
if (mDefaultValue.getValue(value)) {
@@ -113,9 +113,9 @@ bool CDefaultSchemaItem<Type>::setDefaultValue(SmartObject& Object) {
return false;
}
-template<typename Type>
+template <typename Type>
void CDefaultSchemaItem<Type>::BuildObjectBySchema(
- const SmartObject& pattern_object, SmartObject& result_object) {
+ const SmartObject& pattern_object, SmartObject& result_object) {
if (getSmartType() == pattern_object.getType()) {
result_object = pattern_object;
} else {
diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
index c303061152..a0d6d94017 100644
--- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
@@ -42,16 +42,16 @@
#include "utils/shared_ptr.h"
#include "smart_objects/default_shema_item.h"
-
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
-template <typename EnumType> class EnumConversionHelper;
+template <typename EnumType>
+class EnumConversionHelper;
/**
* @brief Enumeration schema item.
* @tparam EnumType Enumeration type.
**/
-template<typename EnumType>
+template <typename EnumType>
class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
public:
/**
@@ -61,9 +61,9 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
* @return Shared pointer to a new schema item.
**/
static utils::SharedPtr<TEnumSchemaItem> create(
- const std::set<EnumType>& AllowedElements,
- const TSchemaItemParameter<EnumType>& DefaultValue =
- TSchemaItemParameter<EnumType>());
+ const std::set<EnumType>& AllowedElements,
+ const TSchemaItemParameter<EnumType>& DefaultValue =
+ TSchemaItemParameter<EnumType>());
/**
* @brief Validate smart object.
* @param Object Object to validate.
@@ -79,7 +79,8 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
* @param RemoveFakeParameters contains true if need to remove fake parameters
* from smart object otherwise contains false.
**/
- void applySchema(SmartObject& Object, const bool RemoveFakeParameters) OVERRIDE;
+ void applySchema(SmartObject& Object,
+ const bool RemoveFakeParameters) OVERRIDE;
/**
* @brief Unapply schema.
* @param Object Object to unapply schema.
@@ -129,7 +130,8 @@ class EnumConversionHelper {
}
static bool CStringToEnum(const char* str, EnumType* value) {
- typename CStringToEnumMap::const_iterator it = cstring_to_enum_map().find(str);
+ typename CStringToEnumMap::const_iterator it =
+ cstring_to_enum_map().find(str);
if (it == cstring_to_enum_map().end()) {
return false;
}
@@ -140,7 +142,8 @@ class EnumConversionHelper {
}
static bool EnumToCString(EnumType value, const char** str) {
- typename EnumToCStringMap::const_iterator it = enum_to_cstring_map().find(value);
+ typename EnumToCStringMap::const_iterator it =
+ enum_to_cstring_map().find(value);
if (it == enum_to_cstring_map().end()) {
return false;
}
@@ -172,7 +175,7 @@ class EnumConversionHelper {
static const CStringToEnumMap cstring_to_enum_map_;
struct Size {
- enum {value = sizeof(cstring_values_) / sizeof(cstring_values_[0])};
+ enum { value = sizeof(cstring_values_) / sizeof(cstring_values_[0]) };
};
static EnumToCStringMap InitEnumToCStringMap() {
@@ -195,28 +198,28 @@ class EnumConversionHelper {
DISALLOW_COPY_AND_ASSIGN(EnumConversionHelper<EnumType>);
};
-
-template<typename EnumType>
+template <typename EnumType>
utils::SharedPtr<TEnumSchemaItem<EnumType> > TEnumSchemaItem<EnumType>::create(
- const std::set<EnumType>& AllowedElements,
- const TSchemaItemParameter<EnumType>& DefaultValue) {
+ const std::set<EnumType>& AllowedElements,
+ const TSchemaItemParameter<EnumType>& DefaultValue) {
return new TEnumSchemaItem<EnumType>(AllowedElements, DefaultValue);
}
-template<typename EnumType>
+template <typename EnumType>
Errors::eType TEnumSchemaItem<EnumType>::validate(const SmartObject& Object) {
if (SmartType_Integer != Object.getType()) {
return Errors::INVALID_VALUE;
}
- if (mAllowedElements.find(static_cast<EnumType>(Object.asInt()))
- == mAllowedElements.end()) {
+ if (mAllowedElements.find(static_cast<EnumType>(Object.asInt())) ==
+ mAllowedElements.end()) {
return Errors::OUT_OF_RANGE;
}
return Errors::OK;
}
-template<typename EnumType>
-void TEnumSchemaItem<EnumType>::applySchema(SmartObject& Object, const bool RemoveFakeParameters) {
+template <typename EnumType>
+void TEnumSchemaItem<EnumType>::applySchema(SmartObject& Object,
+ const bool RemoveFakeParameters) {
if (SmartType_String == Object.getType()) {
EnumType enum_val = static_cast<EnumType>(-1);
if (ConversionHelper::StringToEnum(Object.asString(), &enum_val)) {
@@ -225,32 +228,32 @@ void TEnumSchemaItem<EnumType>::applySchema(SmartObject& Object, const bool Remo
}
}
-template<typename EnumType>
+template <typename EnumType>
void TEnumSchemaItem<EnumType>::unapplySchema(SmartObject& Object) {
if (SmartType_Integer == Object.getType()) {
const char* str;
- if (ConversionHelper::EnumToCString(static_cast<EnumType>(Object.asInt()), &str)) {
+ if (ConversionHelper::EnumToCString(static_cast<EnumType>(Object.asInt()),
+ &str)) {
Object = str;
}
}
}
-template<typename EnumType>
+template <typename EnumType>
SmartType TEnumSchemaItem<EnumType>::getSmartType() const {
return SmartType_Integer;
}
-template<typename EnumType>
+template <typename EnumType>
EnumType TEnumSchemaItem<EnumType>::getDefaultValue() const {
return EnumType::INVALID_ENUM;
}
-template<typename EnumType>
+template <typename EnumType>
TEnumSchemaItem<EnumType>::TEnumSchemaItem(
- const std::set<EnumType>& AllowedElements,
- const TSchemaItemParameter<EnumType>& DefaultValue)
- : CDefaultSchemaItem<EnumType>(DefaultValue),
- mAllowedElements(AllowedElements) {
-}
+ const std::set<EnumType>& AllowedElements,
+ const TSchemaItemParameter<EnumType>& DefaultValue)
+ : CDefaultSchemaItem<EnumType>(DefaultValue)
+ , mAllowedElements(AllowedElements) {}
} // namespace NsSmartObjects
} // namespace NsSmartDeviceLink
diff --git a/src/components/smart_objects/include/smart_objects/errors.h b/src/components/smart_objects/include/smart_objects/errors.h
index fe8a04b692..5d22d2386e 100644
--- a/src/components/smart_objects/include/smart_objects/errors.h
+++ b/src/components/smart_objects/include/smart_objects/errors.h
@@ -35,7 +35,8 @@ namespace NsSmartDeviceLink {
namespace NsSmartObjects {
namespace Errors {
/**
- * @brief Enumeration that provides information about SmartObject validation errors
+ * @brief Enumeration that provides information about SmartObject validation
+ *errors
**/
enum eType {
/**
diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h
index fb4d287fe4..01d6c08daa 100644
--- a/src/components/smart_objects/include/smart_objects/number_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h
@@ -34,10 +34,11 @@
#define SRC_COMPONENTS_SMART_OBJECTS_INCLUDE_SMART_OBJECTS_NUMBER_SCHEMA_ITEM_H_
#include <typeinfo>
-
+#include <limits>
#include "utils/shared_ptr.h"
#include "smart_objects/default_shema_item.h"
#include "smart_objects/schema_item_parameter.h"
+#include "utils/convert_utils.h"
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
@@ -45,7 +46,7 @@ namespace NsSmartObjects {
* @brief Number schema item.
* @tparam NumberType Number type.
**/
-template<typename NumberType>
+template <typename NumberType>
class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
public:
/**
@@ -56,10 +57,12 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
* @return Shared pointer to a new schema item.
**/
static utils::SharedPtr<TNumberSchemaItem> create(
- const TSchemaItemParameter<NumberType>& MinValue = TSchemaItemParameter <NumberType > (),
- const TSchemaItemParameter<NumberType>& MaxValue = TSchemaItemParameter <NumberType > (),
- const TSchemaItemParameter<NumberType>& DefaultValue =
- TSchemaItemParameter<NumberType>());
+ const TSchemaItemParameter<NumberType>& MinValue =
+ TSchemaItemParameter<NumberType>(),
+ const TSchemaItemParameter<NumberType>& MaxValue =
+ TSchemaItemParameter<NumberType>(),
+ const TSchemaItemParameter<NumberType>& DefaultValue =
+ TSchemaItemParameter<NumberType>());
/**
* @brief Validate smart object.
@@ -98,45 +101,47 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
DISALLOW_COPY_AND_ASSIGN(TNumberSchemaItem);
};
-template<typename NumberType>
-utils::SharedPtr<TNumberSchemaItem<NumberType> >
-TNumberSchemaItem<NumberType>::create(
- const TSchemaItemParameter<NumberType>& MinValue,
- const TSchemaItemParameter<NumberType>& MaxValue,
- const TSchemaItemParameter<NumberType>& DefaultValue) {
+template <typename NumberType>
+utils::SharedPtr<TNumberSchemaItem<NumberType> > TNumberSchemaItem<
+ NumberType>::create(const TSchemaItemParameter<NumberType>& MinValue,
+ const TSchemaItemParameter<NumberType>& MaxValue,
+ const TSchemaItemParameter<NumberType>& DefaultValue) {
return new TNumberSchemaItem<NumberType>(MinValue, MaxValue, DefaultValue);
}
-template<typename NumberType>
+template <typename NumberType>
bool TNumberSchemaItem<NumberType>::isValidNumberType(SmartType type) {
NumberType value(0);
- if ((SmartType_Double == type) &&
- (typeid(double) == typeid(value))) {
- return true;
+ if ((SmartType_Double == type) && (typeid(double) == typeid(value))) {
+ return true;
} else if ((SmartType_Integer == type) &&
- (typeid(int32_t) == typeid(value) ||
- typeid(uint32_t) == typeid(value) ||
- typeid(int64_t) == typeid(value))) {
- return true;
+ (typeid(int32_t) == typeid(value) ||
+ typeid(uint32_t) == typeid(value) ||
+ typeid(int64_t) == typeid(value) ||
+ typeid(double) == typeid(value))) {
+ return true;
} else {
- return false;
+ return false;
}
}
-template<typename NumberType>
-Errors::eType TNumberSchemaItem<NumberType>::validate(const SmartObject& Object) {
+template <typename NumberType>
+Errors::eType TNumberSchemaItem<NumberType>::validate(
+ const SmartObject& Object) {
if (!isValidNumberType(Object.getType())) {
return Errors::INVALID_VALUE;
}
NumberType value(0);
if (typeid(int32_t) == typeid(value)) {
- value = Object.asInt();
+ value = utils::SafeStaticCast<int64_t, int32_t>(Object.asInt());
} else if (typeid(uint32_t) == typeid(value)) {
- value = Object.asUInt();
+ value = utils::SafeStaticCast<uint64_t, uint32_t>(Object.asUInt());
} else if (typeid(double) == typeid(value)) {
value = Object.asDouble();
} else if (typeid(int64_t) == typeid(value)) {
- value = Object.asInt64();
+ value = Object.asInt();
+ } else if (typeid(uint64_t) == typeid(value)) {
+ value = Object.asUInt();
} else {
NOTREACHED();
}
@@ -152,17 +157,16 @@ Errors::eType TNumberSchemaItem<NumberType>::validate(const SmartObject& Object)
return Errors::OK;
}
-template<typename NumberType>
+template <typename NumberType>
TNumberSchemaItem<NumberType>::TNumberSchemaItem(
- const TSchemaItemParameter<NumberType>& MinValue,
- const TSchemaItemParameter<NumberType>& MaxValue,
- const TSchemaItemParameter<NumberType>& DefaultValue)
- : CDefaultSchemaItem<NumberType>(DefaultValue),
- mMinValue(MinValue),
- mMaxValue(MaxValue) {
-}
-
-template<typename NumberType>
+ const TSchemaItemParameter<NumberType>& MinValue,
+ const TSchemaItemParameter<NumberType>& MaxValue,
+ const TSchemaItemParameter<NumberType>& DefaultValue)
+ : CDefaultSchemaItem<NumberType>(DefaultValue)
+ , mMinValue(MinValue)
+ , mMaxValue(MaxValue) {}
+
+template <typename NumberType>
NumberType TNumberSchemaItem<NumberType>::getDefaultValue() const {
return NumberType(0);
}
@@ -171,21 +175,21 @@ NumberType TNumberSchemaItem<NumberType>::getDefaultValue() const {
* @brief Specialization of getSmartType for number types.
* @return SmartType.
**/
-template<typename NumberType>
+template <typename NumberType>
SmartType TNumberSchemaItem<NumberType>::getSmartType() const {
DCHECK(!"Wrong type of template class");
return SmartType_Invalid;
}
-template<>
+template <>
SmartType TNumberSchemaItem<int32_t>::getSmartType() const;
-template<>
+template <>
SmartType TNumberSchemaItem<uint32_t>::getSmartType() const;
-template<>
-SmartType TNumberSchemaItem<uint32_t>::getSmartType() const;
+template <>
+SmartType TNumberSchemaItem<int64_t>::getSmartType() const;
-template<>
+template <>
SmartType TNumberSchemaItem<double>::getSmartType() const;
} // namespace NsSmartObjects
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h
index 6e16e6a2a2..549166e723 100644
--- a/src/components/smart_objects/include/smart_objects/object_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h
@@ -63,8 +63,7 @@ class CObjectSchemaItem : public ISchemaItem {
* @param IsMandatory true if member is mandatory, false
* otherwise. Defaults to true.
**/
- SMember(const ISchemaItemPtr SchemaItem,
- const bool IsMandatory = true);
+ SMember(const ISchemaItemPtr SchemaItem, const bool IsMandatory = true);
/**
* @brief Member schema item.
**/
@@ -96,7 +95,8 @@ class CObjectSchemaItem : public ISchemaItem {
* @param RemoveFakeParameters contains true if need to remove fake parameters
* from smart object otherwise contains false.
**/
- void applySchema(SmartObject& Object, const bool RemoveFakeParameters) OVERRIDE;
+ void applySchema(SmartObject& Object,
+ const bool RemoveFakeParameters) OVERRIDE;
/**
* @brief Unapply schema.
* @param Object Object to unapply schema.
@@ -131,7 +131,8 @@ class CObjectSchemaItem : public ISchemaItem {
void RemoveFakeParams(SmartObject& Object);
/**
- * @brief Map of member name to SMember structure describing the object member.
+ * @brief Map of member name to SMember structure describing the object
+ *member.
**/
const Members mMembers;
DISALLOW_COPY_AND_ASSIGN(CObjectSchemaItem);
diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h
index 92b1495909..08610f244e 100644
--- a/src/components/smart_objects/include/smart_objects/schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/schema_item.h
@@ -80,8 +80,9 @@ class ISchemaItem {
* @param RemoveFakeParameters contains true if need to remove fake parameters
* from smart object otherwise contains false.
**/
- virtual void applySchema(NsSmartDeviceLink::NsSmartObjects::SmartObject& Object,
- const bool RemoveFakeParameters);
+ virtual void applySchema(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& Object,
+ const bool RemoveFakeParameters);
/**
* @brief Unapply schema.
@@ -98,8 +99,8 @@ class ISchemaItem {
* @param pattern_object pattern object
* @param result_object object to build
*/
- virtual void BuildObjectBySchema(
- const SmartObject& pattern_object, SmartObject& result_object);
+ virtual void BuildObjectBySchema(const SmartObject& pattern_object,
+ SmartObject& result_object);
/**
* @brief Get value param, depends of children
@@ -108,7 +109,7 @@ class ISchemaItem {
*/
virtual size_t GetMemberSize();
- virtual ~ISchemaItem() { }
+ virtual ~ISchemaItem() {}
};
typedef utils::SharedPtr<ISchemaItem> ISchemaItemPtr;
} // namespace NsSmartObjects
diff --git a/src/components/smart_objects/include/smart_objects/schema_item_parameter.h b/src/components/smart_objects/include/smart_objects/schema_item_parameter.h
index 7ae359b740..49fdb9541b 100644
--- a/src/components/smart_objects/include/smart_objects/schema_item_parameter.h
+++ b/src/components/smart_objects/include/smart_objects/schema_item_parameter.h
@@ -42,7 +42,7 @@ namespace NsSmartObjects {
* etc. which may be unspecified.
* @tparam ParameterType Type of a parameter.
*/
-template<typename ParameterType>
+template <typename ParameterType>
class TSchemaItemParameter FINAL {
public:
/**
@@ -79,20 +79,16 @@ class TSchemaItemParameter FINAL {
const ParameterType mValue;
};
-template<typename ParameterType>
+template <typename ParameterType>
TSchemaItemParameter<ParameterType>::TSchemaItemParameter()
- : mIsSpecified(false),
- mValue() {
-}
+ : mIsSpecified(false), mValue() {}
-template<typename ParameterType>
+template <typename ParameterType>
TSchemaItemParameter<ParameterType>::TSchemaItemParameter(
const ParameterType& ParameterValue)
- : mIsSpecified(true),
- mValue(ParameterValue) {
-}
+ : mIsSpecified(true), mValue(ParameterValue) {}
-template<typename ParameterType>
+template <typename ParameterType>
bool TSchemaItemParameter<ParameterType>::getValue(ParameterType& Value) const {
if (mIsSpecified) {
Value = mValue;
diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h
index bd70b7ea11..688550b040 100644
--- a/src/components/smart_objects/include/smart_objects/smart_object.h
+++ b/src/components/smart_objects/include/smart_objects/smart_object.h
@@ -39,9 +39,13 @@
#include <map>
#include "smart_objects/smart_schema.h"
+#include "utils/custom_string.h"
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
+
+namespace custom_str = utils::custom_string;
+
class SmartObject;
/**
@@ -89,12 +93,19 @@ enum SmartType {
SmartType_Array = 7,
/**
- * @brief Binary data value. Gives possibility for object to store binary data.
+ * @brief Binary data value. Gives possibility for object to store binary
+ *data.
**/
SmartType_Binary = 8,
/**
- * @brief Invalid value. Represents invalid object that cannot change his type.
+ * @brief Unsigned Integer value.
+ **/
+ SmartType_UInteger = 9,
+
+ /**
+ * @brief Invalid value. Represents invalid object that cannot change his
+ *type.
**/
SmartType_Invalid = -1
};
@@ -124,9 +135,12 @@ typedef std::vector<SmartObjectSPtr> SmartObjectList;
/**
* @brief Main SmartObject class
*
- * This class act as Variant type from other languages and can be used as primitive type
- * like bool, int32_t, char, double, string and as complex type like array and map.
+ * This class act as Variant type from other languages and can be used as
+ *primitive type
+ * like bool, int32_t, char, double, string and as complex type like array and
+ *map.
**/
+
class SmartObject FINAL {
public:
/**
@@ -149,7 +163,7 @@ class SmartObject FINAL {
*
* @param pointer
**/
- template<typename UnknownType>
+ template <typename UnknownType>
SmartObject(const UnknownType&);
/**
@@ -192,14 +206,14 @@ class SmartObject FINAL {
*
* @param InitialValue Initial object value
**/
- explicit SmartObject(int32_t InitialValue);
+ explicit SmartObject(const int32_t InitialValue);
/**
- * @brief Returns current object converted to int32_t
+ * @brief Returns current object converted to int64_t
*
- * @return int32_t
+ * @return int64_t
**/
- int32_t asInt() const;
+ int64_t asInt() const;
/**
* @brief Assignment operator for type: int32_t
@@ -207,7 +221,7 @@ class SmartObject FINAL {
* @param NewValue New object value
* @return SmartObject&
**/
- SmartObject& operator=(int32_t NewValue);
+ SmartObject& operator=(const int32_t NewValue);
/**
* @brief Comparison operator for comparing object with integer value
@@ -215,7 +229,7 @@ class SmartObject FINAL {
* @param Value Value to compare object with
* @return bool
**/
- bool operator==(int32_t Value) const;
+ bool operator==(const int32_t Value) const;
// Support of type: uint32_t
/**
@@ -223,14 +237,14 @@ class SmartObject FINAL {
*
* @param InitialValue Initial object value
**/
- explicit SmartObject(uint32_t InitialValue);
+ explicit SmartObject(const uint32_t InitialValue);
/**
- * @brief Returns current object converted to uint32_t int32_t
+ * @brief Returns current object converted to uint64_t
*
- * @return double
+ * @return uint64_t
**/
- uint32_t asUInt() const;
+ uint64_t asUInt() const;
/**
* @brief Assignment operator for type: int32_t
@@ -238,7 +252,7 @@ class SmartObject FINAL {
* @param NewValue New object value
* @return SmartObject&
**/
- SmartObject& operator=(uint32_t NewValue);
+ SmartObject& operator=(const uint32_t NewValue);
/**
* @brief Comparison operator for comparing object with uint32_t value
@@ -246,7 +260,7 @@ class SmartObject FINAL {
* @param Value Value to compare object with
* @return bool
**/
- bool operator==(uint32_t Value) const;
+ bool operator==(const uint32_t Value) const;
/**
* @name Support of type: int64_t
@@ -257,7 +271,7 @@ class SmartObject FINAL {
*
* @param InitialValue Initial object value
**/
- explicit SmartObject(int64_t InitialValue);
+ explicit SmartObject(const int64_t InitialValue);
/**
* @brief Returns current object converted to int64_t
@@ -272,7 +286,7 @@ class SmartObject FINAL {
* @param NewValue New object value
* @return SmartObject&
**/
- SmartObject& operator=(int64_t NewValue);
+ SmartObject& operator=(const int64_t NewValue);
/**
* @brief Comparison operator for comparing object with integer value
@@ -280,7 +294,20 @@ class SmartObject FINAL {
* @param Value Value to compare object with
* @return bool
**/
- bool operator==(int64_t Value) const;
+ bool operator==(const int64_t Value) const;
+
+ /**
+ * @name Support of type: uint64_t
+ * @{
+ **/
+
+ /**
+ * @brief Assignment operator for type: uint64_t
+ *
+ * @param NewValue New object value
+ * @return SmartObject&
+ **/
+ SmartObject& operator=(const uint64_t NewValue);
/** @} */
@@ -401,6 +428,13 @@ class SmartObject FINAL {
explicit SmartObject(const std::string& InitialValue);
/**
+ * @brief Constructor for creating object of type: CustomString
+ *
+ * @param InitialValue Initial object value
+ **/
+ explicit SmartObject(const custom_str::CustomString& InitialValue);
+
+ /**
* @brief Constructor for creating object of type: string
*
* @param InitialValue Initial object value
@@ -408,6 +442,13 @@ class SmartObject FINAL {
explicit SmartObject(const char* InitialValue);
/**
+ * @brief Returns current object converted to CustomString
+ *
+ * @return custom_str::CustomString
+ **/
+ custom_str::CustomString asCustomString() const;
+
+ /**
* @brief Returns current object converted to string
*
* @return std::string
@@ -423,6 +464,14 @@ class SmartObject FINAL {
const char* asCharArray() const;
/**
+ * @brief Assignment operator for type: CustomString
+ *
+ * @param NewValue New object value
+ * @return SmartObject&
+ **/
+ SmartObject& operator=(const custom_str::CustomString& NewValue);
+
+ /**
* @brief Assignment operator for type: string
*
* @param NewValue New object value
@@ -673,7 +722,7 @@ class SmartObject FINAL {
* @param Other value to be compared with
* @return bool Result of nequation
**/
- template<typename Type>
+ template <typename Type>
bool operator!=(const Type& Other) const {
return !(*this == Other);
}
@@ -697,7 +746,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to int32_t type
*
- * @return int32_t Converted value or invalid_int_value if conversion not possible
+ * @return int32_t Converted value or invalid_int_value if conversion not
+ *possible
**/
inline int64_t convert_int() const;
/** @} */
@@ -719,7 +769,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to char type
*
- * @return int32_t Converted value or invalid_char_value if conversion not possible
+ * @return int32_t Converted value or invalid_char_value if conversion not
+ *possible
**/
inline char convert_char() const;
/** @} */
@@ -741,7 +792,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to double type
*
- * @return int32_t Converted value or invalid_double_value if conversion not possible
+ * @return int32_t Converted value or invalid_double_value if conversion not
+ *possible
**/
inline double convert_double() const;
/** @} */
@@ -763,16 +815,13 @@ class SmartObject FINAL {
/**
* @brief Converts object to bool type
*
- * @return int32_t Converted value or invalid_bool_value if conversion not possible
+ * @return int32_t Converted value or invalid_bool_value if conversion not
+ *possible
**/
inline bool convert_bool() const;
/** @} */
/**
- * @name Support of type: string (internal)
- * @{
- */
- /**
* @brief Sets new string value to the object.
*
* This method changes also internal object type
@@ -780,10 +829,10 @@ class SmartObject FINAL {
* @param NewValue New object value
* @return void
**/
- inline void set_value_string(const std::string& NewValue);
+ inline void set_value_string(const custom_str::CustomString& NewValue);
/**
- * @brief Sets new string value to the object.
+ * @brief Sets new CustomString value to the object.
*
* This method changes also internal object type
*
@@ -795,12 +844,21 @@ class SmartObject FINAL {
/**
* @brief Converts object to string type
*
- * @return int32_t Converted value or invalid_string_value if conversion not possible
+ * @return int32_t Converted value or invalid_string_value if conversion not
+ *possible
**/
inline std::string convert_string() const;
/** @} */
/**
+ * @brief Converts object to CustomString type
+ *
+ * @return CustomString Converted value or
+ * invalid_string_value if conversion not possible
+ **/
+ inline custom_str::CustomString convert_custom_string() const;
+
+ /**
* @name Support of type: binary (internal)
* @{
*/
@@ -817,7 +875,8 @@ class SmartObject FINAL {
/**
* @brief Converts object to binary type
*
- * @return int32_t Converted value or invalid_binary_value if conversion not possible
+ * @return int32_t Converted value or invalid_binary_value if conversion not
+ *possible
**/
inline SmartBinary convert_binary() const;
@@ -843,7 +902,7 @@ class SmartObject FINAL {
* @param Value Pointer to string to convert
* @return double
**/
- static double convert_string_to_double(const std::string* Value);
+ static double convert_string_to_double(const custom_str::CustomString* Value);
/**
* @brief Converts string to int64_t
@@ -851,7 +910,8 @@ class SmartObject FINAL {
* @param Value Pointer to string to convert
* @return int64_t int64_t
**/
- static uint64_t convert_string_to_integer(const std::string* Value);
+ static uint64_t convert_string_to_integer(
+ const custom_str::CustomString* Value);
/**
* @brief Converts double value to string
@@ -901,7 +961,7 @@ class SmartObject FINAL {
bool bool_value;
char char_value;
int64_t int_value;
- std::string* str_value;
+ custom_str::CustomString* str_value;
SmartArray* array_value;
SmartMap* map_value;
SmartBinary* binary_value;
diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h
index dbcfcbf9f9..7fad8491a5 100644
--- a/src/components/smart_objects/include/smart_objects/string_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h
@@ -55,10 +55,12 @@ class CStringSchemaItem : public CDefaultSchemaItem<std::string> {
* @return Shared pointer to a new schema item.
**/
static utils::SharedPtr<CStringSchemaItem> create(
- const TSchemaItemParameter<size_t>& MinLength = TSchemaItemParameter<size_t>(),
- const TSchemaItemParameter<size_t>& MaxLength = TSchemaItemParameter<size_t>(),
- const TSchemaItemParameter<std::string>& DefaultValue =
- TSchemaItemParameter<std::string>());
+ const TSchemaItemParameter<size_t>& MinLength =
+ TSchemaItemParameter<size_t>(),
+ const TSchemaItemParameter<size_t>& MaxLength =
+ TSchemaItemParameter<size_t>(),
+ const TSchemaItemParameter<std::string>& DefaultValue =
+ TSchemaItemParameter<std::string>());
/**
* @brief Validate smart object.
* @param Object Object to validate.