Skip to content

Commit d9bce9c

Browse files
authored
Add support of sequences of maps (#152)
* Refs #18687. Add support of sequences of maps Signed-off-by: Ricardo González Moreno <[email protected]> * Refs #18687. Add doxygen Signed-off-by: Ricardo González Moreno <[email protected]> --------- Signed-off-by: Ricardo González Moreno <[email protected]>
1 parent b50069b commit d9bce9c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

include/fastcdr/Cdr.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,25 @@ class Cdr_DllAPI Cdr
18961896
return *this;
18971897
}
18981898

1899+
/*!
1900+
* @brief This function template serializes an array of maps of objects.
1901+
* @param map_t The array of maps of objects that will be serialized in the buffer.
1902+
* @param numElements Number of the elements in the array.
1903+
* @return Reference to the eprosima::fastcdr::Cdr object.
1904+
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
1905+
*/
1906+
template<class _K, class _T>
1907+
Cdr& serializeArray(
1908+
const std::map<_K, _T>* map_t,
1909+
size_t numElements)
1910+
{
1911+
for (size_t count = 0; count < numElements; ++count)
1912+
{
1913+
serialize(map_t[count]);
1914+
}
1915+
return *this;
1916+
}
1917+
18991918
/*!
19001919
* @brief This function template serializes an array of non-basic objects.
19011920
* @param type_t The array of objects that will be serialized in the buffer.
@@ -3184,6 +3203,25 @@ class Cdr_DllAPI Cdr
31843203
return *this;
31853204
}
31863205

3206+
/*!
3207+
* @brief This function deserializes an array of maps of objects.
3208+
* @param map_t The variable that will store the array of maps of objects read from the buffer.
3209+
* @param numElements Number of the elements in the array.
3210+
* @return Reference to the eprosima::fastcdr::Cdr object.
3211+
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
3212+
*/
3213+
template<class _K, class _T>
3214+
Cdr& deserializeArray(
3215+
std::map<_K, _T>* map_t,
3216+
size_t numElements)
3217+
{
3218+
for (size_t count = 0; count < numElements; ++count)
3219+
{
3220+
deserialize(map_t[count]);
3221+
}
3222+
return *this;
3223+
}
3224+
31873225
/*!
31883226
* @brief This function template deserializes an array of non-basic objects.
31893227
* @param type_t The variable that will store the array of objects read from the buffer.

0 commit comments

Comments
 (0)