Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/reusable-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ jobs:
strict-bool:
- false
- true
disable-wstrings:
- false
include:
- cmake-build-type: 'RelWithDebInfo'
strict-bool: false
disable-wstrings: true

steps:
- name: Add ci-pending label if PR
if: ${{ github.event_name == 'pull_request' && inputs.add-label == true && matrix.strict-bool == false }}
if: ${{ github.event_name == 'pull_request' && inputs.add-label == true && matrix.strict-bool == false && matrix.disable-wstrings == false }}
uses: eProsima/eProsima-CI/external/add_labels@v0
with:
labels: ci-pending
Expand Down Expand Up @@ -131,7 +137,7 @@ jobs:
colcon_meta_file: ${{ github.workspace }}/src/fastcdr/.github/workflows/config/build.meta
colcon_build_args: ${{ inputs.colcon-args }}
colcon_build_args_default: --event-handlers=console_direct+
cmake_args: ${{ inputs.cmake-args }} ${{ matrix.strict-bool == true && '-DSTRICT_BOOL=ON' || '' }}
cmake_args: ${{ inputs.cmake-args }} ${{ matrix.strict-bool == true && '-DSTRICT_BOOL=ON' || '' }} ${{ matrix.disable-wstrings == true && '-DFASTCDR_DISABLE_WSTRINGS=ON' || '' }}
cmake_args_default: ${{ env.colcon-build-default-cmake-args }} ${{ env.toolset }}
cmake_build_type: ${{ matrix.cmake-build-type }}
workspace: ${{ github.workspace }}
Expand All @@ -146,7 +152,7 @@ jobs:
ctest_args: ${{ inputs.ctest-args }}
packages_names: fastcdr
workspace: ${{ github.workspace }}
test_report_artifact: ${{ inputs.label }}${{ matrix.strict-bool == true && '-strict-bool' || '' }}
test_report_artifact: ${{ inputs.label }}${{ matrix.strict-bool == true && '-strict-bool' || '' }}${{ matrix.disable-wstrings == true && '-disable-wstrings' || '' }}

- name: Fast CDR Test summary
uses: eProsima/eProsima-CI/multiplatform/junit_summary@v0
Expand All @@ -162,5 +168,5 @@ jobs:
if: ${{ !cancelled() && inputs.run-build == true && inputs.run-tests == true }}
uses: eProsima/eProsima-CI/external/upload-artifact@v0
with:
name: test-results-${{ inputs.label }}${{ matrix.strict-bool == true && '-strict-bool' || '' }}
name: test-results-${{ inputs.label }}${{ matrix.strict-bool == true && '-strict-bool' || '' }}${{ matrix.disable-wstrings == true && '-disable-wstrings' || '' }}
path: log/latest_test/fastcdr
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
ref: ${{ inputs.fastcdr-branch || github.ref }}

- name: Configure Fast CDR
run: cmake -S src/fastcdr -B build/fastcdr
run: cmake -S src/fastcdr -B build/fastcdr -DFASTCDR_DISABLE_WSTRINGS=ON

- name: FACE check (C++11 General Purpose capability set)
run: |
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ option(BUILD_SHARED_LIBS "Create shared libraries by default" ON)
###############################################################################
option(STRICT_BOOL "Enforce bool values to 0/1 during serialization" OFF)

###############################################################################
# Wide characters and strings
###############################################################################
option(FASTCDR_DISABLE_WSTRINGS "Leave out the API for wide characters and strings (wchar_t, std::wstring)" OFF)

###############################################################################
# Test system configuration
###############################################################################
Expand Down
31 changes: 31 additions & 0 deletions include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ class Cdr
Cdr_DllAPI Cdr& serialize(
const std::int32_t long_t);

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function serializes a wide-char.
* @param wchar The value of the wide-char that will be serialized in the buffer.
Expand All @@ -642,6 +643,7 @@ class Cdr
*/
Cdr_DllAPI Cdr& serialize(
const wchar_t wchar);
#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief This function serializes an unsigned long long.
Expand Down Expand Up @@ -716,6 +718,7 @@ class Cdr
Cdr_DllAPI Cdr& serialize(
const char* string_t);

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function serializes a wstring.
* @param string_t The pointer to the wstring that will be serialized in the buffer.
Expand All @@ -724,6 +727,7 @@ class Cdr
*/
Cdr_DllAPI Cdr& serialize(
const wchar_t* string_t);
#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief This function serializes a std::string.
Expand All @@ -747,6 +751,7 @@ class Cdr
return serialize_sequence(c_str, str_len + 1);
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function serializes a std::wstring.
* @param string_t The wstring that will be serialized in the buffer.
Expand All @@ -760,6 +765,8 @@ class Cdr
return serialize(string_t.c_str());
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Encodes a eprosima::fastcdr::fixed_string in the buffer.
* @param[in] value A reference to the fixed string which will be encoded in the buffer.
Expand Down Expand Up @@ -1126,6 +1133,7 @@ class Cdr
const std::int32_t* long_t,
std::size_t num_elements);

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function serializes an array of wide-chars.
* @param wchar The array of wide-chars that will be serialized in the buffer.
Expand All @@ -1136,6 +1144,7 @@ class Cdr
Cdr_DllAPI Cdr& serialize_array(
const wchar_t* wchar,
std::size_t num_elements);
#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief This function serializes an array of unsigned long longs.
Expand Down Expand Up @@ -1227,6 +1236,7 @@ class Cdr
return *this;
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function serializes an array of wide-strings.
* @param string_t The array of wide-strings that will be serialized in the buffer.
Expand All @@ -1246,6 +1256,8 @@ class Cdr
return *this;
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Encodes an array of fixed strings.
* @param[in] value Array of fixed strings which will be encoded in the buffer.
Expand Down Expand Up @@ -1698,6 +1710,7 @@ class Cdr
Cdr_DllAPI Cdr& deserialize(
std::int32_t& long_t);

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function deserializes a wide-char.
* @param wchar The variable that will store the wide-char read from the buffer.
Expand All @@ -1714,6 +1727,8 @@ class Cdr
return *this;
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief This function deserializes an unsigned long long.
* @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
Expand Down Expand Up @@ -1814,6 +1829,7 @@ class Cdr
CdrTryConstructFlag consistency_flag,
std::uint32_t max_length);

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function deserializes a wide-string.
* This function allocates memory to store the wide string. The user pointer will be set to point this allocated memory.
Expand Down Expand Up @@ -1853,6 +1869,7 @@ class Cdr
wchar_t*& string_t,
CdrTryConstructFlag consistency_flag,
std::uint32_t max_length);
#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief This function deserializes a std::string.
Expand Down Expand Up @@ -1902,6 +1919,7 @@ class Cdr
return *this;
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function deserializes a std::wstring.
* @param string_t The variable that will store the string read from the buffer.
Expand Down Expand Up @@ -1948,6 +1966,8 @@ class Cdr
return *this;
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Decodes a fixed string.
* @param[out] value Reference to the variable where the fixed string will be stored after decoding from the buffer.
Expand Down Expand Up @@ -3078,6 +3098,7 @@ class Cdr
std::int32_t* long_t,
std::size_t num_elements);

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function deserializes an array of wide-chars.
* @param wchar The variable that will store the array of wide-chars read from the buffer.
Expand All @@ -3088,6 +3109,7 @@ class Cdr
Cdr_DllAPI Cdr& deserialize_array(
wchar_t* wchar,
std::size_t num_elements);
#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief This function deserializes an array of unsigned long longs.
Expand Down Expand Up @@ -3482,6 +3504,7 @@ class Cdr
return deserialize_string_sequence(sequence_t, num_elements);
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief This function template deserializes a wide-string sequence.
* This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
Expand All @@ -3499,6 +3522,8 @@ class Cdr
return deserialize_wstring_sequence(sequence_t, num_elements);
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// XCDR extensions
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4212,9 +4237,11 @@ class Cdr
std::string*& sequence_t,
std::size_t& num_elements);

#if !FASTCDR_DISABLE_WSTRINGS
Cdr_DllAPI Cdr& deserialize_wstring_sequence(
std::wstring*& sequence_t,
std::size_t& num_elements);
#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Serializes the canonical @c uint8_t representation of @p bool_t.
Expand Down Expand Up @@ -4353,15 +4380,19 @@ class Cdr

Cdr_DllAPI const char* read_string(
std::uint32_t& length);
#if !FASTCDR_DISABLE_WSTRINGS
Cdr_DllAPI const std::wstring read_wstring(
std::uint32_t& length);
#endif // if !FASTCDR_DISABLE_WSTRINGS

Cdr_DllAPI const char* read_string(
std::uint32_t& length,
CdrTryConstructFlag consistency_flag);
#if !FASTCDR_DISABLE_WSTRINGS
Cdr_DllAPI const std::wstring read_wstring(
std::uint32_t& length,
CdrTryConstructFlag consistency_flag);
#endif // if !FASTCDR_DISABLE_WSTRINGS

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// XCDR extensions
Expand Down
9 changes: 9 additions & 0 deletions include/fastcdr/CdrSizeCalculator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class CdrSizeCalculator
return 1;
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief Specific template which calculates the encoded size of an instance of a wchar.
* @param[in] data Reference to the instance.
Expand All @@ -316,6 +317,8 @@ class CdrSizeCalculator
return calculated_size;
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Specific template which calculates the encoded size of an instance of a int16_t.
* @param[in] data Reference to the instance.
Expand Down Expand Up @@ -487,6 +490,7 @@ class CdrSizeCalculator
return calculated_size;
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief Specific template which calculates the encoded size of an instance of a std::wstring.
* @param[in] data Reference to the instance.
Expand All @@ -504,6 +508,8 @@ class CdrSizeCalculator
return calculated_size;
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Specific template which calculates the encoded size of an instance of a fixed_string.
* @param[in] data Reference to the instance.
Expand Down Expand Up @@ -892,6 +898,7 @@ class CdrSizeCalculator
return num_elements;
}

#if !FASTCDR_DISABLE_WSTRINGS
/*!
* @brief Specific template which calculates the encoded size of an instance of an array of wchar.
* @param[in] data Reference to the array's instance.
Expand All @@ -911,6 +918,8 @@ class CdrSizeCalculator
return calculated_size;
}

#endif // if !FASTCDR_DISABLE_WSTRINGS

/*!
* @brief Specific template which calculates the encoded size of an instance of an array of int16_t.
* @param[in] data Reference to the array's instance.
Expand Down
Loading
Loading