summaryrefslogtreecommitdiff
path: root/src/components/formatters
diff options
context:
space:
mode:
authorVeronica Veremjova <VVeremjova@luxoft.com>2015-12-28 14:47:31 +0200
committervveremeva <vveremjova@luxoft.com>2016-01-15 09:21:22 +0200
commit69f632fc2c57d9abbab5e4550db58eb67f8f5574 (patch)
treed6870729f99c96f1d94c0d4ea1728a9714c7d491 /src/components/formatters
parent5859c8f69ee80c3322b3fa980aff432fee8d80b5 (diff)
downloadsdl_core-69f632fc2c57d9abbab5e4550db58eb67f8f5574.tar.gz
Fix converting upperbound values
Convert recieved integer values into 64bit instead of 32bit Replaced returning integer values from Smart Object by 64bit numbers Added functions for converting int64 to long long int and back Closes-Bug: APPLINK-12369
Diffstat (limited to 'src/components/formatters')
-rw-r--r--src/components/formatters/CMakeLists.txt1
-rw-r--r--src/components/formatters/src/CFormatterJsonBase.cc10
-rw-r--r--src/components/formatters/src/CFormatterJsonSDLRPCv1.cc66
-rw-r--r--src/components/formatters/src/formatter_json_rpc.cc7
4 files changed, 45 insertions, 39 deletions
diff --git a/src/components/formatters/CMakeLists.txt b/src/components/formatters/CMakeLists.txt
index ea089955dc..1858342ff3 100644
--- a/src/components/formatters/CMakeLists.txt
+++ b/src/components/formatters/CMakeLists.txt
@@ -38,6 +38,7 @@ include_directories (
${JSONCPP_INCLUDE_DIRECTORY}
${MESSAGE_BROKER_INCLUDE_DIRECTORY}
${COMPONENTS_DIR}/smart_objects/include
+ ${COMPONENTS_DIR}/utils/include
)
set (SOURCES
diff --git a/src/components/formatters/src/CFormatterJsonBase.cc b/src/components/formatters/src/CFormatterJsonBase.cc
index 08773bc1dd..8c2a70f1d4 100644
--- a/src/components/formatters/src/CFormatterJsonBase.cc
+++ b/src/components/formatters/src/CFormatterJsonBase.cc
@@ -32,8 +32,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include "json/json.h"
-
#include "formatters/CFormatterJsonBase.h"
+#include "utils/convert_utils.h"
void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::jsonValueToObj(
const Json::Value& value,
@@ -56,9 +56,9 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::jsonValue
jsonValueToObj(value[i], obj[i]);
}
} else if (value.type() == Json::intValue) {
- obj = value.asInt();
+ obj = utils::ConvertLongLongIntToInt64(value.asInt64());
} else if (value.type() == Json::uintValue) {
- obj = value.asUInt();
+ obj = utils::ConvertLongLongUIntToUInt64(value.asUInt64());
} else if (value.type() == Json::realValue) {
obj = value.asDouble();
} else if (value.type() == Json::booleanValue) {
@@ -104,10 +104,10 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::objToJson
item = obj.asBool();
} else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Integer
== obj.getType()) {
- item = obj.asInt();
+ item = utils::ConvertInt64ToLongLongInt(obj.asInt());
} else if (NsSmartDeviceLink::NsSmartObjects::SmartType_UInteger
== obj.getType()) {
- item = obj.asUInt();
+ item = utils::ConvertUInt64ToLongLongUInt(obj.asUInt());
} else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Double
== obj.getType()) {
item = obj.asDouble();
diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
index 1f29a20d7e..f490b85ea6 100644
--- a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
+++ b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
@@ -1,34 +1,38 @@
-// Copyright (c) 2013, Ford Motor Company
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided with the
-// distribution.
-//
-// Neither the name of the Ford Motor Company nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
+/*
+ * Copyright (c) 2015, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "formatters/CFormatterJsonSDLRPCv1.h"
#include "formatters/meta_formatter.h"
+#include "utils/convert_utils.h"
namespace strings = NsSmartDeviceLink::NsJSONHandler::strings;
namespace smart_objects_ns = NsSmartDeviceLink::NsSmartObjects;
@@ -96,8 +100,8 @@ bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj,
root[type][S_PARAMETERS] = params;
if (formattedObj[strings::S_PARAMS].keyExists(strings::S_CORRELATION_ID)) {
- root[type][S_CORRELATION_ID] =
- formattedObj[strings::S_PARAMS][strings::S_CORRELATION_ID].asInt();
+ root[type][S_CORRELATION_ID] = utils::ConvertInt64ToLongLongInt(
+ formattedObj[strings::S_PARAMS][strings::S_CORRELATION_ID].asInt());
}
root[type][S_NAME] = formattedObj[strings::S_PARAMS][strings::S_FUNCTION_ID]
diff --git a/src/components/formatters/src/formatter_json_rpc.cc b/src/components/formatters/src/formatter_json_rpc.cc
index 012962bbb2..6c6e47069f 100644
--- a/src/components/formatters/src/formatter_json_rpc.cc
+++ b/src/components/formatters/src/formatter_json_rpc.cc
@@ -33,6 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
#include "formatters/formatter_json_rpc.h"
+#include "utils/convert_utils.h"
namespace NsSmartDeviceLink {
namespace NsJSONHandler {
@@ -118,7 +119,7 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
if (NsSmartObjects::SmartType_Integer != code.getType()) {
result = false;
} else {
- root[kResult][kCode] = code.asInt();
+ root[kResult][kCode] = utils::ConvertInt64ToLongLongInt(code.asInt());
}
}
} else if (kNotification == message_type) {
@@ -134,7 +135,7 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
if (NsSmartObjects::SmartType_Integer != code.getType()) {
result = false;
} else {
- root[kError][kCode] = code.asInt();
+ root[kError][kCode] = utils::ConvertInt64ToLongLongInt(code.asInt());
}
}
}
@@ -174,7 +175,7 @@ bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject &params,
strings::S_CORRELATION_ID);
if (NsSmartObjects::SmartType_Integer == id.getType()) {
- id_container[kId] = id.asUInt();
+ id_container[kId] = utils::ConvertUInt64ToLongLongUInt(id.asUInt());
result = true;
}
}