@@ -10,6 +10,48 @@ within distributed systems.
1010Serialization is a crucial process in data distribution services, as it converts complex data structures into a
1111format that can be easily transmitted and reconstructed across different platforms and programming environments.
1212
13+ .. _xtypes_serialization_utilities_idl :
14+
15+ Dynamic Type to IDL
16+ -------------------
17+
18+ The method |XTypesUtils-idl_serialize-api | serializes a |DynamicType-api | object to its IDL representation.
19+
20+ .. note ::
21+
22+ The conversion to IDL only supports the following :ref: `builtin annotations<builtin_annotations> `:
23+ :code: `@bit_bound `, :code: `@extensibility `, :code: `@key `, and :code: `@position `.
24+
25+ .. warning ::
26+
27+ The conversion to IDL of a :ref: `Bitset<xtypes_supportedtypes_bitset> ` with inheritance merges derived
28+ :ref: `Bitsets<xtypes_supportedtypes_bitset> ` with their base :ref: `Bitset<xtypes_supportedtypes_bitset> `.
29+
30+ .. warning ::
31+
32+ The conversion to IDL dismisses values explicitly set to their default value.
33+ For example, the default :code: `@bit_bound ` value of a :ref: `Bitmask<xtypes_supportedtypes_bitmask> ` is 32.
34+ If a user were to explicitly set the :code: `@bit_bound ` value of a
35+ :ref: `Bitmask<xtypes_supportedtypes_bitmask> ` to 32 and then serialize the |DynamicType-api | to IDL, the
36+ :code: `@bit_bound ` would not be included in the IDL.
37+
38+ .. _xtypes_serialization_utilities_idl_example :
39+
40+ Example: Convert a discovered type to IDL format
41+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
43+ The following example demonstrates how to use the |XTypesUtils-idl_serialize-api | method in Fast DDS to convert
44+ discovered types to IDL format.
45+ Each time the subscriber discovers a new |DataReader-api | or |DataWriter-api |, it uses the
46+ |DynamicTypeBuilderFactory-api | to build a |DynamicType-api | and serialize it to IDL format.
47+ Please refer to :ref: `use-case-remote-type-discovery-and-matching ` section for more details on how to implement
48+ remote type discovery.
49+
50+ .. literalinclude :: /../code/DDSCodeTester.cpp
51+ :language: c++
52+ :start-after: //!--DYNTYPE_IDL_SERIALIZATION
53+ :end-before: //!--
54+
1355DynamicData to JSON
1456--------------------
1557
@@ -40,7 +82,7 @@ Below is an example of the definition of primitive types in IDL:
4082 :start-after: //!--IDL_PRIMITIVES
4183 :end-before: //!--
4284
43- The previous |DynamicData-api | object corresponding to the type represented above
85+ A |DynamicData-api | object corresponding to the type represented above
4486would be serialized as follows:
4587
4688.. literalinclude :: /../code/json/Primitives.json
@@ -60,7 +102,7 @@ The following example shows the definition of string types in IDL:
60102 :start-after: //!--IDL_STRINGS
61103 :end-before: //!--
62104
63- The previous |DynamicData-api | object corresponding to the type represented above
105+ A |DynamicData-api | object corresponding to the type represented above
64106would be serialized as follows:
65107
66108.. literalinclude :: /../code/json/Strings.json
@@ -139,7 +181,7 @@ Below is an example of the definition of sequence types in IDL:
139181 :start-after: //!--IDL_SEQUENCES
140182 :end-before: //!--
141183
142- The previous |DynamicData-api | object corresponding to the type represented above
184+ A |DynamicData-api | object corresponding to the type represented above
143185would be serialized as follows:
144186
145187.. literalinclude :: /../code/json/Sequences.json
@@ -158,7 +200,7 @@ The following example shows the definition of array types in IDL:
158200 :start-after: //!--IDL_ARRAYS_JSON
159201 :end-before: //!--
160202
161- The previous |DynamicData-api | object corresponding to the type represented above
203+ A |DynamicData-api | object corresponding to the type represented above
162204would be serialized as follows:
163205
164206.. literalinclude :: /../code/json/Arrays.json
@@ -178,7 +220,7 @@ Below is an example of the definition of map types in IDL:
178220 :start-after: //!--IDL_MAPS
179221 :end-before: //!--
180222
181- The previous |DynamicData-api | object corresponding to the type represented above
223+ A |DynamicData-api | object corresponding to the type represented above
182224would be serialized as follows:
183225
184226.. literalinclude :: /../code/json/Maps.json
@@ -197,7 +239,7 @@ Here is an example of the definition of structure types in IDL:
197239 :start-after: //!--IDL_STRUCT
198240 :end-before: //!--
199241
200- The previous |DynamicData-api | object corresponding to the type represented above
242+ A |DynamicData-api | object corresponding to the type represented above
201243would be serialized as follows:
202244
203245.. literalinclude :: /../code/json/Structs.json
@@ -216,7 +258,7 @@ Below is an example of the definition of union types in IDL:
216258 :start-after: //!--IDL_UNION
217259 :end-before: //!--
218260
219- The previous |DynamicData-api | object corresponding to the type represented above
261+ A |DynamicData-api | object corresponding to the type represented above
220262would be serialized as follows:
221263
222264.. literalinclude :: /../code/json/Unions.json
@@ -235,13 +277,13 @@ Below is an example of the definition of bitset types in IDL:
235277 :start-after: //!--IDL_BITSET_JSON
236278 :end-before: //!--
237279
238- The previous |DynamicData-api | object corresponding to the type represented above
280+ A |DynamicData-api | object corresponding to the type represented above
239281would be serialized as follows:
240282
241283.. literalinclude :: /../code/json/Bitsets.json
242284 :language: json
243285
244- .. _ xtypes_serialization_utilities_example :
286+ .. _ xtypes_serialization_utilities_json_example :
245287
246288Example: Convert received data into JSON format
247289^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments