Skip to content

Commit bc67cf7

Browse files
juanlofer-eprosimatempate
andauthored
DynamicType to IDL serializer (#4787)
* Add tree container Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com> * DynamicType to IDL serializer Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com> * Make methods return RETCODES and noexcept Signed-off-by: tempate <danieldiaz@eprosima.com> * Move TreeNodeType methods to a different file Signed-off-by: tempate <danieldiaz@eprosima.com> * Check ReturnCodes from the DynamicTypes API Signed-off-by: tempate <danieldiaz@eprosima.com> * Replace ostream with string Signed-off-by: tempate <danieldiaz@eprosima.com> * Cover unbounded sequence scenario Signed-off-by: tempate <danieldiaz@eprosima.com> * Support TK_INT8 & TK_UINT8 Signed-off-by: tempate <danieldiaz@eprosima.com> * Include safety checks Signed-off-by: tempate <danieldiaz@eprosima.com> * Add DOCSTRING descriptions Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Dynamic Types to IDL Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests fixes - unbounded sequence & array length Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests fixes - TK_ENUM Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests fixes - TK_UNION Signed-off-by: tempate <danieldiaz@eprosima.com> * Update versions.md Signed-off-by: tempate <danieldiaz@eprosima.com> * Move dyn_type_tree to type_conversion Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Tree Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests fixes - Tree depth Signed-off-by: tempate <danieldiaz@eprosima.com> * Rename Tree to TreeNode Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Refactor Dynamic Types to IDL Signed-off-by: tempate <danieldiaz@eprosima.com> * Support TK_BITSET Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - TK_BITSET Signed-off-by: tempate <danieldiaz@eprosima.com> * Support TK_BITMASK Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - TK_BITMASK Signed-off-by: tempate <danieldiaz@eprosima.com> * Support TK_ALIAS Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - TK_ALIAS Signed-off-by: tempate <danieldiaz@eprosima.com> * Support Annotation @key Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Annotation @key Signed-off-by: tempate <danieldiaz@eprosima.com> * Rearrange & sort methods Signed-off-by: tempate <danieldiaz@eprosima.com> * Support Annotation @extensibility Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Annotation @extensibility Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Nested Struct Signed-off-by: tempate <danieldiaz@eprosima.com> * Support inheritance in TK_STRUCT Signed-off-by: tempate <danieldiaz@eprosima.com> * Tests - Inheritance in TK_STRUCT Signed-off-by: tempate <danieldiaz@eprosima.com> * Rebase fix Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Restructure the code & regenerate types Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Apply suggestions Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Refactor Tests Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Primitives test Signed-off-by: tempate <danieldiaz@eprosima.com> * Apply suggestions Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Apply suggestions Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Sort dependencies Signed-off-by: tempate <danieldiaz@eprosima.com> * Fix - Declaration of `bits` hides previous local declaration Signed-off-by: tempate <danieldiaz@eprosima.com> * Fix - Linking issues Signed-off-by: tempate <danieldiaz@eprosima.com> * Fix - Declaration of `info` hides member Signed-off-by: tempate <danieldiaz@eprosima.com> * Fix - to_upper Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Apply suggestions Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Apply JSON suggestions Signed-off-by: tempate <danieldiaz@eprosima.com> * Uncrustify Signed-off-by: tempate <danieldiaz@eprosima.com> * Review - Apply suggestions Signed-off-by: tempate <danieldiaz@eprosima.com> * Fix - default_type_kind may be used uninitialized Signed-off-by: tempate <danieldiaz@eprosima.com> * Fix - signed/unsigned mismatch Signed-off-by: tempate <danieldiaz@eprosima.com> --------- Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com> Signed-off-by: tempate <danieldiaz@eprosima.com> Co-authored-by: tempate <danieldiaz@eprosima.com>
1 parent 77768eb commit bc67cf7

122 files changed

Lines changed: 26839 additions & 36 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/fastdds/dds/xtypes/utils.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#define FASTDDS_DDS_XTYPES__UTILS_HPP
2121

2222
#include <iostream>
23+
#include <string>
2324

2425
#include <fastdds/dds/core/ReturnCode.hpp>
2526
#include <fastdds/dds/xtypes/dynamic_types/DynamicData.hpp>
27+
#include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>
2628
#include <fastdds/fastdds_dll.hpp>
2729

2830
namespace eprosima {
@@ -35,6 +37,17 @@ enum class DynamicDataJsonFormat
3537
EPROSIMA,
3638
};
3739

40+
/**
41+
* @brief Serializes a @ref DynamicType into its IDL representation.
42+
*
43+
* @param [in] dynamic_type The @ref DynamicType to serialize.
44+
* @param [in,out] output \c std::ostream reference containing the IDL representation.
45+
* @retval RETCODE_OK when serialization fully succeeds, and inner (member serialization) failing code otherwise.
46+
*/
47+
FASTDDS_EXPORTED_API ReturnCode_t idl_serialize(
48+
const DynamicType::_ref_type& dynamic_type,
49+
std::ostream& output) noexcept;
50+
3851
/*!
3952
* Serializes a @ref DynamicData into a JSON object, which is then dumped into an \c std::ostream.
4053
* @param[in] data @ref DynamicData reference to be serialized.

src/cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ set(${PROJECT_NAME}_source_files
104104
fastdds/xtypes/dynamic_types/TypeDescriptorImpl.cpp
105105
fastdds/xtypes/dynamic_types/VerbatimTextDescriptorImpl.cpp
106106
fastdds/xtypes/exception/Exception.cpp
107+
fastdds/xtypes/serializers/idl/dynamic_type_idl.cpp
107108
fastdds/xtypes/serializers/json/dynamic_data_json.cpp
108109
fastdds/xtypes/type_representation/dds_xtypes_typeobjectPubSubTypes.cxx
109110
fastdds/xtypes/type_representation/TypeObjectRegistry.cpp

src/cpp/fastdds/xtypes/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ target_sources(fastdds-xtypes-dynamic-types-impl INTERFACE
7878
dynamic_types/TypeDescriptorImpl.hpp
7979
dynamic_types/VerbatimTextDescriptorImpl.cpp
8080
dynamic_types/VerbatimTextDescriptorImpl.hpp
81+
serializers/idl/dynamic_type_idl.cpp
82+
serializers/idl/dynamic_type_idl.hpp
8183
serializers/json/dynamic_data_json.cpp
8284
serializers/json/dynamic_data_json.hpp
8385
utils.cpp

0 commit comments

Comments
 (0)