Loading ccsrc/Protocols/Json/json_codec_factory_mec021.hh 0 → 100644 +46 −0 Original line number Diff line number Diff line /*! * \file json_codec_factory_mec021.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec021.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec021 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec021: public codec_factory { static json_codec_factory_mec021 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec021 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec021() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec021", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec021(); }; }; // End of class json_codec_factory_mec021 ccsrc/Protocols/Json/json_codec_factory_mec029.hh 0 → 100644 +46 −0 Original line number Diff line number Diff line /*! * \file json_codec_factory_mec029.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec029.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec029 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec029: public codec_factory { static json_codec_factory_mec029 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec029 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec029() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec029", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec029(); }; }; // End of class json_codec_factory_mec029 ccsrc/Protocols/Json/json_codec_mec012.cc +0 −4 Original line number Diff line number Diff line Loading @@ -98,10 +98,6 @@ int json_codec_mec012::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo RnisAPI__TypesAndValues::PlmnInfos plmn_infos; plmn_infos.decode(RnisAPI__TypesAndValues::PlmnInfos_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.plmnInfos() = plmn_infos; } else { return json_codec::decode(p_data, msg, p_params); } Loading ccsrc/Protocols/Json/json_codec_mec013.cc +19 −11 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::NotificationSubscriptionList notification_subscription_list; notification_subscription_list.decode(LocationAPI__TypesAndValues::NotificationSubscriptionList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.notificationSubscriptionList() = notification_subscription_list; } else if (it->second.find("\"userLocationEventSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserLocationEventSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -121,7 +121,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationEventSubscription user_location_event_subscription; user_location_event_subscription.decode(LocationAPI__TypesAndValues::UserLocationEventSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationEventSubscription() = user_location_event_subscription; } else if (it->second.find("\"userLocationEventNotification\"") != std::string::npos) { } else if (it->second.find("\"UserLocationEventNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -129,7 +129,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationEventNotification user_location_event_notification; user_location_event_notification.decode(LocationAPI__TypesAndValues::UserLocationEventNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationEventNotification() = user_location_event_notification; } else if (it->second.find("\"userLocationPeriodicSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserLocationPeriodicSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -137,7 +137,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationPeriodicSubscription user_location_periodic_subscription; user_location_periodic_subscription.decode(LocationAPI__TypesAndValues::UserLocationPeriodicSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationPeriodicSubscription() = user_location_periodic_subscription; } else if (it->second.find("\"userLocationPeriodicNotification\"") != std::string::npos) { } else if (it->second.find("\"UserLocationPeriodicNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -145,7 +145,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationPeriodicNotification user_location_periodic_notification; user_location_periodic_notification.decode(LocationAPI__TypesAndValues::UserLocationPeriodicNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationPeriodicNotification() = user_location_periodic_notification; } else if (it->second.find("\"zoneStatusSubscription\"") != std::string::npos) { } else if (it->second.find("\"ZoneStatusSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -153,7 +153,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneStatusSubscription zone_status_subscription; zone_status_subscription.decode(LocationAPI__TypesAndValues::ZoneStatusSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneStatusSubscription() = zone_status_subscription; } else if (it->second.find("\"zoneStatusNotification\"") != std::string::npos) { } else if (it->second.find("\"ZoneStatusNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -161,7 +161,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneStatusNotification zone_status_notification; zone_status_notification.decode(LocationAPI__TypesAndValues::ZoneStatusNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneStatusNotification() = zone_status_notification; } else if (it->second.find("\"zoneLocationEventSubscription\"") != std::string::npos) { } else if (it->second.find("\"ZoneLocationEventSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -169,7 +169,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneLocationEventSubscription zone_location_event_subscription; zone_location_event_subscription.decode(LocationAPI__TypesAndValues::ZoneLocationEventSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneLocationEventSubscription() = zone_location_event_subscription; } else if (it->second.find("\"zoneLocationEventNotification\"") != std::string::npos) { } else if (it->second.find("\"ZoneLocationEventNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -177,7 +177,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneLocationEventNotification zone_location_event_notification; zone_location_event_notification.decode(LocationAPI__TypesAndValues::ZoneLocationEventNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneLocationEventNotification() = zone_location_event_notification; } else if (it->second.find("\"userAreaSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserAreaSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -185,7 +185,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserAreaSubscription user_area_subscription; user_area_subscription.decode(LocationAPI__TypesAndValues::UserAreaSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userAreaSubscription() = user_area_subscription; } else if (it->second.find("\"userAreaNotification\"") != std::string::npos) { } else if (it->second.find("\"UserAreaNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -193,7 +193,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserAreaNotification user_area_notification; user_area_notification.decode(LocationAPI__TypesAndValues::UserAreaNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userAreaNotification() = user_area_notification; } else if (it->second.find("\"userDistanceSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserDistanceSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -209,6 +209,14 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserDistanceNotification user_distance_notification; user_distance_notification.decode(LocationAPI__TypesAndValues::UserDistanceNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userDistanceNotification() = user_distance_notification; } else if (it->second.find("\"TestNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); LocationAPI__TypesAndValues::TestNotification test_notification; test_notification.decode(LocationAPI__TypesAndValues::TestNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.testNotification() = test_notification; } else if (it->second.find("\"accessPointId\"") != std::string::npos) { if (it->second.find("\"address\"") != std::string::npos) { LocationAPI__TypesAndValues::UserInfo user_info; Loading ccsrc/Protocols/Json/json_codec_mec021.cc 0 → 100644 +84 −0 Original line number Diff line number Diff line #include <stdexcept> #include <regex> #include <string> #include "json_codec_factory_mec021.hh" #include "loggers.hh" #include "LibHttp_JsonMessageBodyTypes.hh" int json_codec_mec021::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& msg, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> json_codec_mec021::encode: ", (const Base_Type&)msg); TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_registrationInfo)) { const ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo& registration_info = msg.registrationInfo(); registration_info.encode(ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else { return json_codec::encode(msg, data); } loggers::get_instance().log("<<< json_codec_mec021::encode"); return 0; } int json_codec_mec021::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody& msg, params* p_params) { loggers::get_instance().log_msg(">>> json_codec_mec021::decode: p_data=", p_data); // Sanity checks params::const_iterator it; if (p_params == nullptr) { loggers::get_instance().warning("json_codec_mec021::decode: Failed to access p_params (null pointer)"); return -1; // TODO Use p_data instead of return -1 } else { it = p_params->find("decode_str"); if (it == p_params->cend()) { loggers::get_instance().warning("json_codec_mec021::decode: Failed to access p_params item (decode_str)"); return -1; // TODO Use p_data instead of return -1 } loggers::get_instance().log("json_codec_mec021::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str()); } // Remove data structure name (if present) ... std::string str; if ((it->second[0] != '[') && (it->second[0] != '{')) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec021::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"appMobilityServiceId\"") != std::string::npos) { if (it->second[0] == '[') { ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfos registration_infos; TTCN_Buffer decoding_buffer_(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); registration_infos.decode(ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfos_descr_, decoding_buffer_, TTCN_EncDec::CT_JSON); msg.registrationInfos() = registration_infos; } else { ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo registration_info; TTCN_Buffer decoding_buffer_(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); registration_info.decode(ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo_descr_, decoding_buffer_, TTCN_EncDec::CT_JSON); msg.registrationInfo() = registration_info; } } else { return json_codec::decode(p_data, msg, p_params); } loggers::get_instance().log_msg("<<< json_codec_mec021::decode: ", (const Base_Type&)msg); return 0; } json_codec_factory_mec021 json_codec_factory_mec021::_f; Loading
ccsrc/Protocols/Json/json_codec_factory_mec021.hh 0 → 100644 +46 −0 Original line number Diff line number Diff line /*! * \file json_codec_factory_mec021.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec021.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec021 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec021: public codec_factory { static json_codec_factory_mec021 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec021 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec021() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec021", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec021(); }; }; // End of class json_codec_factory_mec021
ccsrc/Protocols/Json/json_codec_factory_mec029.hh 0 → 100644 +46 −0 Original line number Diff line number Diff line /*! * \file json_codec_factory_mec029.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec029.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec029 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec029: public codec_factory { static json_codec_factory_mec029 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec029 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec029() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec029", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec029(); }; }; // End of class json_codec_factory_mec029
ccsrc/Protocols/Json/json_codec_mec012.cc +0 −4 Original line number Diff line number Diff line Loading @@ -98,10 +98,6 @@ int json_codec_mec012::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo RnisAPI__TypesAndValues::PlmnInfos plmn_infos; plmn_infos.decode(RnisAPI__TypesAndValues::PlmnInfos_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.plmnInfos() = plmn_infos; } else { return json_codec::decode(p_data, msg, p_params); } Loading
ccsrc/Protocols/Json/json_codec_mec013.cc +19 −11 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::NotificationSubscriptionList notification_subscription_list; notification_subscription_list.decode(LocationAPI__TypesAndValues::NotificationSubscriptionList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.notificationSubscriptionList() = notification_subscription_list; } else if (it->second.find("\"userLocationEventSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserLocationEventSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -121,7 +121,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationEventSubscription user_location_event_subscription; user_location_event_subscription.decode(LocationAPI__TypesAndValues::UserLocationEventSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationEventSubscription() = user_location_event_subscription; } else if (it->second.find("\"userLocationEventNotification\"") != std::string::npos) { } else if (it->second.find("\"UserLocationEventNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -129,7 +129,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationEventNotification user_location_event_notification; user_location_event_notification.decode(LocationAPI__TypesAndValues::UserLocationEventNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationEventNotification() = user_location_event_notification; } else if (it->second.find("\"userLocationPeriodicSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserLocationPeriodicSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -137,7 +137,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationPeriodicSubscription user_location_periodic_subscription; user_location_periodic_subscription.decode(LocationAPI__TypesAndValues::UserLocationPeriodicSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationPeriodicSubscription() = user_location_periodic_subscription; } else if (it->second.find("\"userLocationPeriodicNotification\"") != std::string::npos) { } else if (it->second.find("\"UserLocationPeriodicNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -145,7 +145,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserLocationPeriodicNotification user_location_periodic_notification; user_location_periodic_notification.decode(LocationAPI__TypesAndValues::UserLocationPeriodicNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userLocationPeriodicNotification() = user_location_periodic_notification; } else if (it->second.find("\"zoneStatusSubscription\"") != std::string::npos) { } else if (it->second.find("\"ZoneStatusSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -153,7 +153,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneStatusSubscription zone_status_subscription; zone_status_subscription.decode(LocationAPI__TypesAndValues::ZoneStatusSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneStatusSubscription() = zone_status_subscription; } else if (it->second.find("\"zoneStatusNotification\"") != std::string::npos) { } else if (it->second.find("\"ZoneStatusNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -161,7 +161,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneStatusNotification zone_status_notification; zone_status_notification.decode(LocationAPI__TypesAndValues::ZoneStatusNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneStatusNotification() = zone_status_notification; } else if (it->second.find("\"zoneLocationEventSubscription\"") != std::string::npos) { } else if (it->second.find("\"ZoneLocationEventSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -169,7 +169,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneLocationEventSubscription zone_location_event_subscription; zone_location_event_subscription.decode(LocationAPI__TypesAndValues::ZoneLocationEventSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneLocationEventSubscription() = zone_location_event_subscription; } else if (it->second.find("\"zoneLocationEventNotification\"") != std::string::npos) { } else if (it->second.find("\"ZoneLocationEventNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -177,7 +177,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::ZoneLocationEventNotification zone_location_event_notification; zone_location_event_notification.decode(LocationAPI__TypesAndValues::ZoneLocationEventNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.zoneLocationEventNotification() = zone_location_event_notification; } else if (it->second.find("\"userAreaSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserAreaSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -185,7 +185,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserAreaSubscription user_area_subscription; user_area_subscription.decode(LocationAPI__TypesAndValues::UserAreaSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userAreaSubscription() = user_area_subscription; } else if (it->second.find("\"userAreaNotification\"") != std::string::npos) { } else if (it->second.find("\"UserAreaNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -193,7 +193,7 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserAreaNotification user_area_notification; user_area_notification.decode(LocationAPI__TypesAndValues::UserAreaNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userAreaNotification() = user_area_notification; } else if (it->second.find("\"userDistanceSubscription\"") != std::string::npos) { } else if (it->second.find("\"UserDistanceSubscription\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); Loading @@ -209,6 +209,14 @@ int json_codec_mec013::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo LocationAPI__TypesAndValues::UserDistanceNotification user_distance_notification; user_distance_notification.decode(LocationAPI__TypesAndValues::UserDistanceNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.userDistanceNotification() = user_distance_notification; } else if (it->second.find("\"TestNotification\"") != std::string::npos) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); LocationAPI__TypesAndValues::TestNotification test_notification; test_notification.decode(LocationAPI__TypesAndValues::TestNotification_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.testNotification() = test_notification; } else if (it->second.find("\"accessPointId\"") != std::string::npos) { if (it->second.find("\"address\"") != std::string::npos) { LocationAPI__TypesAndValues::UserInfo user_info; Loading
ccsrc/Protocols/Json/json_codec_mec021.cc 0 → 100644 +84 −0 Original line number Diff line number Diff line #include <stdexcept> #include <regex> #include <string> #include "json_codec_factory_mec021.hh" #include "loggers.hh" #include "LibHttp_JsonMessageBodyTypes.hh" int json_codec_mec021::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& msg, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> json_codec_mec021::encode: ", (const Base_Type&)msg); TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_registrationInfo)) { const ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo& registration_info = msg.registrationInfo(); registration_info.encode(ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else { return json_codec::encode(msg, data); } loggers::get_instance().log("<<< json_codec_mec021::encode"); return 0; } int json_codec_mec021::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody& msg, params* p_params) { loggers::get_instance().log_msg(">>> json_codec_mec021::decode: p_data=", p_data); // Sanity checks params::const_iterator it; if (p_params == nullptr) { loggers::get_instance().warning("json_codec_mec021::decode: Failed to access p_params (null pointer)"); return -1; // TODO Use p_data instead of return -1 } else { it = p_params->find("decode_str"); if (it == p_params->cend()) { loggers::get_instance().warning("json_codec_mec021::decode: Failed to access p_params item (decode_str)"); return -1; // TODO Use p_data instead of return -1 } loggers::get_instance().log("json_codec_mec021::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str()); } // Remove data structure name (if present) ... std::string str; if ((it->second[0] != '[') && (it->second[0] != '{')) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec021::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"appMobilityServiceId\"") != std::string::npos) { if (it->second[0] == '[') { ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfos registration_infos; TTCN_Buffer decoding_buffer_(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); registration_infos.decode(ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfos_descr_, decoding_buffer_, TTCN_EncDec::CT_JSON); msg.registrationInfos() = registration_infos; } else { ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo registration_info; TTCN_Buffer decoding_buffer_(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); registration_info.decode(ApplicationMobilityServiceAPI__TypesAndValues::RegistrationInfo_descr_, decoding_buffer_, TTCN_EncDec::CT_JSON); msg.registrationInfo() = registration_info; } } else { return json_codec::decode(p_data, msg, p_params); } loggers::get_instance().log_msg("<<< json_codec_mec021::decode: ", (const Base_Type&)msg); return 0; } json_codec_factory_mec021 json_codec_factory_mec021::_f;