summaryrefslogtreecommitdiff
path: root/src/components/formatters
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/formatters')
-rw-r--r--src/components/formatters/CMakeLists.txt1
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h10
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h10
-rw-r--r--src/components/formatters/include/formatters/CSmartFactory.h8
-rw-r--r--src/components/formatters/include/formatters/formatter_json_rpc.h6
-rw-r--r--src/components/formatters/src/CFormatterJsonSDLRPCv1.cc12
-rw-r--r--src/components/formatters/src/CFormatterJsonSDLRPCv2.cc12
-rw-r--r--src/components/formatters/src/formatter_json_rpc.cc6
8 files changed, 45 insertions, 20 deletions
diff --git a/src/components/formatters/CMakeLists.txt b/src/components/formatters/CMakeLists.txt
index ffd6f333e5..86483929e9 100644
--- a/src/components/formatters/CMakeLists.txt
+++ b/src/components/formatters/CMakeLists.txt
@@ -38,6 +38,7 @@ include_directories (
${MESSAGE_BROKER_INCLUDE_DIRECTORY}
${COMPONENTS_DIR}/smart_objects/include
${COMPONENTS_DIR}/utils/include
+ ${BOOST_INCLUDE_DIR}
)
set(PATHS
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
index d2fdf87957..cd3e50212a 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
@@ -126,11 +126,14 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase {
*
* @param obj input SmartObject
* @param outStr resulting JSON string
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ *parameters
* @return true if success, false otherwise
*/
static bool toString(
const ns_smart_device_link::ns_smart_objects::SmartObject& obj,
- std::string& outStr);
+ std::string& outStr,
+ const bool remove_unknown_parameters = true);
/**
* @brief Creates a SmartObject from a JSON string.
@@ -151,12 +154,15 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase {
* @param schema Smart schema which describes 'fake' smart object to be
*formatted
* @param outStr Resulting JSON string
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ *parameters
* @return formatting error code
*/
static tMetaFormatterErrorCode MetaFormatToString(
const ns_smart_device_link::ns_smart_objects::SmartObject& object,
const ns_smart_device_link::ns_smart_objects::CSmartSchema& schema,
- std::string& outStr);
+ std::string& outStr,
+ const bool remove_unknown_parameters = true);
};
// ----------------------------------------------------------------------------
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
index e248954552..f86e4e51cb 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
@@ -73,11 +73,14 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
*
* @param obj input SmartObject
* @param outStr resulting JSON string
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ *parameters
* @return true if success, false otherwise
*/
static bool toString(
const ns_smart_device_link::ns_smart_objects::SmartObject& obj,
- std::string& outStr);
+ std::string& outStr,
+ const bool remove_unknown_parameters = true);
/**
* @brief Creates a SmartObject from a JSON string.
@@ -128,12 +131,15 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
* @param schema Smart schema which describes 'fake' smart object to be
*formatted
* @param outStr Resulting JSON string
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ *parameters
* @return formatting error code
*/
static tMetaFormatterErrorCode MetaFormatToString(
const ns_smart_device_link::ns_smart_objects::SmartObject& object,
const ns_smart_device_link::ns_smart_objects::CSmartSchema& schema,
- std::string& outStr);
+ std::string& outStr,
+ const bool remove_unknown_parameters = true);
};
template <typename FunctionId, typename MessageType>
diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h
index a48eab2a6b..f3c3fbe207 100644
--- a/src/components/formatters/include/formatters/CSmartFactory.h
+++ b/src/components/formatters/include/formatters/CSmartFactory.h
@@ -148,14 +148,14 @@ class CSmartFactory {
*
* @param object SmartObject to attach schema for.
*
- * @param RemoveFakeParameters contains true if need
+ * @param remove_unknown_parameters contains true if need
* to remove fake parameters from smart object otherwise contains false.
*
* @return True if operation was successful or false otherwise.
*/
bool attachSchema(
ns_smart_device_link::ns_smart_objects::SmartObject& object,
- const bool RemoveFakeParameters,
+ const bool remove_unknown_parameters,
const utils::SemanticVersion& MessageVersion = utils::SemanticVersion());
/**
@@ -276,7 +276,7 @@ CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CSmartFactory(
template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(
ns_smart_device_link::ns_smart_objects::SmartObject& object,
- const bool RemoveFakeParameters,
+ const bool remove_unknown_parameters,
const utils::SemanticVersion& MessageVersion) {
if (false == object.keyExists(strings::S_PARAMS))
return false;
@@ -305,7 +305,7 @@ bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(
object.setSchema(schemaIterator->second);
schemaIterator->second.applySchema(
- object, RemoveFakeParameters, MessageVersion);
+ object, remove_unknown_parameters, MessageVersion);
return true;
}
diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h
index 842e176976..3503767988 100644
--- a/src/components/formatters/include/formatters/formatter_json_rpc.h
+++ b/src/components/formatters/include/formatters/formatter_json_rpc.h
@@ -105,11 +105,13 @@ class FormatterJsonRpc : public CFormatterJsonBase {
*
* @param obj Input SmartObject.
* @param out_str Resulting JSON string.
- *
+ * @param remove_unknown_parameters contains true if need to remove unknown
+ *parameters
* @return true if success, false otherwise.
*/
static bool ToString(const ns_smart_objects::SmartObject& obj,
- std::string& out_str);
+ std::string& out_str,
+ const bool remove_unknown_parameters = true);
/**
* @brief Creates a SmartObject from a JSON string.
diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
index 121fd43131..a5c3d1a103 100644
--- a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
+++ b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
@@ -85,7 +85,8 @@ const std::string CFormatterJsonSDLRPCv1::getMessageType(
// ----------------------------------------------------------------------------
bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj,
- std::string& outStr) {
+ std::string& outStr,
+ const bool remove_unknown_parameters) {
bool result = false;
try {
Json::Value root(Json::objectValue);
@@ -93,7 +94,8 @@ bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj,
smart_objects_ns::SmartObject formattedObj(obj);
formattedObj.getSchema().unapplySchema(
- formattedObj); // converts enums(as int32_t) to strings
+ formattedObj,
+ remove_unknown_parameters); // converts enums(as int32_t) to strings
objToJsonValue(formattedObj.getElement(strings::S_MSG_PARAMS), params);
@@ -125,7 +127,8 @@ CFormatterJsonSDLRPCv1::tMetaFormatterErrorCode
CFormatterJsonSDLRPCv1::MetaFormatToString(
const smart_objects_ns::SmartObject& object,
const smart_objects_ns::CSmartSchema& schema,
- std::string& outStr) {
+ std::string& outStr,
+ const bool remove_unknown_parameters) {
meta_formatter_error_code::tMetaFormatterErrorCode result_code =
meta_formatter_error_code::kErrorOk;
@@ -156,7 +159,8 @@ CFormatterJsonSDLRPCv1::MetaFormatToString(
result_code |= meta_formatter_error_code::kErrorSchemaIsNotFunction;
}
- CFormatterJsonSDLRPCv1::toString(tmp_object, outStr);
+ CFormatterJsonSDLRPCv1::toString(
+ tmp_object, outStr, remove_unknown_parameters);
return result_code;
}
diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc
index ffbb644cc6..a582b52462 100644
--- a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc
+++ b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc
@@ -41,14 +41,16 @@ namespace formatters {
// ----------------------------------------------------------------------------
bool CFormatterJsonSDLRPCv2::toString(const smart_objects_ns::SmartObject& obj,
- std::string& outStr) {
+ std::string& outStr,
+ const bool remove_unknown_parameters) {
bool result = true;
try {
Json::Value root(Json::objectValue);
smart_objects_ns::SmartObject formattedObj(obj);
formattedObj.getSchema().unapplySchema(
- formattedObj); // converts enums(as int32_t) to strings
+ formattedObj,
+ remove_unknown_parameters); // converts enums(as int32_t) to strings
objToJsonValue(formattedObj.getElement(strings::S_MSG_PARAMS), root);
@@ -68,7 +70,8 @@ CFormatterJsonSDLRPCv2::tMetaFormatterErrorCode
CFormatterJsonSDLRPCv2::MetaFormatToString(
const smart_objects_ns::SmartObject& object,
const smart_objects_ns::CSmartSchema& schema,
- std::string& outStr) {
+ std::string& outStr,
+ const bool remove_unknown_parameters) {
meta_formatter_error_code::tMetaFormatterErrorCode result_code =
meta_formatter_error_code::kErrorOk;
@@ -99,7 +102,8 @@ CFormatterJsonSDLRPCv2::MetaFormatToString(
result_code |= meta_formatter_error_code::kErrorSchemaIsNotFunction;
}
- CFormatterJsonSDLRPCv2::toString(tmp_object, outStr);
+ CFormatterJsonSDLRPCv2::toString(
+ tmp_object, outStr, remove_unknown_parameters);
return result_code;
}
diff --git a/src/components/formatters/src/formatter_json_rpc.cc b/src/components/formatters/src/formatter_json_rpc.cc
index d50d04d0e9..07d45d5855 100644
--- a/src/components/formatters/src/formatter_json_rpc.cc
+++ b/src/components/formatters/src/formatter_json_rpc.cc
@@ -57,7 +57,8 @@ const char* FormatterJsonRpc::kData = "data";
const char* FormatterJsonRpc::kMessage = "message";
bool FormatterJsonRpc::ToString(const ns_smart_objects::SmartObject& obj,
- std::string& out_str) {
+ std::string& out_str,
+ const bool remove_unknown_parameters) {
bool result = true;
try {
Json::Value root(Json::objectValue);
@@ -66,7 +67,8 @@ bool FormatterJsonRpc::ToString(const ns_smart_objects::SmartObject& obj,
ns_smart_objects::SmartObject formatted_object(obj);
Json::Value msg_params_json(Json::objectValue);
- formatted_object.getSchema().unapplySchema(formatted_object);
+ formatted_object.getSchema().unapplySchema(formatted_object,
+ remove_unknown_parameters);
bool is_message_params = formatted_object.keyExists(strings::S_MSG_PARAMS);
bool empty_message_params = true;