summaryrefslogtreecommitdiff
path: root/src/components/smart_objects/include/smart_objects/smart_object.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/smart_objects/include/smart_objects/smart_object.h')
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_object.h132
1 files changed, 96 insertions, 36 deletions
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;