├── .gitattributes ├── .github ├── dco.yml ├── pull_request_template.md └── workflows │ ├── codeql-analysis.yml │ ├── config │ ├── build.meta │ ├── test.meta │ └── test.repos │ ├── mac-ci.yml │ ├── mirror.yml │ ├── nightly-mac-ci.yml │ ├── nightly-ubuntu-ci.yml │ ├── nightly-windows-ci.yml │ ├── reusable-ci.yml │ ├── ubuntu-ci.yml │ └── windows-ci.yml ├── .gitignore ├── .gitmodules ├── .ycm_extra_conf.py ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CTestJenkins.cmake ├── LICENSE ├── PLATFORM_SUPPORT.md ├── QUALITY.md ├── README.md ├── RELEASE_SUPPORT.md ├── VERSIONING.md ├── cmake ├── common │ ├── check_configuration.cmake │ └── find_or_add_gtest.cmake ├── packaging │ ├── Config.cmake.in │ └── windows │ │ └── fastcdr-config.cmake └── testing │ ├── GoogleTest.cmake │ └── generate_google_test_win_wrapper.cmake ├── colcon.pkg ├── doc ├── README.html.in ├── Users Manual.odt └── information │ └── standards │ ├── 10-11-01.pdf │ ├── 11-11-02-1.pdf │ └── 13-02-04.pdf ├── doxyfile.in ├── fastcdr.repos ├── include └── fastcdr │ ├── Cdr.h │ ├── CdrEncoding.hpp │ ├── CdrSizeCalculator.hpp │ ├── FastBuffer.h │ ├── FastCdr.h │ ├── cdr │ └── fixed_size_string.hpp │ ├── config.h.in │ ├── config │ └── doxygen_modules.h │ ├── detail │ └── container_recursive_inspector.hpp │ ├── eProsima_auto_link.h │ ├── exceptions │ ├── BadOptionalAccessException.hpp │ ├── BadParamException.h │ ├── Exception.h │ ├── LockedExternalAccessException.hpp │ └── NotEnoughMemoryException.h │ ├── fastcdr_dll.h │ └── xcdr │ ├── MemberId.hpp │ ├── detail │ └── optional.hpp │ ├── external.hpp │ └── optional.hpp ├── package.xml ├── resources └── images │ └── github_banner_fastcdr.png ├── src └── cpp │ ├── CMakeLists.txt │ ├── Cdr.cpp │ ├── CdrSizeCalculator.cpp │ ├── FastBuffer.cpp │ ├── FastCdr.cpp │ ├── FastCdr.rc │ └── exceptions │ ├── BadOptionalAccessException.cpp │ ├── BadParamException.cpp │ ├── Exception.cpp │ ├── LockedExternalAccessException.cpp │ └── NotEnoughMemoryException.cpp ├── test ├── CMakeLists.txt ├── cdr │ ├── CMakeLists.txt │ ├── ResizeTest.cpp │ ├── SimpleTest.cpp │ ├── array_as_std_vector.cpp │ └── fixed_size_string.cpp ├── cmake │ ├── CMakeLists.txt │ ├── build.cmake │ └── fold.cpp └── xcdr │ ├── CMakeLists.txt │ ├── appendable.cpp │ ├── basic_types.cpp │ ├── external.cpp │ ├── final.cpp │ ├── mutable.cpp │ ├── optional.cpp │ ├── utility.hpp │ ├── xcdrv1.cpp │ └── xcdrv2.cpp ├── utils ├── doxygen │ ├── doxyfile │ ├── doxygenfiles │ │ ├── eProsimaLogo.png │ │ ├── logoEprosimaBlueRTI.gif │ │ └── mainpage.dox │ └── pages │ │ ├── customdoxygen.css │ │ ├── eprosima_footer.html │ │ └── eprosima_header.html └── images │ ├── icon │ ├── eprosima_icon.bmp │ └── eprosima_icon.ico │ └── logo │ ├── eProsimaLogo.jpg │ └── eProsimaLogo.png ├── valgrind.supp └── versions.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files we want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.c text 7 | *.cpp text 8 | *.cxx text 9 | *.h text 10 | *.stg text eol=lf 11 | 12 | # Declare files that will always have CRLF line endings on checkout. 13 | *.sln text eol=crlf 14 | *.vcxproj text eol=crlf 15 | *.vcxproj.filters text eol=crlf 16 | *.bat text eol=crlf 17 | 18 | # Denote all files that are truly binary and should not be modified. 19 | *.png binary 20 | *.jpg binary 21 | 22 | # To diff LibreOffice documents. 23 | # It is needed next configuration value: diff.odf.textconv=odt2txt 24 | *.ods diff=odf 25 | *.odt diff=odf 26 | *.odp diff=odf 27 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | require: 2 | members: false 3 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | ## Description 10 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ## Contributor Checklist 29 | 30 | 34 | 35 | - [ ] Commit messages follow the project guidelines. 36 | - [ ] The code follows the style guidelines of this project. 37 | - [ ] Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally 38 | - [ ] Any new/modified methods have been properly documented using Doxygen. 39 | - [ ] Changes are backport compatible: they do **NOT** break ABI nor change library core behavior. 40 | - [ ] Changes are API compatible. 41 | - [ ] New feature has been added to the `versions.md` file (if applicable). 42 | - [ ] Applicable backports have been included in the description. 43 | 44 | ## Reviewer Checklist 45 | 46 | - [ ] The PR has a milestone assigned. 47 | - [ ] The title and description correctly express the PR's purpose. 48 | - [ ] Check contributor checklist is correct. 49 | - [ ] Check CI results: changes do not issue any warning. 50 | - [ ] Check CI results: CI pass and failing tests are unrelated with the changes. 51 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: 17 | - master 18 | - 2.2.x 19 | - 1.1.x 20 | - 1.0.x 21 | pull_request: 22 | # The branches below must be a subset of the branches above 23 | branches: 24 | - master 25 | - 2.2.x 26 | - 1.1.x 27 | - 1.0.x 28 | schedule: 29 | - cron: '45 16 * * 0' 30 | 31 | jobs: 32 | analyze: 33 | name: Analyze 34 | runs-on: ${{ matrix.os }} 35 | 36 | strategy: 37 | fail-fast: false 38 | matrix: 39 | os: [windows-2019, ubuntu-22.04, macos-13, ] 40 | language: [ 'cpp' ] 41 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 42 | # Learn more: 43 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 44 | 45 | steps: 46 | - name: Checkout repository 47 | uses: actions/checkout@v4 48 | 49 | # Initializes the CodeQL tools for scanning. 50 | - name: Initialize CodeQL 51 | uses: github/codeql-action/init@v3 52 | with: 53 | languages: ${{ matrix.language }} 54 | # If you wish to specify custom queries, you can do so here or in a config file. 55 | # By default, queries listed here will override any specified in a config file. 56 | # Prefix the list here with "+" to use these queries and those in the config file. 57 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 58 | 59 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 60 | # If this step fails, then you should remove it and run the build manually (see below) 61 | # - name: Autobuild 62 | # uses: github/codeql-action/autobuild@v1 63 | 64 | # ℹ️ Command-line programs to run using the OS shell. 65 | # 📚 https://git.io/JvXDl 66 | 67 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 68 | # and modify them (or add more) to build your code if your project 69 | # uses a compiled language 70 | 71 | - name: Build 72 | run: | 73 | mkdir build && cd build 74 | cmake .. 75 | cmake --build . 76 | 77 | - name: Perform CodeQL Analysis 78 | uses: github/codeql-action/analyze@v3 79 | -------------------------------------------------------------------------------- /.github/workflows/config/build.meta: -------------------------------------------------------------------------------- 1 | names: 2 | fastcdr: 3 | cmake-args: 4 | - "-DBUILD_TESTING=ON" 5 | googletest-distribution: 6 | cmake-args: 7 | - "-Dgtest_force_shared_crt=ON" 8 | - "-DBUILD_SHARED_LIBS=ON" 9 | - "-DBUILD_GMOCK=ON" 10 | 11 | -------------------------------------------------------------------------------- /.github/workflows/config/test.meta: -------------------------------------------------------------------------------- 1 | names: 2 | fastcdr: 3 | ctest-args: [ 4 | "--repeat", "until-pass:3", 5 | "--timeout", "300", 6 | "--output-junit", "junit/junit.xml" 7 | ] 8 | -------------------------------------------------------------------------------- /.github/workflows/config/test.repos: -------------------------------------------------------------------------------- 1 | repositories: 2 | googletest-distribution: 3 | type: git 4 | url: https://github.com/google/googletest.git 5 | version: release-1.11.0 6 | -------------------------------------------------------------------------------- /.github/workflows/mac-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR Mac CI 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | os-version: 7 | description: 'OS version to run the workflow' 8 | required: false 9 | default: 'macos-13' 10 | type: string 11 | colcon-args: 12 | description: 'Extra arguments for colcon cli' 13 | required: false 14 | type: string 15 | cmake-args: 16 | description: 'Extra arguments for cmake cli' 17 | required: false 18 | type: string 19 | ctest-args: 20 | description: 'Extra arguments for ctest cli' 21 | required: false 22 | type: string 23 | fastcdr-branch: 24 | description: 'Branch or tag of Fast CDR repository' 25 | type: string 26 | required: true 27 | run-tests: 28 | description: 'Run test suite of Fast CDR' 29 | required: false 30 | type: boolean 31 | default: true 32 | 33 | pull_request: 34 | types: 35 | - review_requested 36 | paths-ignore: 37 | - '**.md' 38 | - '**.txt' 39 | - '!**/CMakeLists.txt' 40 | 41 | concurrency: 42 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 43 | cancel-in-progress: true 44 | 45 | jobs: 46 | mac-ci: 47 | if: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'conflicts') }} 48 | uses: ./.github/workflows/reusable-ci.yml 49 | with: 50 | # It would be desirable to have a matrix of macos OS for this job, but due to the issue opened in this ticket: 51 | # https://github.com/orgs/community/discussions/128118 , it has been set as a single OS job. 52 | os-version: ${{ inputs.os-version || 'macos-13' }} 53 | label: ${{ format('mac-ci-{0}', inputs.fastcdr-branch || github.ref) }} 54 | colcon-args: ${{ inputs.colcon-args }} 55 | cmake-args: ${{ inputs.cmake-args }} 56 | ctest-args: ${{ inputs.ctest-args }} 57 | fastcdr-branch: ${{ inputs.fastcdr-branch || github.ref }} 58 | run-build: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'skip-ci') }} 59 | run-tests: ${{ (inputs.run-tests == true) || ((github.event_name == 'pull_request') && (!contains(github.event.pull_request.labels.*.name, 'no-test'))) }} 60 | -------------------------------------------------------------------------------- /.github/workflows/mirror.yml: -------------------------------------------------------------------------------- 1 | # .github/workflows/mirror.yml 2 | on: 3 | push: 4 | branches: 5 | - 'master' 6 | - '1.1.x' 7 | jobs: 8 | mirror_job_master: 9 | if: github.ref == 'refs/heads/master' 10 | runs-on: ubuntu-latest 11 | name: Mirror master branch to API & ABI compatible minor version branches 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | dest_branch: 16 | - '2.3.x' 17 | - '2.x' 18 | steps: 19 | - name: Mirror action step 20 | id: mirror 21 | uses: eProsima/eProsima-CI/external/mirror-branch-action@v0 22 | with: 23 | github-token: ${{ secrets.GITHUB_TOKEN }} 24 | source: 'master' 25 | dest: ${{ matrix.dest_branch }} 26 | mirror_job_1_x: 27 | if: github.ref == 'refs/heads/1.1.x' 28 | runs-on: ubuntu-latest 29 | name: Mirror 1.1.x branch to API & ABI compatible minor version branches 30 | strategy: 31 | fail-fast: false 32 | matrix: 33 | dest_branch: 34 | - '1.x' 35 | steps: 36 | - name: Mirror action step 37 | id: mirror 38 | uses: eProsima/eProsima-CI/external/mirror-branch-action@v0 39 | with: 40 | github-token: ${{ secrets.GITHUB_TOKEN }} 41 | source: '1.1.x' 42 | dest: ${{ matrix.dest_branch }} 43 | -------------------------------------------------------------------------------- /.github/workflows/nightly-mac-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR Mac CI (nightly) 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 1 * * *' 7 | 8 | jobs: 9 | nightly-mac-ci-master: 10 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@master 11 | with: 12 | os-version: 'macos-13' 13 | label: 'nightly-mac-ci-master' 14 | fastcdr-branch: 'master' 15 | run-build: true 16 | run-tests: true 17 | use-ccache: false 18 | 19 | nightly-mac-ci-2_2_x: 20 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@2.2.x 21 | with: 22 | os-version: 'macos-13' 23 | label: 'nightly-mac-ci-2.2.x' 24 | fastcdr-branch: '2.2.x' 25 | run-build: true 26 | run-tests: true 27 | use-ccache: false 28 | 29 | nightly-mac-ci-1_0_x: 30 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@1.0.x 31 | with: 32 | os-version: 'macos-13' 33 | label: 'nightly-mac-ci-1.0.x' 34 | fastcdr-branch: '1.0.x' 35 | run-build: true 36 | run-tests: true 37 | use-ccache: false 38 | -------------------------------------------------------------------------------- /.github/workflows/nightly-ubuntu-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR Ubuntu CI (nightly) 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 1 * * *' 7 | 8 | jobs: 9 | nightly-ubuntu-ci-master: 10 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@master 11 | with: 12 | os-version: 'ubuntu-22.04' 13 | label: 'nightly-ubuntu-ci-master' 14 | fastcdr-branch: 'master' 15 | run-build: true 16 | run-tests: true 17 | use-ccache: false 18 | 19 | nightly-ubuntu-ci-2_2_x: 20 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@2.2.x 21 | with: 22 | os-version: 'ubuntu-22.04' 23 | label: 'nightly-ubuntu-ci-2.2.x' 24 | fastcdr-branch: '2.2.x' 25 | run-build: true 26 | run-tests: true 27 | use-ccache: false 28 | 29 | nightly-ubuntu-ci-1_0_x: 30 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@1.0.x 31 | with: 32 | os-version: 'ubuntu-20.04' 33 | label: 'nightly-ubuntu-ci-1.0.x' 34 | fastcdr-branch: '1.0.x' 35 | run-build: true 36 | run-tests: true 37 | use-ccache: false 38 | -------------------------------------------------------------------------------- /.github/workflows/nightly-windows-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR Windows CI (nightly) 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 1 * * *' 7 | 8 | jobs: 9 | nightly-windows-ci-master: 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | vs-toolset: 14 | - 'v141' 15 | - 'v142' 16 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@master 17 | with: 18 | os-version: 'windows-2019' 19 | vs-toolset: ${{ matrix.vs-toolset }} 20 | label: 'nightly-windows-${{ matrix.vs-toolset }}-ci-master' 21 | fastcdr-branch: 'master' 22 | run-build: true 23 | run-tests: true 24 | use-ccache: false 25 | 26 | nightly-windows-ci-2_2_x: 27 | strategy: 28 | fail-fast: false 29 | matrix: 30 | vs-toolset: 31 | - 'v141' 32 | - 'v142' 33 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@2.2.x 34 | with: 35 | os-version: 'windows-2019' 36 | vs-toolset: ${{ matrix.vs-toolset }} 37 | label: 'nightly-windows-${{ matrix.vs-toolset }}-ci-2.2.x' 38 | fastcdr-branch: '2.2.x' 39 | run-build: true 40 | run-tests: true 41 | use-ccache: false 42 | 43 | nightly-windows-ci-1_0_x: 44 | strategy: 45 | fail-fast: false 46 | matrix: 47 | vs-toolset: 48 | - 'v141' 49 | - 'v142' 50 | uses: eProsima/Fast-CDR/.github/workflows/reusable-ci.yml@1.0.x 51 | with: 52 | os-version: 'windows-2019' 53 | vs-toolset: ${{ matrix.vs-toolset }} 54 | label: 'nightly-windows-${{ matrix.vs-toolset }}-ci-1.0.x' 55 | fastcdr-branch: '1.0.x' 56 | run-build: true 57 | run-tests: true 58 | use-ccache: false 59 | -------------------------------------------------------------------------------- /.github/workflows/reusable-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR reusable CI workflow 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | os-version: 7 | description: 'The OS image for the workflow' 8 | required: false 9 | default: 'ubuntu-22.04' 10 | type: string 11 | vs-toolset: 12 | description: 'Windows Visual Studio toolset to use (only Windows)' 13 | required: false 14 | type: string 15 | label: 16 | description: 'ID associated to the workflow' 17 | required: true 18 | type: string 19 | colcon-args: 20 | description: 'Extra arguments for colcon cli' 21 | required: false 22 | type: string 23 | cmake-args: 24 | description: 'Extra arguments for cmake cli' 25 | required: false 26 | type: string 27 | ctest-args: 28 | description: 'Extra arguments for ctest cli' 29 | required: false 30 | type: string 31 | fastcdr-branch: 32 | description: 'Branch or tag of Fast CDR repository' 33 | required: true 34 | type: string 35 | run-build: 36 | description: 'Build Fast CDR (CI skipped otherwise)' 37 | required: false 38 | type: boolean 39 | default: true 40 | run-tests: 41 | description: 'Run test suite of Fast CDR' 42 | required: false 43 | type: boolean 44 | default: true 45 | use-ccache: 46 | description: 'Use CCache to speed up the build' 47 | required: false 48 | type: boolean 49 | default: false 50 | add-label: 51 | description: 'Add the ci-pending label to the PR' 52 | required: false 53 | type: boolean 54 | default: false 55 | env: 56 | toolset: ${{ inputs.vs-toolset && format('-T {0}', inputs.vs-toolset) || '' }} 57 | defaults: 58 | run: 59 | shell: bash 60 | 61 | jobs: 62 | fastcdr_test: 63 | runs-on: ${{ inputs.os-version }} 64 | if: ${{ inputs.run-build == true }} 65 | strategy: 66 | fail-fast: false 67 | matrix: 68 | cmake-build-type: 69 | - 'RelWithDebInfo' 70 | 71 | steps: 72 | - name: Add ci-pending label if PR 73 | if: ${{ github.event_name == 'pull_request' && inputs.add-label == true}} 74 | uses: eProsima/eProsima-CI/external/add_labels@v0 75 | with: 76 | labels: ci-pending 77 | number: ${{ github.event.number }} 78 | repo: eProsima/Fast-CDR 79 | 80 | - name: Sync eProsima/Fast-CDR repository 81 | uses: eProsima/eProsima-CI/external/checkout@v0 82 | with: 83 | path: src/fastcdr 84 | ref: ${{ inputs.fastcdr-branch }} 85 | 86 | - name: Install Fix Python version 87 | uses: eProsima/eProsima-CI/external/setup-python@v0 88 | with: 89 | python-version: '3.11' 90 | 91 | - name: Get minimum supported version of CMake 92 | uses: eProsima/eProsima-CI/external/get-cmake@v0 93 | with: 94 | cmakeVersion: '3.22.6' 95 | 96 | - name: Install Colcon dependencies 97 | uses: eProsima/eProsima-CI/multiplatform/install_colcon@v0 98 | 99 | - name: Setup CCache 100 | uses: eProsima/eProsima-CI/external/setup-ccache-action@v0 101 | if: ${{ inputs.use-ccache == true }} 102 | with: 103 | api_token: ${{ secrets.GITHUB_TOKEN }} 104 | 105 | - name: Install Python dependencies 106 | uses: eProsima/eProsima-CI/multiplatform/install_python_packages@v0 107 | with: 108 | packages: vcstool 109 | upgrade: false 110 | 111 | - name: Fetch Fast DDS CI dependencies 112 | uses: eProsima/eProsima-CI/multiplatform/vcs_import@v0 113 | with: 114 | vcs_repos_file: ${{ github.workspace }}/src/fastcdr/.github/workflows/config/test.repos 115 | destination_workspace: src 116 | skip_existing: 'true' 117 | 118 | - name: Colcon build 119 | uses: eProsima/eProsima-CI/multiplatform/colcon_build@v0 120 | with: 121 | colcon_meta_file: ${{ github.workspace }}/src/fastcdr/.github/workflows/config/build.meta 122 | colcon_build_args: ${{ inputs.colcon-args }} 123 | colcon_build_args_default: --event-handlers=console_direct+ 124 | cmake_args: ${{ inputs.cmake-args }} 125 | cmake_args_default: ${{ env.toolset }} 126 | cmake_build_type: ${{ matrix.cmake-build-type }} 127 | workspace: ${{ github.workspace }} 128 | 129 | - name: Colcon test 130 | id: test_fastcdr 131 | if: ${{ inputs.run-tests == true }} 132 | uses: eProsima/eProsima-CI/multiplatform/colcon_test@v0 133 | with: 134 | colcon_meta_file: ${{ github.workspace }}/src/fastcdr/.github/workflows/config/build.meta ${{ github.workspace }}/src/fastcdr/.github/workflows/config/test.meta 135 | colcon_test_args_default: --event-handlers=console_direct+ 136 | ctest_args: ${{ inputs.ctest-args }} 137 | packages_names: fastcdr 138 | workspace: ${{ github.workspace }} 139 | test_report_artifact: ${{ inputs.label }} 140 | 141 | - name: Fast CDR Test summary 142 | uses: eProsima/eProsima-CI/multiplatform/junit_summary@v0 143 | if: ${{ !cancelled() && inputs.run-tests == true }} 144 | with: 145 | junit_reports_dir: ${{ steps.test_fastcdr.outputs.ctest_results_path }} 146 | print_summary: 'True' 147 | show_failed: 'True' 148 | show_disabled: 'False' 149 | show_skipped: 'False' 150 | 151 | - name: Archive Test Results 152 | if: always() 153 | uses: eProsima/eProsima-CI/external/upload-artifact@v0 154 | with: 155 | name: test-results-${{ inputs.label }} 156 | path: log/latest_test/fastcdr 157 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR Ubuntu CI 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | os-version: 7 | description: 'OS version to run the workflow' 8 | required: false 9 | default: 'ubuntu-22.04' 10 | type: string 11 | colcon-args: 12 | description: 'Extra arguments for colcon cli' 13 | required: false 14 | type: string 15 | cmake-args: 16 | description: 'Extra arguments for cmake cli' 17 | required: false 18 | type: string 19 | ctest-args: 20 | description: 'Extra arguments for ctest cli' 21 | required: false 22 | type: string 23 | fastcdr-branch: 24 | description: 'Branch or tag of Fast CDR repository' 25 | type: string 26 | required: true 27 | run-tests: 28 | description: 'Run test suite of Fast CDR' 29 | required: false 30 | type: boolean 31 | default: true 32 | use-ccache: 33 | description: 'Use CCache to speed up the build' 34 | required: false 35 | type: boolean 36 | default: false 37 | 38 | pull_request: 39 | types: 40 | - review_requested 41 | paths-ignore: 42 | - '**.md' 43 | - '**.txt' 44 | - '!**/CMakeLists.txt' 45 | 46 | concurrency: 47 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 48 | cancel-in-progress: true 49 | 50 | jobs: 51 | ubuntu-ci: 52 | if: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'conflicts') }} 53 | uses: ./.github/workflows/reusable-ci.yml 54 | with: 55 | # It would be desirable to have a matrix of ubuntu OS for this job, but due to the issue opened in this ticket: 56 | # https://github.com/orgs/community/discussions/128118 , it has been set as a single OS job. 57 | os-version: ${{ inputs.os-version || 'ubuntu-22.04' }} 58 | label: ${{ format('ubuntu-ci-{0}', inputs.fastcdr-branch || github.ref) }} 59 | colcon-args: ${{ inputs.colcon-args }} 60 | cmake-args: ${{ inputs.cmake-args }} 61 | ctest-args: ${{ inputs.ctest-args }} 62 | fastcdr-branch: ${{ inputs.fastcdr-branch || github.ref }} 63 | run-build: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'skip-ci') }} 64 | run-tests: ${{ (inputs.run-tests == true) || ((github.event_name == 'pull_request') && (!contains(github.event.pull_request.labels.*.name, 'no-test'))) }} 65 | use-ccache: ${{ inputs.use-ccache || false }} 66 | add-label: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.repository) && true || false }} 67 | -------------------------------------------------------------------------------- /.github/workflows/windows-ci.yml: -------------------------------------------------------------------------------- 1 | name: Fast CDR Windows CI 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | os-version: 7 | description: 'OS version to run the workflow' 8 | required: false 9 | default: 'windows-2019' 10 | type: string 11 | vs-toolset: 12 | description: 'Visual Studio toolset to use (Default: v141 and v142)' 13 | required: false 14 | default: '' 15 | type: string 16 | colcon-args: 17 | description: 'Extra arguments for colcon cli' 18 | required: false 19 | type: string 20 | cmake-args: 21 | description: 'Extra arguments for cmake cli' 22 | required: false 23 | type: string 24 | ctest-args: 25 | description: 'Extra arguments for ctest cli' 26 | required: false 27 | type: string 28 | fastcdr-branch: 29 | description: 'Branch or tag of Fast CDR repository' 30 | type: string 31 | required: true 32 | run-tests: 33 | description: 'Run test suite of Fast CDR' 34 | required: false 35 | type: boolean 36 | default: true 37 | 38 | pull_request: 39 | types: 40 | - review_requested 41 | paths-ignore: 42 | - '**.md' 43 | - '**.txt' 44 | - '!**/CMakeLists.txt' 45 | 46 | concurrency: 47 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 48 | cancel-in-progress: true 49 | 50 | jobs: 51 | windows-ci: 52 | strategy: 53 | fail-fast: false 54 | matrix: 55 | vs-toolset: 56 | - 'v141' 57 | - 'v142' 58 | if: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'conflicts') }} 59 | uses: ./.github/workflows/reusable-ci.yml 60 | with: 61 | # It would be desirable to have a matrix of windows OS for this job, but due to the issue opened in this ticket: 62 | # https://github.com/orgs/community/discussions/128118 , it has been set as a single OS job. 63 | os-version: ${{ inputs.os-version || 'windows-2019' }} 64 | vs-toolset: ${{ inputs.vs-toolset || matrix.vs-toolset }} 65 | label: ${{ format('windows-{0}-ci-{1}', matrix.vs-toolset, inputs.fastcdr-branch || github.ref) }} 66 | colcon-args: ${{ inputs.colcon-args }} 67 | cmake-args: ${{ inputs.cmake-args }} 68 | ctest-args: ${{ inputs.ctest-args }} 69 | fastcdr-branch: ${{ inputs.fastcdr-branch || github.ref }} 70 | run-build: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'skip-ci') }} 71 | run-tests: ${{ (inputs.run-tests == true) || ((github.event_name == 'pull_request') && (!contains(github.event.pull_request.labels.*.name, 'no-test'))) }} 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Backup GVim files. 2 | *~ 3 | # Temporaly GVim files. 4 | *.swp 5 | # Build directory 6 | build/ 7 | # Visual Studio user configuration files. 8 | *.vcxproj.user 9 | *.sdf 10 | *.opensdf 11 | *.suo 12 | # Visual Studio build directories. 13 | Debug*/ 14 | Release*/ 15 | ipch/ 16 | objs/ 17 | output/ 18 | bin/ 19 | # Lib directory 20 | lib/ 21 | # Tags info 22 | tags 23 | cscope.out 24 | # Compiled python objects 25 | *.pyc 26 | # Installers 27 | *.tar.gz 28 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/.gitmodules -------------------------------------------------------------------------------- /.ycm_extra_conf.py: -------------------------------------------------------------------------------- 1 | # This file is NOT licensed under the GPLv3, which is the license for the rest 2 | # of YouCompleteMe. 3 | # 4 | # Here's the license text for this file: 5 | # 6 | # This is free and unencumbered software released into the public domain. 7 | # 8 | # Anyone is free to copy, modify, publish, use, compile, sell, or 9 | # distribute this software, either in source code form or as a compiled 10 | # binary, for any purpose, commercial or non-commercial, and by any 11 | # means. 12 | # 13 | # In jurisdictions that recognize copyright laws, the author or authors 14 | # of this software dedicate any and all copyright interest in the 15 | # software to the public domain. We make this dedication for the benefit 16 | # of the public at large and to the detriment of our heirs and 17 | # successors. We intend this dedication to be an overt act of 18 | # relinquishment in perpetuity of all present and future rights to this 19 | # software under copyright law. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | # OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # For more information, please refer to 30 | 31 | import os 32 | import ycm_core 33 | 34 | # These are the compilation flags that will be used in case there's no 35 | # compilation database set (by default, one is not set). 36 | # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. 37 | flags = [ 38 | '-Wall', 39 | '-Wextra', 40 | '-Werror', 41 | '-Wno-long-long', 42 | '-Wno-variadic-macros', 43 | '-fexceptions', 44 | '-std=c++11', 45 | '-x', 46 | 'c++', 47 | '-isystem', 48 | '/usr/include', 49 | '-I', 50 | 'include', 51 | '-I', 52 | os.environ['EPROSIMADIR'] + '/code', 53 | ] 54 | 55 | 56 | # Set this to the absolute path to the folder (NOT the file!) containing the 57 | # compile_commands.json file to use that instead of 'flags'. See here for 58 | # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html 59 | # 60 | # Most projects will NOT need to set this to anything; you can just change the 61 | # 'flags' list of compilation flags. Notice that YCM itself uses that approach. 62 | compilation_database_folder = '' 63 | 64 | if os.path.exists( compilation_database_folder ): 65 | database = ycm_core.CompilationDatabase( compilation_database_folder ) 66 | else: 67 | database = None 68 | 69 | SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] 70 | 71 | def DirectoryOfThisScript(): 72 | return os.path.dirname( os.path.abspath( __file__ ) ) 73 | 74 | 75 | def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): 76 | if not working_directory: 77 | return list( flags ) 78 | new_flags = [] 79 | make_next_absolute = False 80 | path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] 81 | for flag in flags: 82 | new_flag = flag 83 | 84 | if make_next_absolute: 85 | make_next_absolute = False 86 | if not flag.startswith( '/' ): 87 | new_flag = os.path.join( working_directory, flag ) 88 | 89 | for path_flag in path_flags: 90 | if flag == path_flag: 91 | make_next_absolute = True 92 | break 93 | 94 | if flag.startswith( path_flag ): 95 | path = flag[ len( path_flag ): ] 96 | new_flag = path_flag + os.path.join( working_directory, path ) 97 | break 98 | 99 | if new_flag: 100 | new_flags.append( new_flag ) 101 | return new_flags 102 | 103 | 104 | def IsHeaderFile( filename ): 105 | extension = os.path.splitext( filename )[ 1 ] 106 | return extension in [ '.h', '.hxx', '.hpp', '.hh' ] 107 | 108 | 109 | def GetCompilationInfoForFile( filename ): 110 | # The compilation_commands.json file generated by CMake does not have entries 111 | # for header files. So we do our best by asking the db for flags for a 112 | # corresponding source file, if any. If one exists, the flags for that file 113 | # should be good enough. 114 | if IsHeaderFile( filename ): 115 | basename = os.path.splitext( filename )[ 0 ] 116 | for extension in SOURCE_EXTENSIONS: 117 | replacement_file = basename + extension 118 | if os.path.exists( replacement_file ): 119 | compilation_info = database.GetCompilationInfoForFile( 120 | replacement_file ) 121 | if compilation_info.compiler_flags_: 122 | return compilation_info 123 | return None 124 | return database.GetCompilationInfoForFile( filename ) 125 | 126 | 127 | def FlagsForFile( filename, **kwargs ): 128 | if database: 129 | # Bear in mind that compilation_info.compiler_flags_ does NOT return a 130 | # python list, but a "list-like" StringVec object 131 | compilation_info = GetCompilationInfoForFile( filename ) 132 | if not compilation_info: 133 | return None 134 | 135 | final_flags = MakeRelativePathsInFlagsAbsolute( 136 | compilation_info.compiler_flags_, 137 | compilation_info.compiler_working_dir_ ) 138 | 139 | else: 140 | relative_to = DirectoryOfThisScript() 141 | final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) 142 | 143 | return { 144 | 'flags': final_flags, 145 | 'do_cache': True 146 | } 147 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ############################################################################### 16 | # CMake build rules for FastCDR # 17 | ############################################################################### 18 | cmake_minimum_required(VERSION 3.20) 19 | 20 | # Set CMAKE_BUILD_TYPE to Release by default. 21 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 22 | message(STATUS "Setting build type to 'Release' as none was specified.") 23 | set(CMAKE_BUILD_TYPE Release CACHE STRING 24 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." 25 | FORCE) 26 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 27 | endif() 28 | 29 | # Set BUILD_TESTING to OFF by default. 30 | if(NOT BUILD_TESTING) 31 | message(STATUS "Tests not compiled by default") 32 | set(BUILD_TESTING OFF CACHE BOOL "Enable testing" FORCE) 33 | endif() 34 | 35 | ############################################################################### 36 | # Project # 37 | ############################################################################### 38 | project(fastcdr VERSION 2.3.0 LANGUAGES CXX) 39 | 40 | set(PROJECT_NAME_STYLED "FastCDR") 41 | set(PROJECT_NAME_LARGE "Fast CDR") 42 | string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER) 43 | set(${PROJECT_NAME}_DESCRIPTION_SUMMARY "C++ library for serialize using CDR serialization") 44 | set(${PROJECT_NAME}_DESCRIPTION "eProsima ${PROJECT_NAME_LARGE} library provides two serialization mechanisms. One is the standard CDR serialization mechanism, while the other is a faster implementation that modifies the standard.") 45 | 46 | message(STATUS "Configuring ${PROJECT_NAME_LARGE}") 47 | message(STATUS "Version: ${PROJECT_VERSION}") 48 | 49 | ############################################################################### 50 | # CCache on Windows on CI 51 | ############################################################################### 52 | if (MSVC AND CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "ccache") 53 | foreach(config DEBUG RELWITHDEBINFO) 54 | foreach(lang C CXX) 55 | set(flags_var "CMAKE_${lang}_FLAGS_${config}") 56 | string(REPLACE "/Zi" "/Z7" ${flags_var} "${${flags_var}}") 57 | set(${flags_var} "${${flags_var}}") 58 | endforeach() 59 | endforeach() 60 | endif() 61 | 62 | ############################################################################### 63 | # GCC colors if using CCache 64 | ############################################################################### 65 | if("${CMAKE_CXX_COMPILER_LAUNCHER}" STREQUAL "ccache" AND 66 | CMAKE_COMPILER_IS_GNUCXX AND 67 | CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4,8) 68 | add_compile_options(-fdiagnostics-color=always) 69 | endif() 70 | 71 | ############################################################################### 72 | # Default shared libraries 73 | ############################################################################### 74 | # Global flag to cause add_library() to create shared libraries if on. 75 | # If set to true, this will cause all libraries to be built shared 76 | # unless the library was explicitly added as a static library. 77 | option(BUILD_SHARED_LIBS "Create shared libraries by default" ON) 78 | 79 | ############################################################################### 80 | # Test system configuration 81 | ############################################################################### 82 | include(${PROJECT_SOURCE_DIR}/cmake/common/check_configuration.cmake) 83 | 84 | set(FORCE_CXX "11" CACHE STRING "C++ standard fulfillment selection") 85 | check_stdcxx(${FORCE_CXX}) 86 | 87 | check_endianness() 88 | check_type_sizes() 89 | 90 | ############################################################################### 91 | # Check MSVC architecture 92 | ############################################################################### 93 | if(MSVC OR MSVC_IDE) 94 | check_msvc_arch() 95 | endif() 96 | 97 | ############################################################################### 98 | # Installation paths 99 | ############################################################################### 100 | option(APPEND_PROJECT_NAME_TO_INCLUDEDIR 101 | "When ON headers are installed to a path ending with a folder called \ 102 | ${PROJECT_NAME}. This avoids include directory search order issues when \ 103 | overriding this package from a merged catkin, ament, or colcon workspace." 104 | OFF) 105 | 106 | set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries") 107 | set(_include_dir "include/") 108 | if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) 109 | string(APPEND _include_dir "${PROJECT_NAME}/") 110 | endif() 111 | set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for C++ headers") 112 | unset(_include_dir) 113 | set(LIB_INSTALL_DIR lib${LIB_SUFFIX}/ CACHE PATH "Installation directory for libraries") 114 | set(DATA_INSTALL_DIR share/ CACHE PATH "Installation directory for data") 115 | if(WIN32) 116 | set(DOC_DIR "doc") 117 | else() 118 | set(DOC_DIR "${DATA_INSTALL_DIR}/doc") 119 | endif() 120 | set(DOC_INSTALL_DIR ${DOC_DIR} CACHE PATH "Installation directory for documentation") 121 | set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses") 122 | 123 | ############################################################################### 124 | # Compile library. 125 | ############################################################################### 126 | add_subdirectory(src/cpp) 127 | 128 | ############################################################################### 129 | # Testing 130 | ############################################################################### 131 | enable_testing() 132 | include(CTest) 133 | 134 | if (BUILD_TESTING) 135 | if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) 136 | add_subdirectory(test) 137 | else() 138 | message(INFO "Tests are disabled because the version of CMake is less than 3.22") 139 | endif() 140 | endif() 141 | 142 | ############################################################################### 143 | # Documentation 144 | ############################################################################### 145 | # Add an option to toggle the generation of the API documentation. 146 | option(BUILD_DOCUMENTATION "Use doxygen to create product documentation" OFF) 147 | option(CHECK_DOCUMENTATION "Use doxygen to check code documentation" OFF) 148 | option(GENERATE_PDF_DOC "Use doxygen to generate API Reference PDF" OFF) 149 | 150 | if(CHECK_DOCUMENTATION) 151 | set(BUILD_DOCUMENTATION ON) 152 | endif() 153 | 154 | if(BUILD_DOCUMENTATION) 155 | find_package(Doxygen) 156 | if(NOT DOXYGEN_FOUND) 157 | message(FATAL_ERROR "doxygen is needed to build the documentation. Please install it correctly") 158 | endif() 159 | if(UNIX) 160 | find_program(DOXYFILE_MAKE make) 161 | if(DOXYFILE_MAKE) 162 | message(STATUS "Found Make: ${DOXYFILE_MAKE}") 163 | else() 164 | message(FATAL_ERROR "make is needed to build the documentation. Please install it correctly") 165 | endif() 166 | elseif(WIN32) 167 | set(DOXYFILE_MAKE make.bat) 168 | endif() 169 | 170 | if(NOT CHECK_DOCUMENTATION) 171 | find_program(WGET_EXE wget) 172 | if(WGET_EXE) 173 | message(STATUS "Found WGet: ${WGET_EXE}") 174 | else() 175 | message(FATAL_ERROR "wget is needed to build the documentation. Please install it correctly") 176 | endif() 177 | find_program(UNZIP_EXE unzip) 178 | if(UNZIP_EXE) 179 | message(STATUS "Found Unzip: ${UNZIP_EXE}") 180 | else() 181 | message(FATAL_ERROR "unzip is needed to build the documentation. Please install it correctly") 182 | endif() 183 | endif() 184 | 185 | # Target to create documentation directories 186 | add_custom_target(docdirs 187 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/doc 188 | COMMENT "Creating documentation directory" VERBATIM) 189 | 190 | ### Doxygen ########################3 191 | if(CHECK_DOCUMENTATION) 192 | set(USE_DOT NO) 193 | else() 194 | set(USE_DOT YES) 195 | endif() 196 | if(GENERATE_PDF_DOC) 197 | set(GENERATE_LATEX YES) 198 | else() 199 | set(GENERATE_LATEX NO) 200 | endif() 201 | # Configure the template doxyfile for or specific project 202 | configure_file(doxyfile.in ${PROJECT_BINARY_DIR}/doxyfile @ONLY IMMEDIATE) 203 | # Add custom target to run doxygen when ever the project is build 204 | add_custom_target(doxygen 205 | COMMAND "${DOXYGEN_EXECUTABLE}" "${PROJECT_BINARY_DIR}/doxyfile" 206 | SOURCES "${PROJECT_BINARY_DIR}/doxyfile" 207 | COMMENT "Generating API documentation with doxygen" VERBATIM) 208 | 209 | add_dependencies(doxygen docdirs) 210 | 211 | if(GENERATE_PDF_DOC) 212 | add_custom_target(make_pdf ALL 213 | COMMAND "make" "pdf" 214 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/doxygen/latex 215 | COMMENT "Generating API reference PDF" VERBATIM) 216 | 217 | add_dependencies(make_pdf doxygen) 218 | endif() 219 | 220 | ### README html ######################## 221 | 222 | if(WIN32) 223 | set(README_LOCATION "${PROJECT_BINARY_DIR}/") 224 | set(README_LOCATION_PREFFIX "doc/") 225 | set(README_INSTALL_LOCATION ".") 226 | else() 227 | set(README_LOCATION "${PROJECT_BINARY_DIR}/doc/") 228 | set(README_INSTALL_LOCATION "${DOC_INSTALL_DIR}") 229 | endif() 230 | 231 | configure_file(doc/README.html.in ${README_LOCATION}/README.html @ONLY IMMEDIATE) 232 | 233 | add_custom_target(doc ALL 234 | COMMENT "Generated project documentation" VERBATIM) 235 | 236 | add_dependencies(doc doxygen) 237 | endif() 238 | 239 | 240 | ############################################################################### 241 | # Packaging 242 | ############################################################################### 243 | # Install licenses 244 | install(FILES ${PROJECT_SOURCE_DIR}/LICENSE 245 | DESTINATION ${LICENSE_INSTALL_DIR} 246 | COMPONENT licenses 247 | ) 248 | 249 | if(BUILD_DOCUMENTATION) 250 | 251 | # Instalation of doxygen files 252 | install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/api_reference 253 | DESTINATION ${DOC_INSTALL_DIR} 254 | COMPONENT documentation 255 | ) 256 | 257 | install(FILES "${README_LOCATION}/README.html" 258 | DESTINATION ${README_INSTALL_LOCATION} 259 | COMPONENT documentation 260 | ) 261 | 262 | if(GENERATE_PDF_DOC) 263 | install(FILES "${PROJECT_BINARY_DIR}/doxygen/latex/refman.pdf" 264 | DESTINATION ${DOC_INSTALL_DIR} 265 | RENAME fastcdr-${PROJECT_VERSION}-api-reference.pdf 266 | COMPONENT documentation) 267 | endif() 268 | endif() 269 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | The following documents constitutes a set of guidelines to which contributors must adhere. 4 | 5 | * [Contributions Licensing](#contributions-licensing) 6 | * [Developer Certificate of Origin](#developer-certificate-of-origin) 7 | * [Code Coverage](#code-coverage) 8 | 9 | ## Contributions Licensing 10 | 11 | Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): 12 | 13 | ~~~ 14 | 5. Submission of Contributions. Unless You explicitly state otherwise, 15 | any Contribution intentionally submitted for inclusion in the Work 16 | by You to the Licensor shall be under the terms and conditions of 17 | this License, without any additional terms or conditions. 18 | Notwithstanding the above, nothing herein shall supersede or modify 19 | the terms of any separate license agreement you may have executed 20 | with Licensor regarding such Contributions. 21 | ~~~ 22 | 23 | ## Developer Certificate of Origin 24 | 25 | Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). 26 | 27 | ## Code Coverage 28 | 29 | As stated in [QUALITY.md](QUALITY.md), all contributions to the project must increase line code coverage. 30 | Because of this, contributors are asked to locally run a coverage assessment that ensures that code coverage has increased when compared to the latest execution of the [nightly coverage CI job](http://jenkins.eprosima.com:8080/job/nightly_fastdds_coverage_linux/). 31 | -------------------------------------------------------------------------------- /CTestJenkins.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set(CTEST_SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 16 | set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build") 17 | set(CTEST_TEST_TIMEOUT 300) 18 | 19 | site_name(CTEST_SITE) 20 | set(CTEST_BUILD_NAME "${JENKINS_BUILD_NAME}") 21 | set(CTEST_BUILD_OPTIONS "${JENKINS_BUILD_OPTIONS}") 22 | set(CTEST_BUILD_CONFIGURATION "${JENKINS_BUILD_CONFIGURATION}") 23 | 24 | set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "${CTEST_MEMORYCHECK_COMMAND_OPTIONS} --quiet --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=50 --xml=yes --xml-file=test_%p_memcheck.xml \"--suppressions=${CTEST_SOURCE_DIRECTORY}/valgrind.supp\"") 25 | 26 | set(CTEST_COVERAGE_C_FLAGS "-DCMAKE_C_FLAGS:STRING=-fwrapv -fprofile-arcs -ftest-coverage") 27 | set(CTEST_COVERAGE_CXX_FLAGS "-DCMAKE_CXX_FLAGS:STRING=-fwrapv -fprofile-arcs -ftest-coverage") 28 | set(CTEST_COVERAGE_EXE_LD_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=-fprofile-arcs -ftest-coverage") 29 | set(CTEST_COVERAGE_SHARED_LD_FLAGS "-DCMAKE_SHARED_LINKER_FLAGS:STRING=-fprofile-arcs -ftest-coverage") 30 | 31 | include(ProcessorCount) 32 | ProcessorCount(NUMBER_PROCESSORS) 33 | message("Number of processors: " ${NUMBER_PROCESSORS}) 34 | if(NOT NUMBER_PROCESSORS EQUAL 0) 35 | if(${JENKINS_GENERATOR} MATCHES "Unix Makefiles") 36 | set(CTEST_BUILD_FLAGS "-j${NUMBER_PROCESSORS} -l${NUMBER_PROCESSORS}") 37 | # Error using visual studio with multicore 38 | #elseif(${JENKINS_GENERATOR} MATCHES "Visual Studio") 39 | #set(CTEST_WIN_CXX_FLAGS "-DEPROSIMA_EXTRA_CMAKE_CXX_FLAGS:STRING=/MP") 40 | endif() 41 | set(CTEST_TEST_ARGS ${CTEST_TEST_ARGS} PARALLEL_LEVEL ${NUMBER_PROCESSORS}) 42 | endif() 43 | 44 | # Check CMake version for QUIET parameter 45 | if(${CMAKE_MAJOR_VERSION} GREATER 3 OR (${CMAKE_MAJOR_VERSION} EQUAL 3 AND ${CMAKE_MINOR_VERSION} GREATER 2)) 46 | set(QUIET_ QUIET) 47 | endif() 48 | 49 | ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) 50 | 51 | if(UNIX) 52 | find_program(CTEST_COVERAGE_COMMAND NAMES gcov) 53 | find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) 54 | endif() 55 | 56 | set(CTEST_CONFIGURE_COMMAND "${CMAKE_COMMAND}") 57 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} -DCMAKE_BUILD_TYPE=${CTEST_BUILD_CONFIGURATION}") 58 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} ${CTEST_BUILD_OPTIONS}") 59 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} ${CTEST_WIN_CXX_FLAGS}") 60 | if(CTEST_COVERAGE_COMMAND AND NOT DISABLE_CTEST_COVERAGE) 61 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_COVERAGE_C_FLAGS}\"") 62 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_COVERAGE_CXX_FLAGS}\"") 63 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_COVERAGE_EXE_LD_FLAGS}\"") 64 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_COVERAGE_SHARED_LD_FLAGS}\"") 65 | endif() 66 | set(CTEST_CONFIGURE_COMMAND "${CTEST_CONFIGURE_COMMAND} \"${CTEST_SOURCE_DIRECTORY}\"") 67 | set(CTEST_BUILD_COMMAND "${CMAKE_COMMAND} --build .") 68 | if(WIN32) 69 | set(CTEST_BUILD_COMMAND "${CTEST_BUILD_COMMAND} --config ${CTEST_BUILD_CONFIGURATION}") 70 | endif() 71 | set(CTEST_CONFIGURATION_TYPE ${CTEST_BUILD_CONFIGURATION}) 72 | 73 | ctest_start("${JENKINS_DASHBOARD}" ${QUIET_}) 74 | ctest_configure(RETURN_VALUE CONFIGURING_RET_VALUE ${QUIET_}) 75 | ctest_build(RETURN_VALUE BUILDING_RET_VALUE ${QUIET_}) 76 | ctest_test(${QUIET_}) 77 | if(CTEST_COVERAGE_COMMAND AND NOT DISABLE_CTEST_COVERAGE) 78 | ctest_coverage(${QUIET_}) 79 | endif() 80 | if(CTEST_MEMORYCHECK_COMMAND AND NOT DISABLE_CTEST_MEMORYCHECK) 81 | ctest_memcheck(EXCLUDE_LABEL NoMemoryCheck ${QUIET_}) 82 | endif() 83 | 84 | if(NOT CONFIGURING_RET_VALUE AND NOT BUILDING_RET_VALUE) 85 | message(0) 86 | else() 87 | message(255) 88 | endif() 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /PLATFORM_SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Platform Support 2 | 3 | This document reflects the level of support offered by **eProsima Fast CDR** on different platforms as per the following 4 | definitions: 5 | 6 | ## Tier 1 7 | 8 | Tier 1 platforms are subjected to our unit test suite and other testing tools on a frequent basis including continuous 9 | integration jobs and nightly jobs. 10 | Errors or bugs discovered in these platforms are prioritized for correction by the development team. 11 | Significant errors discovered in Tier 1 platforms can impact release dates and we strive to resolve all known high 12 | priority errors in Tier 1 platforms prior to new version releases. 13 | 14 | ## Tier 2 15 | 16 | Tier 2 platforms are subject to periodic CI testing which runs both builds and tests with publicly accessible results. 17 | The CI is expected to be run at least within a week of relevant changes for the current release of **Fast CDR**. 18 | Installation instructions should be available and up-to-date in order for a platform to be listed in this category. 19 | Package-level binary packages may not be provided but providing a downloadable archive of the built workspace is 20 | encouraged. 21 | Errors may be present in released product versions for Tier 2 platforms. 22 | Known errors in Tier 2 platforms will be addressed subject to resource availability on a best effort basis and may or 23 | may not be corrected prior to new version releases. 24 | One or more entities should be committed to continuing support of the platform. 25 | 26 | ## Tier 3 27 | 28 | Tier 3 platforms are those for which community reports indicate that the release is functional. 29 | The development team does not run the unit test suite or perform any other tests on platforms in Tier 3. 30 | Community members may provide assistance with these platforms. 31 | 32 | ## Platforms 33 | 34 | |Architecture|Ubuntu Jammy (22.04)|MacOS Mojave (10.14)|Windows 10 (VS2019)|Ubuntu Focal (20.04)|Debian Buster (10)| 35 | |------------|--------------------|--------------------|-------------------|--------------------|------------------| 36 | |amd64 |Tier 1 [a][s] |Tier 1 [s] |Tier 1 [a][s] |Tier 3 [a][s] |Tier 3 [s] | 37 | |amd32 | | |Tier 1 [a][s] | | | 38 | |arm64 |Tier 1 [a][s] | | |Tier 3 [a][s] |Tier 3 [s] | 39 | |arm32 |Tier 3 [s] | | |Tier 3 [s] |Tier 3 [s] | 40 | 41 | " [a] " Binary releases are provided as a single archive per platform.\ 42 | " [s] " Compilation from source. 43 | 44 | Other Tier 3 OS: 45 | 46 | * FreeBSD 47 | * VxWorks 48 | * QNX 49 | * Android 11 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Fast CDR](resources/images/github_banner_fastcdr.png)](https://www.eprosima.com/middleware/fast-dds) 2 | 3 |
4 | 5 | 18 | 19 |

20 | 21 |
22 | License 23 | Releases 24 | Issues 25 | Forks 26 | Stars 27 |
28 | Fast CDR Ubuntu CI (nightly) 29 | Linux arm64 CI 30 | Fast CDR Windows CI (nightly) 31 | Fast CDR MacOS CI (nightly) 32 |
33 | 34 |

35 | 36 | *eProsima Fast CDR* is a C++ library that provides two serialization mechanisms. 37 | One is the standard CDR serialization mechanism, while the other is a faster implementation that modifies the standard. 38 | 39 | ## Commercial support 40 | 41 | Looking for commercial support? Write us to info@eprosima.com 42 | 43 | Find more about us at [eProsima’s webpage](https://eprosima.com/). 44 | 45 | ## Build 46 | 47 | **eProsima Fast CDR** provides [CMake][cmake] scripts to build and install it (please read the [installation guide](https://fast-dds.docs.eprosima.com/en/latest/installation/sources/sources_linux.html#cmake-installation) for more details). 48 | Also, in [eProsima][eprosima] you can find packages for Linux using autotools and binaries for Windows. 49 | 50 | [cmake]: http://www.cmake.org 51 | [eprosima]: http://www.eprosima.com 52 | 53 | ## Quality Declaration 54 | 55 | **eprosima Fast CDR** claims to be in the **Quality Level 1** category based on the guidelines provided by [ROS 2](https://ros.org/reps/rep-2004.html). 56 | See the [Quality Declaration](QUALITY.md) for more details. 57 | -------------------------------------------------------------------------------- /RELEASE_SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Release support 2 | 3 | 4 | Please, refer to the [master branch](https://github.com/eProsima/Fast-CDR/blob/master/RELEASE_SUPPORT.md) for the latest version of this document. 5 | 6 | *eProsima Fast CDR* maintains several releases with different support cycles. 7 | **All of them are attached to different *eProsima Fast DDS* releases.** 8 | 9 | ## *eProsima Fast DDS* and *Fast CDR* supported versions compatibility 10 | 11 | |Fast DDS Version|Fast CDR Version|Fast CDR Version branch|Fast CDR Latest Release| 12 | |----------------|----------------|-----------------------|-----------------------| 13 | |3.2|2.3|[2.3.x](https://github.com/eProsima/Fast-CDR/tree/2.3.x)|[v2.3.0](https://github.com/eProsima/Fast-CDR/releases/tag/v2.3.0)| 14 | |3.1, 2.14|2.2|[2.2.x](https://github.com/eProsima/Fast-CDR/tree/2.2.x)|[v2.2.6](https://github.com/eProsima/Fast-CDR/releases/tag/v2.2.6)| 15 | |2.10|1.0|[1.0.x](https://github.com/eProsima/Fast-CDR/tree/1.0.x)|[v1.0.28](https://github.com/eProsima/Fast-CDR/releases/tag/v1.0.28)| 16 | |2.6|1.0|[1.0.x](https://github.com/eProsima/Fast-CDR/tree/1.0.x)|[v1.0.28](https://github.com/eProsima/Fast-CDR/releases/tag/v1.0.28)| 17 | 18 | ## *eProsima Fast DDS* and *Fast CDR* previously supported versions compatibility 19 | 20 | |Fast DDS Version|Fast CDR Version|Fast CDR Version branch|Fast CDR Latest Release|Release Date|EOL Date| 21 | |----------------|----------------|-----------------------|-----------------------|------------|--------| 22 | |2.13|2.1|[2.1.x](https://github.com/eProsima/Fast-CDR/tree/2.1.x)|[v2.1.3](https://github.com/eProsima/Fast-CDR/releases/tag/v2.1.3)|December 2023|July 2024| 23 | |2.12|2.0|[2.0.x](https://github.com/eProsima/Fast-CDR/tree/2.0.x)|[v2.0.0](https://github.com/eProsima/Fast-CDR/releases/tag/v2.0.0)|September 2023|March 2024| 24 | |2.11|1.1|[1.1.x](https://github.com/eProsima/Fast-CDR/tree/1.1.x)|[v1.1.1](https://github.com/eProsima/Fast-CDR/releases/tag/v1.1.1)|May 2023|February 2024| 25 | 26 | For detailed information about the lifecycle of the different *Fast DDS* versions (and their corresponding counterpart in this repository), please refer to the [release support section of the Fast DDS repository](https://github.com/eProsima/Fast-DDS/blob/master/RELEASE_SUPPORT.md). 27 | -------------------------------------------------------------------------------- /VERSIONING.md: -------------------------------------------------------------------------------- 1 | Versioning policy declaration 2 | ============================= 3 | 4 | Starting on v1.0.15, the version numbers for this library will adhere to the versioning policies defined by [Semantic Versioning](https://semver.org/). 5 | 6 | This means that API breaks should only happen between major version changes. 7 | If an ABI break is required, it should be done between minor versions, and it should be clearly stated on the release notes. 8 | 9 | The changes included on each version can be found in the [release notes](https://github.com/eProsima/Fast-CDR/releases) -------------------------------------------------------------------------------- /cmake/common/check_configuration.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # get_set_stdcxx() checks and sets the compiler standard level 16 | # stdversion: the level of standard fullfilment 17 | # stdfeature: the feature name associated with that level 18 | # gcc_flag: the gcc/clang flag for fallback 19 | # cl_flag: the cl flag for fallback 20 | # force: if the user should enforced this standard level or not (FORCE_CXX) 21 | # result: a return variable to check if this level is available 22 | 23 | function(get_set_stdcxx stdversion stdfeature gcc_flag cl_flag force result) 24 | 25 | set(${result} 0 PARENT_SCOPE) 26 | 27 | # check if CMake feature management is available 28 | get_property(CXX_KNOWN_FEATURES GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) 29 | if((stdfeature IN_LIST CXX_KNOWN_FEATURES) AND NOT ("run_fallback_test" IN_LIST ARGV)) 30 | # CMake is aware let's check if is available 31 | if(force AND (stdfeature IN_LIST CMAKE_CXX_COMPILE_FEATURES)) 32 | # is available report and enforce as commanded 33 | # avoid using CACHE variables to avoid polute projects that use this repo as subdir 34 | set(CMAKE_CXX_STANDARD ${stdversion} PARENT_SCOPE) 35 | set(${result} 1 PARENT_SCOPE) 36 | message(STATUS "Enforced ${stdfeature} CMake feature") 37 | elseif(force) 38 | message(FATAL_ERROR "The specified C++ ${stdfeature} feature is not supported using default compiler.") 39 | endif() 40 | else() 41 | # fallback to the old behaviour 42 | include(CheckCXXCompilerFlag) 43 | 44 | if(gcc_flag AND ( 45 | CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR 46 | CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR 47 | CMAKE_CXX_COMPILER_ID MATCHES "QCC")) 48 | # check using gcc/clang flags 49 | check_cxx_compiler_flag(${gcc_flag} SUPPORTS_${stdfeature}) 50 | if(SUPPORTS_${stdfeature} AND force) 51 | add_compile_options($<$:${gcc_flag}>) 52 | set(${result} 1 PARENT_SCOPE) 53 | message(STATUS "Enforced ${gcc_flag} CMake feature") 54 | elseif((NOT SUPPORTS_${stdfeature}) AND force) 55 | message(FATAL_ERROR "Force to support ${stdfeature} but not supported by gnu compiler") 56 | endif() 57 | elseif(cl_flag AND (MSVC OR MSVC_IDE)) 58 | # check using cl flags 59 | check_cxx_compiler_flag(${cl_flag} SUPPORTS_${stdfeature}) 60 | if(SUPPORTS_${stdfeature} AND force) 61 | add_compile_options($<$:${cl_flag}>) 62 | set(${result} 1 PARENT_SCOPE) 63 | message(STATUS "Enforced ${cl_flag} CMake feature") 64 | elseif((NOT SUPPORTS_${stdfeature}) AND force) 65 | message(FATAL_ERROR "Force to support ${stdfeature} but not supported by MSVC") 66 | endif() 67 | elseif(force) 68 | message(WARNING "The specified C++ ${stdfeature} feature is not supported using default compiler.") 69 | endif() 70 | 71 | endif() 72 | 73 | endfunction() 74 | 75 | function(check_stdcxx enforced_level) 76 | 77 | # Map force values to cmake features 78 | set(cxx_levels 23 20 17 14 1Y 11) 79 | set(cxx_features cxx_std_23 cxx_std_20 cxx_std_17 cxx_std_14 NOTFOUND cxx_std_11) 80 | set(gcc_flags -std=c++23 -std=c++20 -std=c++17 -std=c++14 -std=c++1y -std=c++11) 81 | set(cl_flags /std:c++23 /std:c++20 /std:c++17 /std:c++14 NOTFOUND NOTFOUND) 82 | set(HAVE_CXX HAVE_CXX23 HAVE_CXX20 HAVE_CXX17 HAVE_CXX14 HAVE_CXX1Y HAVE_CXX11) 83 | 84 | # Traverse the collection 85 | while(cxx_levels) 86 | 87 | # pop current values 88 | list(POP_FRONT cxx_levels level) 89 | list(POP_FRONT cxx_features feature) 90 | list(POP_FRONT gcc_flags gcc_flag) 91 | list(POP_FRONT cl_flags cl_flag) 92 | list(POP_FRONT HAVE_CXX preprocessor_flag) 93 | 94 | # check if we must enforce this one 95 | if(enforced_level STREQUAL level) 96 | set(force TRUE) 97 | else() 98 | set(force FALSE) 99 | endif() 100 | 101 | # testing framework awareness 102 | set(test) 103 | if("run_fallback_test" IN_LIST ARGV) 104 | set(test "run_fallback_test") 105 | endif() 106 | 107 | # check 108 | get_set_stdcxx(${level} ${feature} ${gcc_flag} ${cl_flag} ${force} result ${test}) 109 | 110 | if(result) 111 | # we are done, mark all levels below as available 112 | set(${preprocessor_flag} 1 PARENT_SCOPE) 113 | # upload local variable fixed by get_set_stdcxx 114 | set(CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD} PARENT_SCOPE) 115 | while(HAVE_CXX) 116 | list(POP_FRONT HAVE_CXX preprocessor_flag) 117 | set(${preprocessor_flag} 1 PARENT_SCOPE) 118 | endwhile() 119 | break() 120 | else() 121 | # If the user doesn't enforce this level the macros are not trustworthy 122 | set(${preprocessor_flag} 0 PARENT_SCOPE) 123 | endif() 124 | 125 | endwhile() 126 | 127 | endfunction() 128 | 129 | macro(check_type_sizes) 130 | include(CheckTypeSize) 131 | check_type_size("long double" TYPE_LONG_DOUBLE LANGUAGE CXX) 132 | set(FASTCDR_SIZEOF_LONG_DOUBLE ${TYPE_LONG_DOUBLE}) 133 | check_type_size("__float128" TYPE_FLOAT128 LANGUAGE CXX) 134 | if(HAVE_TYPE_FLOAT128) 135 | set(FASTCDR_HAVE_FLOAT128 1) 136 | else() 137 | set(FASTCDR_HAVE_FLOAT128 0) 138 | endif() 139 | endmacro() 140 | 141 | macro(check_endianness) 142 | if(CMAKE_CXX_BYTE_ORDER) 143 | if(CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN") 144 | set(FASTCDR_IS_BIG_ENDIAN_TARGET 1) 145 | else() 146 | set(FASTCDR_IS_BIG_ENDIAN_TARGET 0) 147 | endif() 148 | else() 149 | # Test endianness 150 | include(TestBigEndian) 151 | test_big_endian(BIG_ENDIAN) 152 | set(FASTCDR_IS_BIG_ENDIAN_TARGET ${BIG_ENDIAN}) 153 | endif() 154 | endmacro() 155 | 156 | macro(check_msvc_arch) 157 | if(MSVC_VERSION EQUAL 1700) 158 | if(CMAKE_CL_64) 159 | set(MSVC_ARCH "x64Win64VS2012") 160 | else() 161 | set(MSVC_ARCH "i86Win32VS2012") 162 | endif() 163 | elseif(MSVC_VERSION EQUAL 1800) 164 | if(CMAKE_CL_64) 165 | set(MSVC_ARCH "x64Win64VS2013") 166 | else() 167 | set(MSVC_ARCH "i86Win32VS2013") 168 | endif() 169 | elseif(MSVC_VERSION EQUAL 1900) 170 | if(CMAKE_CL_64) 171 | set(MSVC_ARCH "x64Win64VS2015") 172 | else() 173 | set(MSVC_ARCH "i86Win32VS2015") 174 | endif() 175 | elseif(MSVC_VERSION GREATER 1900) 176 | if(CMAKE_CL_64) 177 | set(MSVC_ARCH "x64Win64VS2017") 178 | else() 179 | set(MSVC_ARCH "i86Win32VS2017") 180 | endif() 181 | else() 182 | if(CMAKE_CL_64) 183 | set(MSVC_ARCH "x64Win64VSUnknown") 184 | else() 185 | set(MSVC_ARCH "i86Win32VSUnknown") 186 | endif() 187 | endif() 188 | endmacro() 189 | 190 | function(set_common_compile_options target) 191 | enable_language(C) 192 | enable_language(CXX) 193 | if(MSVC OR MSVC_IDE) 194 | target_compile_options(${target} PRIVATE /W4) 195 | else() 196 | target_compile_options(${target} PRIVATE -Wall 197 | -Wextra 198 | -Wshadow 199 | $<$:-Wnon-virtual-dtor> 200 | -pedantic 201 | -Wcast-align 202 | -Wunused 203 | $<$:-Woverloaded-virtual> 204 | -Wconversion 205 | -Wsign-conversion 206 | $<$:-Wlogical-op> 207 | $<$,$>:-Wuseless-cast> 208 | -Wdouble-promotion 209 | $<$:-Wold-style-cast> 210 | $<$,$,6.0.0>>>,$,$,6.0.0>>>>:-Wnull-dereference> 211 | $<$,$,7.0.0>>>,$,$,7.0.0>>>>:-Wduplicated-branches> 212 | $<$,$,6.0.0>>>,$,$,6.0.0>>>>:-Wduplicated-cond> 213 | $<$,$,7.0.0>>>,$,$,7.0.0>>>>:-Wrestrict> 214 | ) 215 | endif() 216 | endfunction() 217 | -------------------------------------------------------------------------------- /cmake/common/find_or_add_gtest.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | macro(find_or_add_gtest) 16 | # Check if building on an ament context, i.e. ROS 2 17 | # Thanks to https://github.com/facontidavide/PlotJuggler/blob/main/CMakeLists.txt#L66 18 | find_package(ament_cmake QUIET) 19 | 20 | # This is a ROS 2 build 21 | if(ament_cmake_FOUND) 22 | # Find all GTest vendor required packages 23 | find_package(ament_cmake REQUIRED) 24 | find_package(gtest_vendor REQUIRED) 25 | find_package(ament_cmake_gtest REQUIRED) 26 | 27 | # Find GTest 28 | ament_find_gtest() 29 | 30 | # Add aliases for GTest libraries so we can use them as targets independently of the context 31 | add_library(GTest::gtest ALIAS gtest) 32 | add_library(GTest::gtest_main ALIAS gtest_main) 33 | target_link_libraries(gtest_main gtest) 34 | 35 | # This is a non-ROS 2 build 36 | else() 37 | # Find GTest normally 38 | find_package(GTest CONFIG REQUIRED) 39 | endif() 40 | endmacro() 41 | -------------------------------------------------------------------------------- /cmake/packaging/Config.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@) 16 | 17 | @PACKAGE_INIT@ 18 | 19 | @FASTCDR_PACKAGE_OPT_BIN_DIR_CONDITION@ 20 | set_and_check(@PROJECT_NAME@_BIN_DIR "@PACKAGE_BIN_INSTALL_DIR@") 21 | endif() 22 | set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") 23 | set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") 24 | 25 | set(fastcdr_known_comps static shared) 26 | set(fastcdr_comp_static NO) 27 | set(fastcdr_comp_shared NO) 28 | foreach (fastcdr_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS) 29 | if (fastcdr_comp IN_LIST fastcdr_known_comps) 30 | set(fastcdr_comp_${fastcdr_comp} YES) 31 | else () 32 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE 33 | "fastcdr does not recognize component `${fastcdr_comp}`.") 34 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) 35 | return() 36 | endif () 37 | endforeach () 38 | 39 | if (fastcdr_comp_static AND fastcdr_comp_shared) 40 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE 41 | "fastcdr `static` and `shared` components are mutually exclusive.") 42 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) 43 | return() 44 | endif () 45 | 46 | set(fastcdr_static_targets "${CMAKE_CURRENT_LIST_DIR}/fastcdr-static-targets.cmake") 47 | set(fastcdr_shared_targets "${CMAKE_CURRENT_LIST_DIR}/fastcdr-shared-targets.cmake") 48 | 49 | macro(fastcdr_load_targets type) 50 | if (NOT EXISTS "${fastcdr_${type}_targets}") 51 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE 52 | "fastcdr `${type}` libraries were requested but not found.") 53 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) 54 | return() 55 | endif () 56 | include("${fastcdr_${type}_targets}") 57 | endmacro() 58 | 59 | if (fastcdr_comp_static) 60 | fastcdr_load_targets(static) 61 | elseif (fastcdr_comp_shared) 62 | fastcdr_load_targets(shared) 63 | elseif (DEFINED fastcdr_SHARED_LIBS AND fastcdr_SHARED_LIBS) 64 | fastcdr_load_targets(shared) 65 | elseif (DEFINED fastcdr_SHARED_LIBS AND NOT fastcdr_SHARED_LIBS) 66 | fastcdr_load_targets(static) 67 | elseif (BUILD_SHARED_LIBS) 68 | if (EXISTS "${fastcdr_shared_targets}") 69 | fastcdr_load_targets(shared) 70 | else () 71 | fastcdr_load_targets(static) 72 | endif () 73 | else () 74 | if (EXISTS "${fastcdr_static_targets}") 75 | fastcdr_load_targets(static) 76 | else () 77 | fastcdr_load_targets(shared) 78 | endif () 79 | endif () 80 | -------------------------------------------------------------------------------- /cmake/packaging/windows/fastcdr-config.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | if(MSVC_VERSION LESS_EQUAL 1900) 16 | message(FATAL_ERROR "Visual Studio version ${MSVC_VERSION} is no longer supported") 17 | else() 18 | if(CMAKE_CL_64) 19 | include("${CMAKE_CURRENT_LIST_DIR}/../share/fastcdr-x64Win64VS2019/cmake/fastcdr-config.cmake") 20 | else() 21 | include("${CMAKE_CURRENT_LIST_DIR}/../share/fastcdr-i86Win32VS2019/cmake/fastcdr-config.cmake") 22 | endif() 23 | endif() 24 | 25 | -------------------------------------------------------------------------------- /cmake/testing/GoogleTest.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include(GoogleTest) 16 | 17 | function(gtest_discover_tests TARGET) 18 | cmake_minimum_required(VERSION 3.22) 19 | if (WIN32) 20 | add_custom_command( 21 | TARGET ${TARGET} POST_BUILD 22 | COMMAND ${CMAKE_COMMAND} -DTARGET=${TARGET} -DCONFIG=$ -DRUNTIME_LIST=$ -P ${CMAKE_SOURCE_DIR}/cmake/testing/generate_google_test_win_wrapper.cmake 23 | COMMAND_EXPAND_LISTS 24 | VERBATIM 25 | ) 26 | 27 | set(CMAKE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_win_wrapper_$.bat") 28 | endif() 29 | _gtest_discover_tests(${TARGET} ${ARGN}) 30 | endfunction() 31 | -------------------------------------------------------------------------------- /cmake/testing/generate_google_test_win_wrapper.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | if (NOT DEFINED TARGET) 16 | message(FATAL_ERROR "This scrips needs TARGET variable set") 17 | endif() 18 | if (NOT DEFINED CONFIG) 19 | message(FATAL_ERROR "This scrips needs CONFIG variable set") 20 | endif() 21 | if (NOT DEFINED RUNTIME_LIST) 22 | message(FATAL_ERROR "This scrips needs RUNTIME_LIST variable set") 23 | endif() 24 | 25 | set(_path "") 26 | 27 | foreach(_runtime_dll IN LISTS RUNTIME_LIST) 28 | cmake_path(GET _runtime_dll PARENT_PATH _runtime_dll_path) 29 | cmake_path(NATIVE_PATH _runtime_dll_path _runtime_dll_path_native) 30 | list(APPEND _path "${_runtime_dll_path_native}") 31 | endforeach() 32 | 33 | list(REMOVE_DUPLICATES _path) 34 | 35 | cmake_path(NATIVE_PATH CMAKE_COMMAND _cmake_command) 36 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_win_wrapper_${CONFIG}.bat" " 37 | @ECHO OFF 38 | set \"PATH=${_path};%PATH%\" 39 | \"${_cmake_command}\" %* 40 | ") 41 | -------------------------------------------------------------------------------- /colcon.pkg: -------------------------------------------------------------------------------- 1 | name: fastcdr 2 | type: cmake 3 | dependencies: 4 | # Needed for test compilation in ROS 2 CI 5 | - ament_cmake_gtest 6 | - ament_cmake 7 | # Needed for test compilation in eProsima CI 8 | - googletest-distribution 9 | -------------------------------------------------------------------------------- /doc/Users Manual.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/doc/Users Manual.odt -------------------------------------------------------------------------------- /doc/information/standards/10-11-01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/doc/information/standards/10-11-01.pdf -------------------------------------------------------------------------------- /doc/information/standards/11-11-02-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/doc/information/standards/11-11-02-1.pdf -------------------------------------------------------------------------------- /doc/information/standards/13-02-04.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/doc/information/standards/13-02-04.pdf -------------------------------------------------------------------------------- /fastcdr.repos: -------------------------------------------------------------------------------- 1 | repositories: 2 | fastcdr: 3 | type: git 4 | url: https://github.com/eProsima/Fast-CDR.git 5 | version: master 6 | -------------------------------------------------------------------------------- /include/fastcdr/CdrEncoding.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_CDRENCODING_HPP_ 16 | #define _FASTCDR_CDRENCODING_HPP_ 17 | 18 | #include 19 | 20 | namespace eprosima { 21 | namespace fastcdr { 22 | 23 | //! @brief This enumeration represents the kinds of CDR serialization supported by eprosima::fastcdr::CDR. 24 | typedef enum 25 | { 26 | //! @brief Common CORBA CDR serialization. 27 | CORBA_CDR = 0, 28 | //! @brief DDS CDR serialization. 29 | DDS_CDR = 1, 30 | //! @brief XCDRv1 encoding defined by standard DDS X-Types 1.3 31 | XCDRv1 = 2, 32 | //! @brief XCDRv2 encoding defined by standard DDS X-Types 1.3 33 | XCDRv2 = 3 34 | } CdrVersion; 35 | 36 | //! @brief This enumeration represents the supported XCDR encoding algorithms. 37 | typedef enum : uint8_t 38 | { 39 | //! @brief Specifies that the content is PLAIN_CDR. 40 | PLAIN_CDR = 0x0, 41 | //! @brief Specifies that the content is PL_CDR, 42 | PL_CDR = 0x2, 43 | //! @brief Specifies that the content is PLAIN_CDR2. 44 | PLAIN_CDR2 = 0x6, 45 | //! @brief Specifies that the content is DELIMIT_CDR2. 46 | DELIMIT_CDR2 = 0x8, 47 | //! @brief Specifies that the content is PL_CDR2. 48 | PL_CDR2 = 0xa 49 | } EncodingAlgorithmFlag; 50 | 51 | } // namespace fastcdr 52 | } // namespace eprosima 53 | 54 | #endif // _FASTCDR_CDRENCODING_HPP_ 55 | -------------------------------------------------------------------------------- /include/fastcdr/cdr/fixed_size_string.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /*! 16 | * @file fixed_size_string.hpp 17 | * 18 | */ 19 | 20 | #ifndef FASTCDR_UTILS_FIXED_SIZE_STRING_HPP_ 21 | #define FASTCDR_UTILS_FIXED_SIZE_STRING_HPP_ 22 | 23 | #include 24 | #include 25 | 26 | #ifdef _WIN32 27 | #define MEMCCPY _memccpy 28 | #else 29 | #define MEMCCPY memccpy 30 | #endif // ifdef _WIN32 31 | 32 | namespace eprosima { 33 | namespace fastcdr { 34 | 35 | /** 36 | * @brief Template class for non-alloc strings. 37 | * 38 | * Will be truncated when assigned from a longer string. 39 | * 40 | * @tparam MAX_CHARS Maximum number of characters is specified as the template parameter. 41 | * Space for an additional null terminator will be reserved. 42 | */ 43 | template 44 | struct fixed_string 45 | { 46 | public: 47 | 48 | //! @brief Maximum number of characters. 49 | static constexpr size_t max_size = MAX_CHARS; 50 | 51 | //! @brief Default constructor. 52 | fixed_string() noexcept 53 | { 54 | memset(string_data, 0, sizeof(string_data)); 55 | string_len = 0; 56 | } 57 | 58 | // We don't need to define copy/move constructors/assignment operators as the default ones would be enough 59 | 60 | /*! 61 | * @brief Constructs from a char array 62 | * @param[in] c_array Char array to be constructed from. 63 | * @param[in] n_chars Number of characters of the Char array 64 | */ 65 | fixed_string( 66 | const char* c_array, 67 | size_t n_chars) noexcept 68 | { 69 | assign(c_array, n_chars); 70 | } 71 | 72 | /*! 73 | * @brief Assigns from a char array 74 | * @param[in] c_array Char array to be assigned from. 75 | * @param[in] n_chars Number of characters of the Char array. 76 | * @return Reference of this instance. 77 | */ 78 | fixed_string& assign( 79 | const char* c_array, 80 | size_t n_chars) noexcept 81 | { 82 | string_len = (nullptr == c_array) ? 0 : 83 | (MAX_CHARS < n_chars) ? MAX_CHARS : n_chars; 84 | if (0 < string_len) 85 | { 86 | memcpy(string_data, c_array, string_len); 87 | } 88 | return *this; 89 | } 90 | 91 | /*! 92 | * @brief Constructs from a C string. 93 | * @param[in] c_string Pointer to the C string. 94 | */ 95 | fixed_string ( 96 | const char* c_string) noexcept 97 | : fixed_string() 98 | { 99 | set(c_string != nullptr ? c_string : ""); 100 | } 101 | 102 | /*! 103 | * @brief Assigns from a C string. 104 | * @param[in] c_string Pointer to the C string. 105 | * @return Reference of this instance. 106 | */ 107 | fixed_string& operator = ( 108 | const char* c_string) noexcept 109 | { 110 | set(c_string != nullptr ? c_string : ""); 111 | return *this; 112 | } 113 | 114 | /*! 115 | * @brief Constructs from a std::string. 116 | * @param[in] str Reference to the std::string. 117 | */ 118 | fixed_string ( 119 | const std::string& str) noexcept 120 | : fixed_string() 121 | { 122 | set(str.c_str()); 123 | } 124 | 125 | /*! 126 | * @brief Assigns from a std::string. 127 | * @param[in] str Reference to the std::string. 128 | * return Reference of this instance. 129 | */ 130 | fixed_string& operator = ( 131 | const std::string& str) noexcept 132 | { 133 | set(str.c_str()); 134 | return *this; 135 | } 136 | 137 | /*! 138 | * @brief Assigns from a fixed_string of any size. 139 | * @param[in] rhs Reference to the fixed_string. 140 | * return Reference of this instance. 141 | */ 142 | template fixed_string& operator = ( 143 | const fixed_string& rhs) noexcept 144 | { 145 | set(rhs.c_str()); 146 | return *this; 147 | } 148 | 149 | /*! 150 | * @brief Converts to C string. 151 | * @return Pointer to the C string. 152 | */ 153 | const char* c_str() const noexcept 154 | { 155 | return string_data; 156 | } 157 | 158 | /*! 159 | * @brief Converts to std::string. 160 | * @return Reference to the std::string. 161 | */ 162 | std::string to_string() const 163 | { 164 | return std::string(string_data); 165 | } 166 | 167 | /*! 168 | * @brief Compares equality with a C string. 169 | * @param[in] rhs C string to be compared with. 170 | * @return `true` if strings are equal. `false` otherwise. 171 | */ 172 | bool operator == ( 173 | const char* rhs) const noexcept 174 | { 175 | return strncmp(string_data, rhs, MAX_CHARS) == 0; 176 | } 177 | 178 | /*! 179 | * @brief Compares equality with a std::string. 180 | * @param[in] rhs std::string to be compared with. 181 | * @return `true` if strings are equal. `false` otherwise. 182 | */ 183 | bool operator == ( 184 | const std::string& rhs) const noexcept 185 | { 186 | return strncmp(string_data, rhs.c_str(), MAX_CHARS) == 0; 187 | } 188 | 189 | /*! 190 | * @brief Compares equality with a fixed_string of any size. 191 | * @param[in] rhs fixed_string to be compared with. 192 | * @return `true` if strings are equal. `false` otherwise. 193 | */ 194 | template bool operator == ( 195 | const fixed_string& rhs) const noexcept 196 | { 197 | return strncmp(string_data, rhs.c_str(), MAX_CHARS) == 0; 198 | } 199 | 200 | /*! 201 | * @brief Compares inequality with a C string. 202 | * @param[in] rhs C string to be compared with. 203 | * @return `true` if strings are not equal. `false` otherwise. 204 | */ 205 | bool operator != ( 206 | const char* rhs) const noexcept 207 | { 208 | return !(*this == rhs); 209 | } 210 | 211 | /*! 212 | * @brief Compares inequality with a std::string. 213 | * @param[in] rhs std::string to be compared with. 214 | * @return `true` if strings are not equal. `false` otherwise. 215 | */ 216 | bool operator != ( 217 | const std::string& rhs) const noexcept 218 | { 219 | return !(*this == rhs); 220 | } 221 | 222 | /*! 223 | * @brief Compares inequality with a fixed_string of any size. 224 | * @param[in] rhs fixed_string to be compared with. 225 | * @return `true` if strings are not equal. `false` otherwise. 226 | */ 227 | template bool operator != ( 228 | const fixed_string& rhs) const noexcept 229 | { 230 | return !(*this == rhs); 231 | } 232 | 233 | /*! 234 | * @brief Compares relational less than with a fixed_string of any size. 235 | * @param[in] rhs fixed_string to be compared with. 236 | * @return `true` if this string is less than the provided one. `false` otherwise. 237 | */ 238 | template bool operator < ( 239 | const fixed_string& rhs) const noexcept 240 | { 241 | return 0 > compare(rhs); 242 | } 243 | 244 | /*! 245 | * @brief Compares relational greater than with a fixed_string of any size. 246 | * @param[in] rhs fixed_string to be compared with. 247 | * @return `true` if this string is greater than the provided one. `false` otherwise. 248 | */ 249 | template bool operator > ( 250 | const fixed_string& rhs) const noexcept 251 | { 252 | return 0 < compare(rhs); 253 | } 254 | 255 | /*! 256 | * @brief Compares relational less than with a std::string of any size. 257 | * @param[in] rhs std::string to be compared with. 258 | * @return `true` if this string is less than the provided one. `false` otherwise. 259 | */ 260 | bool operator < ( 261 | const std::string& rhs) const noexcept 262 | { 263 | return 0 > compare(rhs); 264 | } 265 | 266 | /*! 267 | * @brief Compares relational greater than with a std::string of any size. 268 | * @param[in] rhs std::string to be compared with. 269 | * @return `true` if this string is greater than the provided one. `false` otherwise. 270 | */ 271 | bool operator > ( 272 | const std::string& rhs) const noexcept 273 | { 274 | return 0 < compare(rhs); 275 | } 276 | 277 | /*! 278 | * @brief Casts to a C string. 279 | */ 280 | operator const char* () const noexcept { 281 | return c_str(); 282 | } 283 | 284 | /*! 285 | * @brief Returns the size of the string. 286 | * @return Length of the string. 287 | */ 288 | size_t size() const noexcept 289 | { 290 | return string_len; 291 | } 292 | 293 | /*! 294 | * @brief Compares with a C string. 295 | * @param[in] str C string to be compared with. 296 | * @return Integer value with the result of the comparison as described in `std::string::compare()`. 297 | */ 298 | int compare( 299 | const char* str) const noexcept 300 | { 301 | return strncmp(string_data, str, MAX_CHARS); 302 | } 303 | 304 | /*! 305 | * @brief Compares with a std::string. 306 | * @param[in] str std::string to be compared with. 307 | * @return Integer value with the result of the comparison as described in `std::string::compare()`. 308 | */ 309 | int compare( 310 | const std::string& str) const noexcept 311 | { 312 | return strncmp(string_data, str.c_str(), MAX_CHARS); 313 | } 314 | 315 | /*! 316 | * @brief Compares with a fixed_string 317 | * @param[in] str fixed_string to be compared with. 318 | * @return Integer value with the result of the comparison as described in `std::string::compare()`. 319 | */ 320 | template int compare( 321 | const fixed_string& str) const noexcept 322 | { 323 | return strncmp(string_data, str.c_str(), MAX_CHARS); 324 | } 325 | 326 | private: 327 | 328 | void set( 329 | const char* c_string) noexcept 330 | { 331 | char* result = static_cast(MEMCCPY(string_data, c_string, '\0', MAX_CHARS)); 332 | string_len = (result == nullptr) ? MAX_CHARS : static_cast(result - string_data) - 1u; 333 | } 334 | 335 | char string_data[MAX_CHARS + 1]; ///< Holds string data, including ending null character. 336 | size_t string_len; ///< Holds current string length. 337 | }; 338 | 339 | using string_255 = fixed_string<255>; 340 | 341 | } /* namespace fastcdr */ 342 | } /* namespace eprosima */ 343 | 344 | #endif /* FASTCDR_UTILS_FIXED_SIZE_STRING_HPP_ */ 345 | -------------------------------------------------------------------------------- /include/fastcdr/config.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_CONFIG_H_ 16 | #define _FASTCDR_CONFIG_H_ 17 | 18 | #define FASTCDR_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ 19 | #define FASTCDR_VERSION_MINOR @PROJECT_VERSION_MINOR@ 20 | #define FASTCDR_VERSION_MICRO @PROJECT_VERSION_PATCH@ 21 | #define FASTCDR_VERSION_STR "@PROJECT_VERSION@" 22 | 23 | // C++11 support defines 24 | #ifndef HAVE_CXX11 25 | #define HAVE_CXX11 @HAVE_CXX11@ 26 | #endif // ifndef HAVE_CXX11 27 | 28 | // Endianness defines 29 | #ifndef FASTCDR_IS_BIG_ENDIAN_TARGET 30 | #define FASTCDR_IS_BIG_ENDIAN_TARGET @FASTCDR_IS_BIG_ENDIAN_TARGET@ 31 | #endif // ifndef FASTCDR_IS_BIG_ENDIAN_TARGET 32 | 33 | #ifndef FASTCDR_HAVE_FLOAT128 34 | #define FASTCDR_HAVE_FLOAT128 @FASTCDR_HAVE_FLOAT128@ 35 | #endif // ifndef FASTCDR_HAVE_FLOAT128 36 | 37 | #ifndef FASTCDR_SIZEOF_LONG_DOUBLE 38 | #define FASTCDR_SIZEOF_LONG_DOUBLE @FASTCDR_SIZEOF_LONG_DOUBLE@ 39 | #endif // ifndef FASTCDR_SIZEOF_LONG_DOUBLE 40 | 41 | #if defined(__ARM_ARCH) && __ARM_ARCH <= 7 42 | #define FASTCDR_ARM32 43 | #endif // if defined(__ARM_ARCH) && __ARM_ARCH <= 7 44 | 45 | #if defined(__GNUC__) && !defined(__clang__) 46 | #define TEMPLATE_SPEC 47 | #else 48 | #define TEMPLATE_SPEC template<> 49 | #endif // if defined(__GNUC__) && !defined(__clang__) 50 | 51 | #endif // _FASTCDR_CONFIG_H_ 52 | -------------------------------------------------------------------------------- /include/fastcdr/config/doxygen_modules.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * @file doxygen_modules.h 17 | */ 18 | 19 | #ifndef FASTCDR_DOXYGEN_MODULES_H_ 20 | #define FASTCDR_DOXYGEN_MODULES_H_ 21 | 22 | /*! 23 | * @defgroup FASTCDRAPIREFERENCE FastCDR Serializer API Reference 24 | * @brief FastCDR Serializer internal API groped in modules. 25 | */ 26 | 27 | /*! 28 | * @defgroup EXCEPTIONMODULE Exceptions 29 | * @ingroup FASTCDRAPIREFERENCE 30 | * @brief Exceptions used by the FastCDR API. 31 | * All exceptions defined in this module are thrown by the FastCDR library. 32 | */ 33 | 34 | #endif /* FASTCDR_DOXYGEN_MODULES_H_ */ 35 | -------------------------------------------------------------------------------- /include/fastcdr/detail/container_recursive_inspector.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_DETAIL_CONTAINERRECURSIVEINSPECTOR_HPP_ 16 | #define _FASTCDR_DETAIL_CONTAINERRECURSIVEINSPECTOR_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace eprosima { 23 | namespace fastcdr { 24 | 25 | // Helpers to deduce multi-array of primitives. 26 | /// Basis 27 | constexpr bool is_multi_array_primitive( 28 | ...) 29 | { 30 | return false; 31 | } 32 | 33 | /// Specializations 34 | template ::value || 36 | std::is_arithmetic<_T>::value>::type* = nullptr> 37 | constexpr bool is_multi_array_primitive( 38 | _T const*) 39 | { 40 | return true; 41 | } 42 | 43 | template 44 | constexpr bool is_multi_array_primitive( 45 | std::array<_T, _N> const*) 46 | { 47 | return is_multi_array_primitive(static_cast<_T const*>(nullptr)); 48 | } 49 | 50 | } // namespace fastcdr 51 | } // namespace eprosima 52 | 53 | #endif // _FASTCDR_DETAIL_CONTAINERRECURSIVEINSPECTOR_HPP_ 54 | -------------------------------------------------------------------------------- /include/fastcdr/eProsima_auto_link.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /* 16 | Expected defines. 17 | 18 | - EPROSIMA_LIB_NAME 19 | - FASTCDR_VERSION_MAJOR 20 | - FASTCDR_VERSION_MINOR 21 | */ 22 | 23 | #if defined(_MSC_VER) 24 | #define EPROSIMA_STRINGIZE(X) EPROSIMA_DO_STRINGIZE(X) 25 | #define EPROSIMA_DO_STRINGIZE(X) #X 26 | 27 | #if defined(_DEBUG) 28 | #define EPROSIMA_LIB_DEBUG_TAG "d" 29 | #else 30 | #define EPROSIMA_LIB_DEBUG_TAG 31 | #endif // _DEBUG 32 | 33 | // Select linkage option. 34 | #if (defined(_DLL) || defined(_RTLDLL)) && defined(EPROSIMA_DYN_LINK) 35 | #define EPROSIMA_LIB_PREFIX 36 | #elif defined(EPROSIMA_DYN_LINK) 37 | #error "Mixing a dll eprosima library with a static runtime is a bad idea" 38 | #else 39 | #define EPROSIMA_LIB_PREFIX "lib" 40 | #endif // if (defined(_DLL) || defined(_RTLDLL)) && defined(EPROSIMA_DYN_LINK) 41 | 42 | // Include library 43 | #if defined(EPROSIMA_LIB_NAME) \ 44 | && defined(EPROSIMA_LIB_PREFIX) \ 45 | && defined(EPROSIMA_LIB_DEBUG_TAG) \ 46 | && defined(FASTCDR_VERSION_MAJOR) \ 47 | && defined(FASTCDR_VERSION_MINOR) 48 | #pragma \ 49 | comment(lib, EPROSIMA_LIB_PREFIX EPROSIMA_STRINGIZE(EPROSIMA_LIB_NAME) EPROSIMA_LIB_DEBUG_TAG "-" EPROSIMA_STRINGIZE(FASTCDR_VERSION_MAJOR) "." EPROSIMA_STRINGIZE(FASTCDR_VERSION_MINOR) ".lib") 50 | #else 51 | #error "Some required macros where not defined" 52 | #endif // if defined(EPROSIMA_LIB_NAME) && defined(EPROSIMA_LIB_PREFIX) && defined(EPROSIMA_LIB_DEBUG_TAG) && defined(FASTCDR_VERSION_MAJOR) && defined(FASTCDR_VERSION_MINOR) 53 | 54 | #endif // _MSC_VER 55 | 56 | // Undef macros 57 | #ifdef EPROSIMA_LIB_PREFIX 58 | #undef EPROSIMA_LIB_PREFIX 59 | #endif // ifdef EPROSIMA_LIB_PREFIX 60 | 61 | #ifdef EPROSIMA_LIB_NAME 62 | #undef EPROSIMA_LIB_NAME 63 | #endif // ifdef EPROSIMA_LIB_NAME 64 | 65 | #ifdef EPROSIMA_LIB_DEBUG_TAG 66 | #undef EPROSIMA_LIB_DEBUG_TAG 67 | #endif // ifdef EPROSIMA_LIB_DEBUG_TAG 68 | -------------------------------------------------------------------------------- /include/fastcdr/exceptions/BadOptionalAccessException.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_EXCEPTIONS_BADOPTIONALACCESSEXCEPTION_H_ 16 | #define _FASTCDR_EXCEPTIONS_BADOPTIONALACCESSEXCEPTION_H_ 17 | 18 | #include "Exception.h" 19 | 20 | namespace eprosima { 21 | namespace fastcdr { 22 | namespace exception { 23 | /*! 24 | * @brief This class is thrown as an exception when accessing the value of a null optional. 25 | * @ingroup EXCEPTIONMODULE 26 | */ 27 | class Cdr_DllAPI BadOptionalAccessException : public Exception 28 | { 29 | public: 30 | 31 | /*! 32 | * @brief Default constructor. 33 | * 34 | * @param message An error message. This message pointer is copied. 35 | */ 36 | BadOptionalAccessException( 37 | const char* const& message) noexcept; 38 | 39 | /*! 40 | * @brief Default copy constructor. 41 | * 42 | * @param ex BadOptionalAccessException that will be copied. 43 | */ 44 | BadOptionalAccessException( 45 | const BadOptionalAccessException& ex) noexcept; 46 | 47 | /*! 48 | * @brief Default move constructor. 49 | * 50 | * @param ex BadOptionalAccessException that will be moved. 51 | */ 52 | BadOptionalAccessException( 53 | BadOptionalAccessException&& ex) noexcept; 54 | 55 | /*! 56 | * @brief Assigment operation. 57 | * 58 | * @param ex BadOptionalAccessException that will be copied. 59 | */ 60 | BadOptionalAccessException& operator =( 61 | const BadOptionalAccessException& ex) noexcept; 62 | 63 | /*! 64 | * @brief Assigment operation. 65 | * 66 | * @param ex BadOptionalAccessException that will be moved. 67 | */ 68 | BadOptionalAccessException& operator =( 69 | BadOptionalAccessException&& ex) noexcept; 70 | 71 | //! @brief Default destructor 72 | virtual ~BadOptionalAccessException() noexcept; 73 | 74 | //! @brief This function throws the object as exception. 75 | void raise() const override; 76 | 77 | //! @brief Default message used in the library. 78 | static const char* const BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT; 79 | }; 80 | } //namespace exception 81 | } //namespace fastcdr 82 | } //namespace eprosima 83 | #endif // _FASTCDR_EXCEPTIONS_BADOPTIONALACCESSEXCEPTION_H_ 84 | -------------------------------------------------------------------------------- /include/fastcdr/exceptions/BadParamException.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_EXCEPTIONS_BADPARAMEXCEPTION_H_ 16 | #define _FASTCDR_EXCEPTIONS_BADPARAMEXCEPTION_H_ 17 | 18 | #include "Exception.h" 19 | 20 | namespace eprosima { 21 | namespace fastcdr { 22 | namespace exception { 23 | /*! 24 | * @brief This class is thrown as an exception when an invalid parameter is being serialized. 25 | * @ingroup EXCEPTIONMODULE 26 | */ 27 | class Cdr_DllAPI BadParamException : public Exception 28 | { 29 | public: 30 | 31 | /*! 32 | * @brief Default constructor. 33 | * 34 | * @param message An error message. This message pointer is copied. 35 | */ 36 | BadParamException( 37 | const char* const& message) noexcept; 38 | 39 | /*! 40 | * @brief Default copy constructor. 41 | * 42 | * @param ex BadParamException that will be copied. 43 | */ 44 | BadParamException( 45 | const BadParamException& ex) noexcept; 46 | 47 | /*! 48 | * @brief Default move constructor. 49 | * 50 | * @param ex BadParamException that will be moved. 51 | */ 52 | BadParamException( 53 | BadParamException&& ex) noexcept; 54 | 55 | /*! 56 | * @brief Assigment operation. 57 | * 58 | * @param ex BadParamException that will be copied. 59 | */ 60 | BadParamException& operator =( 61 | const BadParamException& ex) noexcept; 62 | 63 | /*! 64 | * @brief Assigment operation. 65 | * 66 | * @param ex BadParamException that will be moved. 67 | */ 68 | BadParamException& operator =( 69 | BadParamException&& ex) noexcept; 70 | 71 | //! @brief Default destructor 72 | virtual ~BadParamException() noexcept; 73 | 74 | //! @brief This function throws the object as exception. 75 | void raise() const override; 76 | 77 | //! @brief Default message used in the library. 78 | static const char* const BAD_PARAM_MESSAGE_DEFAULT; 79 | }; 80 | } //namespace exception 81 | } //namespace fastcdr 82 | } //namespace eprosima 83 | #endif // _FASTCDR_EXCEPTIONS_BADPARAMEXCEPTION_H_ 84 | -------------------------------------------------------------------------------- /include/fastcdr/exceptions/Exception.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_EXCEPTIONS_EXCEPTION_H_ 16 | #define _FASTCDR_EXCEPTIONS_EXCEPTION_H_ 17 | 18 | #include "../fastcdr_dll.h" 19 | #include 20 | 21 | namespace eprosima { 22 | namespace fastcdr { 23 | namespace exception { 24 | /*! 25 | * @brief This abstract class is used to create exceptions. 26 | * @ingroup EXCEPTIONMODULE 27 | */ 28 | class Cdr_DllAPI Exception 29 | { 30 | public: 31 | 32 | //! \brief Default destructor. 33 | virtual ~Exception() noexcept; 34 | 35 | //! \brief This function throws the object as exception. 36 | virtual void raise() const = 0; 37 | 38 | /*! 39 | * @brief This function returns the error message. 40 | * 41 | * @return The error message. 42 | */ 43 | virtual const char* what() const noexcept; 44 | 45 | protected: 46 | 47 | /*! 48 | * @brief Default constructor. 49 | * 50 | * @param message A error message. This message pointer is copied. 51 | */ 52 | Exception( 53 | const char* const& message) noexcept; 54 | 55 | /*! 56 | * @brief Default copy constructor. 57 | * 58 | * @param ex Exception that will be copied. 59 | */ 60 | Exception( 61 | const Exception& ex) noexcept; 62 | 63 | /*! 64 | * @brief Default move constructor. 65 | * 66 | * @param ex Exception that will be moved. 67 | */ 68 | Exception( 69 | Exception&& ex) noexcept; 70 | 71 | /*! 72 | * @brief Assigment operation. 73 | * 74 | * @param ex Exception that will be copied. 75 | */ 76 | Exception& operator =( 77 | const Exception& ex) noexcept; 78 | 79 | /*! 80 | * @brief Assigment operation. 81 | * 82 | * @param ex Exception that will be moved. 83 | */ 84 | Exception& operator =( 85 | Exception&& ex) noexcept; 86 | 87 | private: 88 | 89 | const char* m_message; 90 | }; 91 | } //namespace exception 92 | } //namespace fastcdr 93 | } //namespace eprosima 94 | 95 | #endif // _FASTCDR_EXCEPTIONS_EXCEPTION_H_ 96 | -------------------------------------------------------------------------------- /include/fastcdr/exceptions/LockedExternalAccessException.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_EXCEPTIONS_LOCKEDEXTERNALACCESSEXCEPTION_H_ 16 | #define _FASTCDR_EXCEPTIONS_LOCKEDEXTERNALACCESSEXCEPTION_H_ 17 | 18 | #include "Exception.h" 19 | 20 | namespace eprosima { 21 | namespace fastcdr { 22 | namespace exception { 23 | /*! 24 | * @brief This class is thrown as an exception when accessing to set the value of a locked external. 25 | * @ingroup EXCEPTIONMODULE 26 | */ 27 | class Cdr_DllAPI LockedExternalAccessException : public Exception 28 | { 29 | public: 30 | 31 | /*! 32 | * @brief Default constructor. 33 | * 34 | * @param message An error message. This message pointer is copied. 35 | */ 36 | LockedExternalAccessException( 37 | const char* const& message) noexcept; 38 | 39 | /*! 40 | * @brief Default copy constructor. 41 | * 42 | * @param ex LockedExternalAccessException that will be copied. 43 | */ 44 | LockedExternalAccessException( 45 | const LockedExternalAccessException& ex) noexcept; 46 | 47 | /*! 48 | * @brief Default move constructor. 49 | * 50 | * @param ex LockedExternalAccessException that will be moved. 51 | */ 52 | LockedExternalAccessException( 53 | LockedExternalAccessException&& ex) noexcept; 54 | 55 | /*! 56 | * @brief Assigment operation. 57 | * 58 | * @param ex LockedExternalAccessException that will be copied. 59 | */ 60 | LockedExternalAccessException& operator =( 61 | const LockedExternalAccessException& ex) noexcept; 62 | 63 | /*! 64 | * @brief Assigment operation. 65 | * 66 | * @param ex LockedExternalAccessException that will be moved. 67 | */ 68 | LockedExternalAccessException& operator =( 69 | LockedExternalAccessException&& ex) noexcept; 70 | 71 | //! @brief Default destructor 72 | virtual ~LockedExternalAccessException() noexcept; 73 | 74 | //! @brief This function throws the object as exception. 75 | void raise() const override; 76 | 77 | //! @brief Default message used in the library. 78 | static const char* const LOCKED_EXTERNAL_ACCESS_MESSAGE_DEFAULT; 79 | }; 80 | } //namespace exception 81 | } //namespace fastcdr 82 | } //namespace eprosima 83 | #endif // _FASTCDR_EXCEPTIONS_LOCKEDEXTERNALACCESSEXCEPTION_H_ 84 | -------------------------------------------------------------------------------- /include/fastcdr/exceptions/NotEnoughMemoryException.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_EXCEPTIONS_NOTENOUGHMEMORYEXCEPTION_H_ 16 | #define _FASTCDR_EXCEPTIONS_NOTENOUGHMEMORYEXCEPTION_H_ 17 | 18 | #include "Exception.h" 19 | 20 | namespace eprosima { 21 | namespace fastcdr { 22 | namespace exception { 23 | /*! 24 | * @brief This class is thrown as an exception when the buffer's internal memory reachs its size limit. 25 | * @ingroup EXCEPTIONMODULE 26 | */ 27 | class Cdr_DllAPI NotEnoughMemoryException : public Exception 28 | { 29 | public: 30 | 31 | /*! 32 | * @brief Default constructor. 33 | * 34 | * @param message An error message. This message pointer is copied. 35 | */ 36 | NotEnoughMemoryException( 37 | const char* const& message) noexcept; 38 | 39 | /*! 40 | * @brief Default copy constructor. 41 | * 42 | * @param ex NotEnoughMemoryException that will be copied. 43 | */ 44 | NotEnoughMemoryException( 45 | const NotEnoughMemoryException& ex) noexcept; 46 | 47 | /*! 48 | * @brief Default move constructor. 49 | * 50 | * @param ex NotEnoughMemoryException that will be moved. 51 | */ 52 | NotEnoughMemoryException( 53 | NotEnoughMemoryException&& ex) noexcept; 54 | 55 | /*! 56 | * @brief Assigment operation. 57 | * 58 | * @param ex NotEnoughMemoryException that will be copied. 59 | */ 60 | NotEnoughMemoryException& operator =( 61 | const NotEnoughMemoryException& ex) noexcept; 62 | 63 | /*! 64 | * @brief Assigment operation. 65 | * 66 | * @param ex NotEnoughMemoryException that will be moved. 67 | */ 68 | NotEnoughMemoryException& operator =( 69 | NotEnoughMemoryException&& ex) noexcept; 70 | 71 | //! @brief Default destructor 72 | virtual ~NotEnoughMemoryException() noexcept; 73 | 74 | //! @brief This function throws the object as exception. 75 | void raise() const override; 76 | 77 | //! @brief Default message used in the library. 78 | static const char* const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT; 79 | }; 80 | } //namespace exception 81 | } //namespace fastcdr 82 | } //namespace eprosima 83 | #endif // _FASTCDR_EXCEPTIONS_NOTENOUGHMEMORYEXCEPTION_H_ 84 | -------------------------------------------------------------------------------- /include/fastcdr/fastcdr_dll.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _FASTCDR_FASTCDR_DLL_H_ 16 | #define _FASTCDR_FASTCDR_DLL_H_ 17 | 18 | #include 19 | 20 | // normalize macros 21 | #if !defined(FASTCDR_DYN_LINK) && !defined(FASTCDR_STATIC_LINK) \ 22 | && !defined(EPROSIMA_ALL_DYN_LINK) && !defined(EPROSIMA_ALL_STATIC_LINK) 23 | #define FASTCDR_STATIC_LINK 24 | #endif // if !defined(FASTCDR_DYN_LINK) && !defined(FASTCDR_STATIC_LINK) && !defined(EPROSIMA_ALL_DYN_LINK) && !defined(EPROSIMA_ALL_STATIC_LINK) 25 | 26 | #if defined(EPROSIMA_ALL_DYN_LINK) && !defined(FASTCDR_DYN_LINK) 27 | #define FASTCDR_DYN_LINK 28 | #endif // if defined(EPROSIMA_ALL_DYN_LINK) && !defined(FASTCDR_DYN_LINK) 29 | 30 | #if defined(FASTCDR_DYN_LINK) && defined(FASTCDR_STATIC_LINK) 31 | #error Must not define both FASTCDR_DYN_LINK and FASTCDR_STATIC_LINK 32 | #endif // if defined(FASTCDR_DYN_LINK) && defined(FASTCDR_STATIC_LINK) 33 | 34 | #if defined(EPROSIMA_ALL_NO_LIB) && !defined(FASTCDR_NO_LIB) 35 | #define FASTCDR_NO_LIB 36 | #endif // if defined(EPROSIMA_ALL_NO_LIB) && !defined(FASTCDR_NO_LIB) 37 | 38 | // enable dynamic linking 39 | 40 | #if defined(_WIN32) 41 | #if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTCDR_DYN_LINK) 42 | #if defined(fastcdr_EXPORTS) 43 | #define Cdr_DllAPI __declspec( dllexport ) 44 | #else 45 | #define Cdr_DllAPI __declspec( dllimport ) 46 | #endif // FASTCDR_SOURCE 47 | #else 48 | #define Cdr_DllAPI 49 | #endif // if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTCDR_DYN_LINK) 50 | #else 51 | #define Cdr_DllAPI 52 | #endif // _WIN32 53 | 54 | // Auto linking. 55 | 56 | #if !defined(FASTCDR_SOURCE) && !defined(EPROSIMA_ALL_NO_LIB) \ 57 | && !defined(FASTCDR_NO_LIB) 58 | 59 | // Set properties. 60 | #define EPROSIMA_LIB_NAME fastcdr 61 | 62 | #if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTCDR_DYN_LINK) 63 | #define EPROSIMA_DYN_LINK 64 | #endif // if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTCDR_DYN_LINK) 65 | 66 | #include "eProsima_auto_link.h" 67 | #endif // auto-linking disabled 68 | 69 | #endif // _FASTCDR_FASTCDR_DLL_H_ 70 | -------------------------------------------------------------------------------- /include/fastcdr/xcdr/MemberId.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | #ifndef _FASTCDR_XCDR_MEMBERID_HPP_ 16 | #define _FASTCDR_XCDR_MEMBERID_HPP_ 17 | 18 | #include 19 | 20 | #include "../fastcdr_dll.h" 21 | 22 | namespace eprosima { 23 | namespace fastcdr { 24 | 25 | class Cdr; 26 | 27 | class Cdr_DllAPI MemberId 28 | { 29 | public: 30 | 31 | MemberId() = default; 32 | 33 | MemberId( 34 | uint32_t id_value) 35 | : id(id_value) 36 | { 37 | } 38 | 39 | bool operator ==( 40 | uint32_t id_value) const 41 | { 42 | return id == id_value; 43 | } 44 | 45 | bool operator ==( 46 | const MemberId member_id) const 47 | { 48 | return id == member_id.id; 49 | } 50 | 51 | bool operator !=( 52 | const MemberId member_id) const 53 | { 54 | return !(member_id == *this); 55 | } 56 | 57 | uint32_t id { member_id_invalid_value_ }; 58 | 59 | bool must_understand { false }; 60 | 61 | private: 62 | 63 | static constexpr uint32_t member_id_invalid_value_ = 0xFFFFFFFF; 64 | 65 | }; 66 | 67 | static const MemberId MEMBER_ID_INVALID {}; 68 | 69 | } // namespace fastcdr 70 | } // namespace eprosima 71 | 72 | #endif //_FASTCDR_XCDR_MEMBERID_HPP_ 73 | -------------------------------------------------------------------------------- /include/fastcdr/xcdr/detail/optional.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | #ifndef _FASTCDR_XCDR_DETAIL_OPTIONAL_HPP_ 16 | #define _FASTCDR_XCDR_DETAIL_OPTIONAL_HPP_ 17 | 18 | #include 19 | 20 | namespace eprosima { 21 | namespace fastcdr { 22 | namespace detail { 23 | template 24 | struct optional_storage 25 | { 26 | union 27 | { 28 | char dummy_; 29 | T val_; 30 | }; 31 | 32 | bool engaged_ { false }; 33 | 34 | optional_storage() 35 | { 36 | } 37 | 38 | ~optional_storage() 39 | { 40 | if (engaged_) 41 | { 42 | val_.~T(); 43 | } 44 | } 45 | 46 | }; 47 | 48 | /* *INDENT-OFF* */ 49 | template 50 | struct optional_storage::value>::type> 51 | { 52 | union 53 | { 54 | char dummy_; T val_; 55 | }; 56 | 57 | bool engaged_ { false }; 58 | 59 | optional_storage() 60 | { 61 | } 62 | 63 | ~optional_storage() = default; 64 | }; 65 | /* *INDENT-ON* */ 66 | } // namespace detail 67 | } // namespace fastcdr 68 | } // namespace eprosima 69 | 70 | #endif //_FASTCDR_XCDR_DETAIL_OPTIONAL_HPP_ 71 | 72 | -------------------------------------------------------------------------------- /include/fastcdr/xcdr/external.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | #ifndef _FASTCDR_XCDR_EXTERNAL_HPP_ 16 | #define _FASTCDR_XCDR_EXTERNAL_HPP_ 17 | 18 | #include 19 | 20 | #include "../exceptions/LockedExternalAccessException.hpp" 21 | 22 | namespace eprosima { 23 | namespace fastcdr { 24 | 25 | /*! 26 | * @brief This class template manages an external member, a member declared to be external to the storage of a type. 27 | */ 28 | template 29 | class external 30 | { 31 | public: 32 | 33 | using type = T; 34 | 35 | //! Default constructor 36 | external() = default; 37 | 38 | //! Constructor from a pointer. 39 | external( 40 | T* pointer, 41 | bool locked = false) noexcept 42 | : pointer_ {pointer} 43 | , locked_ {locked} 44 | { 45 | } 46 | 47 | //! Constructor from a shared pointer. 48 | external( 49 | std::shared_ptr pointer) noexcept 50 | : pointer_ {pointer} 51 | { 52 | } 53 | 54 | //! Copy constructor. 55 | external( 56 | const external& other) noexcept 57 | : locked_ {other.locked_} 58 | { 59 | if (locked_) 60 | { 61 | pointer_ = std::make_shared(*other.pointer_); 62 | } 63 | else 64 | { 65 | pointer_ = other.pointer_; 66 | } 67 | } 68 | 69 | //! Assignment 70 | external& operator =( 71 | const external& other) 72 | { 73 | if (locked_) 74 | { 75 | throw exception::LockedExternalAccessException( 76 | exception::LockedExternalAccessException::LOCKED_EXTERNAL_ACCESS_MESSAGE_DEFAULT); 77 | } 78 | 79 | if (!other.pointer_) 80 | { 81 | pointer_.reset(); 82 | } 83 | else if (other.locked_) 84 | { 85 | if (!pointer_) 86 | { 87 | pointer_ = std::make_shared(*other.pointer_); 88 | } 89 | else 90 | { 91 | *pointer_ = *other.pointer_; 92 | } 93 | } 94 | else 95 | { 96 | pointer_ = other.pointer_; 97 | } 98 | 99 | return *this; 100 | } 101 | 102 | //! Destructor 103 | ~external() = default; 104 | 105 | //! Dereference object. 106 | T& operator *() noexcept 107 | { 108 | return *pointer_; 109 | } 110 | 111 | //! Dereference object. 112 | const T& operator *() const noexcept 113 | { 114 | return *pointer_; 115 | } 116 | 117 | //! Get pointer. 118 | T* get() noexcept 119 | { 120 | return pointer_.get(); 121 | } 122 | 123 | //! Get pointer. 124 | const T* get() const noexcept 125 | { 126 | return pointer_.get(); 127 | } 128 | 129 | //! Get shared pointer. 130 | std::shared_ptr get_shared_ptr() noexcept 131 | { 132 | return pointer_; 133 | } 134 | 135 | //! Dereference object member. 136 | T* operator ->() noexcept 137 | { 138 | return pointer_.get(); 139 | } 140 | 141 | //! Dereference object member. 142 | const T* operator ->() const noexcept 143 | { 144 | return pointer_.get(); 145 | } 146 | 147 | //! Compares they manage the same object or empty both. 148 | bool operator ==( 149 | const external& other) const 150 | { 151 | return pointer_.get() == other.pointer_.get(); 152 | } 153 | 154 | //! Compares they don't manages the same object 155 | bool operator !=( 156 | const external& other) const 157 | { 158 | return !(*this == other); 159 | } 160 | 161 | //! Checks if not null 162 | operator bool() const noexcept 163 | { 164 | return nullptr != pointer_.get(); 165 | } 166 | 167 | //! Checks if locked 168 | bool is_locked() const noexcept 169 | { 170 | return locked_; 171 | } 172 | 173 | //! Locks the managed object. 174 | void lock() noexcept 175 | { 176 | locked_ = true; 177 | } 178 | 179 | private: 180 | 181 | std::shared_ptr pointer_; 182 | 183 | bool locked_ {false}; 184 | 185 | }; 186 | 187 | } // namespace fastcdr 188 | } // namespace eprosima 189 | 190 | #endif //_FASTCDR_XCDR_EXTERNAL_HPP_ 191 | -------------------------------------------------------------------------------- /include/fastcdr/xcdr/optional.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | #ifndef _FASTCDR_XCDR_OPTIONAL_HPP_ 16 | #define _FASTCDR_XCDR_OPTIONAL_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "detail/optional.hpp" 22 | #include "../exceptions/BadOptionalAccessException.hpp" 23 | 24 | namespace eprosima { 25 | namespace fastcdr { 26 | 27 | //! An empty class type used to indicate optional type with uninitialized state. 28 | struct nullopt_t 29 | { 30 | constexpr explicit nullopt_t( 31 | int) 32 | { 33 | } 34 | 35 | }; 36 | 37 | /*! 38 | * @brief nullopt is a constant of type nullopt_t that is used to indicate optional type with uninitialized state. 39 | */ 40 | static constexpr nullopt_t nullopt {0}; 41 | 42 | /*! 43 | * @brief This class template manages an optional contained value, i.e. a value that may or may not be present. 44 | */ 45 | template 46 | class optional 47 | { 48 | public: 49 | 50 | using type = T; 51 | 52 | //! Default constructor 53 | optional() = default; 54 | 55 | //! Copy constructor from an instance of the templated class. 56 | optional( 57 | const T& val) noexcept 58 | { 59 | ::new(&storage_.val_)T(val); 60 | storage_.engaged_ = true; 61 | } 62 | 63 | //! Move constructor from an instance of the templated class. 64 | optional( 65 | T&& val) noexcept 66 | { 67 | ::new(&storage_.val_)T(std::move(val)); 68 | storage_.engaged_ = true; 69 | } 70 | 71 | //! Copy constructor. 72 | optional( 73 | const optional& val) noexcept 74 | { 75 | if (val.storage_.engaged_) 76 | { 77 | ::new(&storage_.val_)T(val.storage_.val_); 78 | storage_.engaged_ = true; 79 | } 80 | } 81 | 82 | //! Move constructor. 83 | optional( 84 | optional&& val) noexcept 85 | { 86 | if (val.storage_.engaged_) 87 | { 88 | ::new(&storage_.val_)T(std::move(val.storage_.val_)); 89 | storage_.engaged_ = true; 90 | } 91 | } 92 | 93 | //! Destructor 94 | ~optional() = default; 95 | 96 | /*! 97 | * @brief Constructs the contained value in-place 98 | * 99 | * @param[in] _args The arguments to pass to the constructor. 100 | */ 101 | template void emplace( 102 | Args&&... _args) 103 | { 104 | reset(); 105 | storage_.val_.T(std::forward(_args)...); 106 | storage_.engaged_ = true; 107 | } 108 | 109 | /*! 110 | * @brief Reset the state of the optional 111 | * 112 | * @param[in] initial_engaged True value initializes the state with a default instance of the templated class. 113 | * False value leaves the optional in a uninitialized state. 114 | */ 115 | void reset( 116 | bool initial_engaged = false) 117 | { 118 | if (storage_.engaged_) 119 | { 120 | storage_.val_.~T(); 121 | } 122 | storage_.engaged_ = initial_engaged; 123 | if (storage_.engaged_) 124 | { 125 | ::new(&storage_.val_)T(); 126 | } 127 | } 128 | 129 | /*! 130 | * @brief Returns the contained value. 131 | * 132 | * @return The contained value. 133 | * @exception exception::BadOptionalAccessException This exception is thrown when the optional is uninitialized. 134 | */ 135 | T& value()& 136 | { 137 | if (!storage_.engaged_) 138 | { 139 | throw exception::BadOptionalAccessException( 140 | exception::BadOptionalAccessException::BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT); 141 | } 142 | 143 | return storage_.val_; 144 | } 145 | 146 | /*! 147 | * @brief Returns the contained value. 148 | * 149 | * @return The contained value. 150 | * @exception exception::BadOptionalAccessException This exception is thrown when the optional is uninitialized. 151 | */ 152 | const T& value() const& 153 | { 154 | if (!storage_.engaged_) 155 | { 156 | throw exception::BadOptionalAccessException( 157 | exception::BadOptionalAccessException::BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT); 158 | } 159 | 160 | return storage_.val_; 161 | } 162 | 163 | /*! 164 | * @brief Returns the contained value. 165 | * 166 | * @return The contained value. 167 | * @exception exception::BadOptionalAccessException This exception is thrown when the optional is uninitialized. 168 | */ 169 | T&& value() && 170 | { 171 | if (!storage_.engaged_) 172 | { 173 | throw exception::BadOptionalAccessException( 174 | exception::BadOptionalAccessException::BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT); 175 | } 176 | 177 | return std::move(storage_.val_); 178 | } 179 | 180 | /*! 181 | * @brief Returns the contained value. 182 | * 183 | * @return The contained value. 184 | * @exception exception::BadOptionalAccessException This exception is thrown when the optional is uninitialized. 185 | */ 186 | const T&& value() const&& 187 | { 188 | if (!storage_.engaged_) 189 | { 190 | throw exception::BadOptionalAccessException( 191 | exception::BadOptionalAccessException::BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT); 192 | } 193 | 194 | return std::move(storage_.val_); 195 | } 196 | 197 | /*! 198 | * @brief Checks whether the optional contains a value. 199 | * 200 | * @return Whether the optional contains a value. 201 | */ 202 | bool has_value() const 203 | { 204 | return storage_.engaged_; 205 | } 206 | 207 | //! Assigns content from an optional. 208 | optional& operator =( 209 | const optional& opt) 210 | { 211 | reset(); 212 | storage_.engaged_ = opt.storage_.engaged_; 213 | if (opt.storage_.engaged_) 214 | { 215 | ::new(&storage_.val_)T(opt.storage_.val_); 216 | } 217 | return *this; 218 | } 219 | 220 | //! Assigns content from an optional. 221 | optional& operator =( 222 | optional&& opt) 223 | { 224 | reset(); 225 | storage_.engaged_ = opt.storage_.engaged_; 226 | if (opt.storage_.engaged_) 227 | { 228 | ::new(&storage_.val_)T(std::move(opt.storage_.val_)); 229 | } 230 | return *this; 231 | } 232 | 233 | //! Assigns content from an instance of the templated class. 234 | optional& operator =( 235 | const T& val) 236 | { 237 | reset(); 238 | ::new(&storage_.val_)T(val); 239 | storage_.engaged_ = true; 240 | return *this; 241 | } 242 | 243 | //! Assigns content from an instance of the templated class. 244 | optional& operator =( 245 | T&& val) 246 | { 247 | reset(); 248 | ::new(&storage_.val_)T(std::move(val)); 249 | storage_.engaged_ = true; 250 | return *this; 251 | } 252 | 253 | //! Uninitialized the optional. 254 | optional& operator = ( 255 | nullopt_t) noexcept 256 | { 257 | reset(); 258 | return *this; 259 | } 260 | 261 | //! Compares optional values. 262 | bool operator ==( 263 | const optional& opt_val) const 264 | { 265 | return opt_val.storage_.engaged_ == storage_.engaged_ && 266 | (storage_.engaged_ ? opt_val.storage_.val_ == storage_.val_ : true); 267 | } 268 | 269 | //! Compares optional values. 270 | bool operator !=( 271 | const optional& opt_val) const 272 | { 273 | return !operator ==(opt_val); 274 | } 275 | 276 | /*! 277 | * @brief Accesses the contained value. 278 | * 279 | * The behavior is undefined if *this does not contain a value. 280 | * 281 | * @return The contained value. 282 | */ 283 | T& operator *() & noexcept 284 | { 285 | return storage_.val_; 286 | } 287 | 288 | /*! 289 | * @brief Accesses the contained value. 290 | * 291 | * The behavior is undefined if *this does not contain a value. 292 | * 293 | * @return The contained value. 294 | */ 295 | const T& operator *() const& noexcept 296 | { 297 | return storage_.val_; 298 | } 299 | 300 | /*! 301 | * @brief Accesses the contained value. 302 | * 303 | * The behavior is undefined if *this does not contain a value. 304 | * 305 | * @return The contained value. 306 | */ 307 | T&& operator *() && noexcept 308 | { 309 | return std::move(storage_.val_); 310 | } 311 | 312 | /*! 313 | * @brief Accesses the contained value. 314 | * 315 | * The behavior is undefined if *this does not contain a value. 316 | * 317 | * @return The contained value. 318 | */ 319 | const T&& operator *() const&& noexcept 320 | { 321 | return std::move(storage_.val_); 322 | } 323 | 324 | /*! 325 | * @brief Accesses the contained value. 326 | * 327 | * The behavior is undefined if *this does not contain a value. 328 | * 329 | * @return The contained value. 330 | */ 331 | T* operator ->() noexcept 332 | { 333 | return std::addressof(storage_.val_); 334 | } 335 | 336 | /*! 337 | * @brief Accesses the contained value. 338 | * 339 | * The behavior is undefined if *this does not contain a value. 340 | * 341 | * @return The contained value. 342 | */ 343 | const T* operator ->() const noexcept 344 | { 345 | return std::addressof(storage_.val_); 346 | } 347 | 348 | //! Checks whether the optional contains a value. 349 | explicit operator bool() const noexcept 350 | { 351 | return storage_.engaged_; 352 | } 353 | 354 | private: 355 | 356 | detail::optional_storage storage_; 357 | }; 358 | 359 | } // namespace fastcdr 360 | } // namespace eprosima 361 | 362 | #endif //_FASTCDR_XCDR_OPTIONAL_HPP_ 363 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fastcdr 5 | 2.3.0 6 | 7 | *eProsima Fast CDR* is a C++ serialization library implementing the Common Data Representation (CDR) mechanism defined by the Object Management Group (OMG) consortium. CDR is the serialization mechanism used in DDS for the DDS Interoperability Wire Protocol (DDSI-RTPS). 8 | 9 | Miguel Company 10 | Raúl Sánchez-Mateos 11 | Apache 2.0 12 | 13 | https://www.eprosima.com/ 14 | https://github.com/eProsima/Fast-CDR/issues 15 | https://github.com/eProsima/Fast-CDR 16 | 17 | cmake 18 | doxygen 19 | 20 | ament_cmake_gtest 21 | ament_cmake 22 | 23 | 24 | cmake 25 | 26 | 27 | -------------------------------------------------------------------------------- /resources/images/github_banner_fastcdr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/resources/images/github_banner_fastcdr.png -------------------------------------------------------------------------------- /src/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | file(GLOB_RECURSE ALL_HEADERS 16 | ${PROJECT_SOURCE_DIR}/include/**/*.h 17 | ${PROJECT_SOURCE_DIR}/include/**/*.hpp 18 | ${PROJECT_SOURCE_DIR}/src/cpp/**/*.h 19 | ${PROJECT_SOURCE_DIR}/src/cpp/**/*.hpp 20 | ) 21 | 22 | # Set source files 23 | set(${PROJECT_NAME}_source_files 24 | ${ALL_HEADERS} 25 | 26 | Cdr.cpp 27 | CdrSizeCalculator.cpp 28 | FastCdr.cpp 29 | FastBuffer.cpp 30 | exceptions/BadOptionalAccessException.cpp 31 | exceptions/BadParamException.cpp 32 | exceptions/Exception.cpp 33 | exceptions/LockedExternalAccessException.cpp 34 | exceptions/NotEnoughMemoryException.cpp 35 | FastCdr.rc 36 | ) 37 | 38 | configure_file(${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/config.h.in 39 | ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/config.h) 40 | 41 | if(APPLE) 42 | set(CMAKE_MACOSX_RPATH ON) 43 | set(CMAKE_SKIP_BUILD_RPATH FALSE) 44 | set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 45 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") 46 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) 47 | endif() 48 | 49 | # Create library 50 | add_library(${PROJECT_NAME} ${${PROJECT_NAME}_source_files}) 51 | set_common_compile_options(${PROJECT_NAME}) 52 | set_target_properties(${PROJECT_NAME} PROPERTIES 53 | VERSION ${PROJECT_VERSION} 54 | SOVERSION ${PROJECT_VERSION_MAJOR} 55 | ) 56 | 57 | target_compile_definitions(${PROJECT_NAME} 58 | PRIVATE 59 | ${PROJECT_NAME_UPPER}_SOURCE 60 | INTERFACE 61 | $<$:${PROJECT_NAME_UPPER}_NO_LIB> 62 | PUBLIC 63 | $<$:$<$,SHARED_LIBRARY>:${PROJECT_NAME_UPPER}_DYN_LINK>> 64 | ) 65 | 66 | # Define public headers 67 | target_include_directories(${PROJECT_NAME} PUBLIC 68 | $ $ 69 | $ 70 | ) 71 | 72 | if(MSVC OR MSVC_IDE) 73 | set_target_properties(${PROJECT_NAME} PROPERTIES 74 | RELEASE_POSTFIX -${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 75 | RELWITHDEBINFO_POSTFIX -${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 76 | DEBUG_POSTFIX d-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 77 | ) 78 | 79 | get_target_property(TARGET_TYPE ${PROJECT_NAME} TYPE) 80 | if(TARGET_TYPE STREQUAL "SHARED_LIBRARY") 81 | # Export symbols in DLL library 82 | set_target_properties(${PROJECT_NAME} PROPERTIES 83 | PDB_NAME_DEBUG ${PROJECT_NAME}d-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 84 | PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/symbols" 85 | ) 86 | else() 87 | # Rename the library to have a "lib" before. 88 | set_target_properties(${PROJECT_NAME} PROPERTIES 89 | OUTPUT_NAME lib${PROJECT_NAME} 90 | COMPILE_PDB_NAME_DEBUG lib${PROJECT_NAME}d-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 91 | COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/symbols" 92 | ) 93 | endif() 94 | endif() 95 | 96 | ############################################################################### 97 | # Packaging 98 | ############################################################################### 99 | 100 | # Install public headers 101 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME} 102 | DESTINATION ${INCLUDE_INSTALL_DIR} 103 | COMPONENT headers 104 | FILES_MATCHING 105 | PATTERN "*.h" 106 | PATTERN "*.hpp" 107 | PATTERN "*.ipp" 108 | ) 109 | 110 | # Install config.h header 111 | install(FILES ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/config.h 112 | DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} 113 | COMPONENT headers 114 | ) 115 | 116 | # Install libraries 117 | install(TARGETS ${PROJECT_NAME} 118 | EXPORT ${PROJECT_NAME}-targets 119 | RUNTIME DESTINATION ${BIN_INSTALL_DIR} 120 | LIBRARY DESTINATION ${LIB_INSTALL_DIR} 121 | ARCHIVE DESTINATION ${LIB_INSTALL_DIR} 122 | COMPONENT libraries 123 | ) 124 | 125 | # Generate different target names depending on linking 126 | get_target_property(TARGET_TYPE ${PROJECT_NAME} TYPE) 127 | if(TARGET_TYPE STREQUAL "SHARED_LIBRARY") 128 | set(FASTCDR_LINKING shared) 129 | else() 130 | set(FASTCDR_LINKING static) 131 | endif() 132 | 133 | if(INSTALLER_PLATFORM) 134 | set(INSTALL_DESTINATION_PATH ${DATA_INSTALL_DIR}/${PROJECT_NAME}-${INSTALLER_PLATFORM}/cmake) 135 | else() 136 | set(INSTALL_DESTINATION_PATH ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}) 137 | endif() 138 | 139 | install(EXPORT ${PROJECT_NAME}-targets 140 | DESTINATION ${INSTALL_DESTINATION_PATH} 141 | FILE ${PROJECT_NAME}-${FASTCDR_LINKING}-targets.cmake 142 | COMPONENT cmake 143 | ) 144 | 145 | if(MSVC OR MSVC_IDE) 146 | # first try dll symbols 147 | get_target_property(PDB_FILE ${PROJECT_NAME} PDB_NAME_DEBUG) 148 | if(PDB_FILE) 149 | get_target_property(PDB_DIR ${PROJECT_NAME} PDB_OUTPUT_DIRECTORY_DEBUG) 150 | set(PDB_FILE "${PDB_DIR}/${PDB_FILE}.pdb") 151 | else() 152 | # fallback to static lib symbols 153 | get_target_property(PDB_FILE ${PROJECT_NAME} COMPILE_PDB_NAME_DEBUG) 154 | if(PDB_FILE) 155 | get_target_property(PDB_DIR ${PROJECT_NAME} COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG) 156 | set(PDB_FILE "${PDB_DIR}/${PDB_FILE}.pdb") 157 | endif() 158 | endif() 159 | 160 | # install symbols if any 161 | if(PDB_FILE) 162 | install(FILES ${PDB_FILE} 163 | DESTINATION ${LIB_INSTALL_DIR} 164 | COMPONENT symbols 165 | CONFIGURATIONS Debug 166 | ) 167 | endif() 168 | endif() 169 | 170 | ############################################################################### 171 | # Create CMake package config file 172 | ############################################################################### 173 | include(CMakePackageConfigHelpers) 174 | 175 | if(BUILD_SHARED_LIBS) 176 | set(FASTCDR_PACKAGE_OPT_BIN_DIR_CONDITION "if(MSVC OR MSVC_IDE)") 177 | else() 178 | set(FASTCDR_PACKAGE_OPT_BIN_DIR_CONDITION "if(0)") 179 | endif() 180 | 181 | configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/packaging/Config.cmake.in 182 | ${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config.cmake 183 | INSTALL_DESTINATION ${INSTALL_DESTINATION_PATH} 184 | PATH_VARS BIN_INSTALL_DIR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR 185 | ) 186 | write_basic_package_version_file(${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config-version.cmake 187 | VERSION ${PROJECT_VERSION} 188 | COMPATIBILITY SameMajorVersion 189 | ) 190 | install(FILES ${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config.cmake 191 | ${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-config-version.cmake 192 | DESTINATION ${INSTALL_DESTINATION_PATH} 193 | COMPONENT cmake 194 | ) 195 | -------------------------------------------------------------------------------- /src/cpp/CdrSizeCalculator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | namespace eprosima { 18 | namespace fastcdr { 19 | 20 | CdrSizeCalculator::CdrSizeCalculator( 21 | CdrVersion cdr_version) 22 | : cdr_version_(cdr_version) 23 | { 24 | switch (cdr_version_) 25 | { 26 | case CdrVersion::XCDRv2: 27 | break; 28 | default: 29 | current_encoding_ = EncodingAlgorithmFlag::PLAIN_CDR; 30 | align64_ = 8; 31 | break; 32 | } 33 | } 34 | 35 | CdrSizeCalculator::CdrSizeCalculator( 36 | CdrVersion cdr_version, 37 | EncodingAlgorithmFlag encoding) 38 | : CdrSizeCalculator(cdr_version) 39 | { 40 | current_encoding_ = encoding; 41 | } 42 | 43 | CdrVersion CdrSizeCalculator::get_cdr_version() const 44 | { 45 | return cdr_version_; 46 | } 47 | 48 | EncodingAlgorithmFlag CdrSizeCalculator::get_encoding() const 49 | { 50 | return current_encoding_; 51 | } 52 | 53 | size_t CdrSizeCalculator::begin_calculate_type_serialized_size( 54 | EncodingAlgorithmFlag new_encoding, 55 | size_t& current_alignment) 56 | { 57 | size_t calculated_size {0}; 58 | current_encoding_ = new_encoding; 59 | 60 | if (CdrVersion::XCDRv2 == cdr_version_ && EncodingAlgorithmFlag::PLAIN_CDR2 != current_encoding_) 61 | { 62 | calculated_size = 4 + alignment(current_alignment, 4); // DHEADER 63 | } 64 | 65 | current_alignment += calculated_size; 66 | 67 | serialized_member_size_ = NO_SERIALIZED_MEMBER_SIZE; // Avoid error when serializing arrays, sequences, etc.. 68 | 69 | return calculated_size; 70 | } 71 | 72 | size_t CdrSizeCalculator::end_calculate_type_serialized_size( 73 | EncodingAlgorithmFlag new_encoding, 74 | size_t& current_alignment) 75 | { 76 | size_t calculated_size {0}; 77 | 78 | if (CdrVersion::XCDRv1 == cdr_version_ && EncodingAlgorithmFlag::PL_CDR == current_encoding_) 79 | { 80 | calculated_size = 4 + alignment(current_alignment, 4); // Sentinel 81 | } 82 | else if (CdrVersion::XCDRv2 == cdr_version_ && EncodingAlgorithmFlag::PLAIN_CDR2 != current_encoding_) 83 | { 84 | serialized_member_size_ = SERIALIZED_MEMBER_SIZE; 85 | } 86 | 87 | current_alignment += calculated_size; 88 | 89 | current_encoding_ = new_encoding; 90 | 91 | return calculated_size; 92 | } 93 | 94 | } // namespace fastcdr 95 | } // namespace eprosima 96 | -------------------------------------------------------------------------------- /src/cpp/FastBuffer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__ 18 | #include 19 | #else 20 | #include 21 | #endif // if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__ 22 | 23 | #define BUFFER_START_LENGTH 200 24 | 25 | using namespace eprosima::fastcdr; 26 | 27 | FastBuffer::FastBuffer( 28 | char* const buffer, 29 | const size_t bufferSize) 30 | : buffer_(buffer) 31 | , size_(bufferSize) 32 | , m_internalBuffer(false) 33 | { 34 | } 35 | 36 | FastBuffer::~FastBuffer() 37 | { 38 | if (m_internalBuffer && buffer_ != nullptr) 39 | { 40 | free(buffer_); 41 | } 42 | } 43 | 44 | bool FastBuffer::reserve( 45 | size_t size) 46 | { 47 | if (m_internalBuffer && buffer_ == NULL) 48 | { 49 | buffer_ = reinterpret_cast(malloc(size)); 50 | if (buffer_) 51 | { 52 | size_ = size; 53 | return true; 54 | } 55 | } 56 | return false; 57 | } 58 | 59 | bool FastBuffer::resize( 60 | size_t min_size_inc) 61 | { 62 | size_t incBufferSize = BUFFER_START_LENGTH; 63 | 64 | if (m_internalBuffer) 65 | { 66 | if (min_size_inc > BUFFER_START_LENGTH) 67 | { 68 | incBufferSize = min_size_inc; 69 | } 70 | 71 | if (buffer_ == NULL) 72 | { 73 | size_ = incBufferSize; 74 | 75 | buffer_ = reinterpret_cast(malloc(size_)); 76 | 77 | if (buffer_ != NULL) 78 | { 79 | return true; 80 | } 81 | } 82 | else 83 | { 84 | size_ += incBufferSize; 85 | 86 | buffer_ = reinterpret_cast(realloc(buffer_, size_)); 87 | 88 | if (buffer_ != NULL) 89 | { 90 | return true; 91 | } 92 | } 93 | } 94 | 95 | return false; 96 | } 97 | -------------------------------------------------------------------------------- /src/cpp/FastCdr.rc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | // Microsoft Visual C++ generated resource script. 18 | // 19 | #ifdef APSTUDIO_INVOKED 20 | #ifndef APSTUDIO_READONLY_SYMBOLS 21 | #define _APS_NEXT_RESOURCE_VALUE 101 22 | #define _APS_NEXT_COMMAND_VALUE 40001 23 | #define _APS_NEXT_CONTROL_VALUE 1001 24 | #define _APS_NEXT_SYMED_VALUE 101 25 | #endif 26 | #endif 27 | 28 | #define APSTUDIO_READONLY_SYMBOLS 29 | ///////////////////////////////////////////////////////////////////////////// 30 | // 31 | // Generated from the TEXTINCLUDE 2 resource. 32 | // 33 | #include "windows.h" 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | #undef APSTUDIO_READONLY_SYMBOLS 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | // Spanish resources 40 | 41 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN) 42 | #ifdef _WIN32 43 | LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN 44 | #pragma code_page(1252) 45 | #endif //_WIN32 46 | 47 | #ifdef APSTUDIO_INVOKED 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // TEXTINCLUDE 51 | // 52 | 53 | 1 TEXTINCLUDE 54 | BEGIN 55 | "resource.h\0" 56 | END 57 | 58 | 2 TEXTINCLUDE 59 | BEGIN 60 | "#include ""afxres.h""\r\n" 61 | "\0" 62 | END 63 | 64 | 3 TEXTINCLUDE 65 | BEGIN 66 | "\r\n" 67 | "\0" 68 | END 69 | 70 | #endif // APSTUDIO_INVOKED 71 | 72 | 73 | ///////////////////////////////////////////////////////////////////////////// 74 | // 75 | // Version 76 | // 77 | 78 | #define VER_PRODUCTVERSION FASTCDR_VERSION_MAJOR,FASTCDR_VERSION_MINOR,FASTCDR_VERSION_MICRO,0 79 | #define VER_PRODUCTVERSION_STR FASTCDR_VERSION_STR 80 | #define VER_COMPANYNAME_STR "eProsima" 81 | #define VER_FILEDESCRIPTION_STR "Library to serialize in CDR" 82 | #define VER_LEGALCOPYRIGHT_STR "Copyright 2015 (c)" 83 | #define VER_PRODUCTNAME_STR "FastCDR" 84 | 85 | #ifdef _WIN32 86 | #if defined(fastcdr_EXPORTS) 87 | 88 | #ifndef _DEBUG 89 | #define VER_DEBUG 0 90 | #else 91 | #define VER_DEBUG VS_FF_DEBUG 92 | #endif // _DEBUG 93 | 94 | VS_VERSION_INFO VERSIONINFO 95 | FILEVERSION VER_PRODUCTVERSION 96 | PRODUCTVERSION VER_PRODUCTVERSION 97 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 98 | FILEFLAGS VER_DEBUG 99 | FILEOS VOS__WINDOWS32 100 | FILETYPE VFT_DLL 101 | FILESUBTYPE VFT2_UNKNOWN 102 | BEGIN 103 | BLOCK "StringFileInfo" 104 | BEGIN 105 | BLOCK "0c0a04b0" 106 | BEGIN 107 | VALUE "CompanyName", VER_COMPANYNAME_STR 108 | VALUE "FileDescription", VER_FILEDESCRIPTION_STR 109 | VALUE "FileVersion", VER_PRODUCTVERSION_STR 110 | VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR 111 | VALUE "ProductName", VER_PRODUCTNAME_STR 112 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 113 | END 114 | END 115 | BLOCK "VarFileInfo" 116 | BEGIN 117 | VALUE "Translation", 0xc0a, 1200 118 | END 119 | END 120 | 121 | #endif 122 | #endif // _WIN32 123 | 124 | #endif // Spanish resources 125 | ///////////////////////////////////////////////////////////////////////////// 126 | 127 | 128 | 129 | #ifndef APSTUDIO_INVOKED 130 | ///////////////////////////////////////////////////////////////////////////// 131 | // 132 | // Generated from the TEXTINCLUDE 3 resource. 133 | // 134 | 135 | 136 | ///////////////////////////////////////////////////////////////////////////// 137 | #endif // not APSTUDIO_INVOKED 138 | 139 | 140 | -------------------------------------------------------------------------------- /src/cpp/exceptions/BadOptionalAccessException.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | using namespace eprosima::fastcdr::exception; 18 | 19 | const char* const BadOptionalAccessException::BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT = 20 | "Bad optional access: value not set"; 21 | 22 | BadOptionalAccessException::BadOptionalAccessException( 23 | const char* const& message) noexcept 24 | : Exception(message) 25 | { 26 | } 27 | 28 | BadOptionalAccessException::BadOptionalAccessException( 29 | const BadOptionalAccessException& ex) noexcept 30 | : Exception(ex) 31 | { 32 | } 33 | 34 | BadOptionalAccessException::BadOptionalAccessException( 35 | BadOptionalAccessException&& ex) noexcept 36 | : Exception(std::move(ex)) 37 | { 38 | } 39 | 40 | BadOptionalAccessException& BadOptionalAccessException::operator =( 41 | const BadOptionalAccessException& ex) noexcept 42 | { 43 | if (this != &ex) 44 | { 45 | Exception::operator =( 46 | ex); 47 | } 48 | 49 | return *this; 50 | } 51 | 52 | BadOptionalAccessException& BadOptionalAccessException::operator =( 53 | BadOptionalAccessException&& ex) noexcept 54 | { 55 | if (this != &ex) 56 | { 57 | Exception::operator =( 58 | std::move(ex)); 59 | } 60 | 61 | return *this; 62 | } 63 | 64 | BadOptionalAccessException::~BadOptionalAccessException() noexcept 65 | { 66 | } 67 | 68 | void BadOptionalAccessException::raise() const 69 | { 70 | throw *this; 71 | } 72 | -------------------------------------------------------------------------------- /src/cpp/exceptions/BadParamException.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | using namespace eprosima::fastcdr::exception; 18 | 19 | const char* const BadParamException::BAD_PARAM_MESSAGE_DEFAULT = "Bad parameter"; 20 | 21 | BadParamException::BadParamException( 22 | const char* const& message) noexcept 23 | : Exception(message) 24 | { 25 | } 26 | 27 | BadParamException::BadParamException( 28 | const BadParamException& ex) noexcept 29 | : Exception(ex) 30 | { 31 | } 32 | 33 | BadParamException::BadParamException( 34 | BadParamException&& ex) noexcept 35 | : Exception(std::move(ex)) 36 | { 37 | } 38 | 39 | BadParamException& BadParamException::operator =( 40 | const BadParamException& ex) noexcept 41 | { 42 | if (this != &ex) 43 | { 44 | Exception::operator =( 45 | ex); 46 | } 47 | 48 | return *this; 49 | } 50 | 51 | BadParamException& BadParamException::operator =( 52 | BadParamException&& ex) noexcept 53 | { 54 | if (this != &ex) 55 | { 56 | Exception::operator =( 57 | std::move(ex)); 58 | } 59 | 60 | return *this; 61 | } 62 | 63 | BadParamException::~BadParamException() noexcept 64 | { 65 | } 66 | 67 | void BadParamException::raise() const 68 | { 69 | throw *this; 70 | } 71 | -------------------------------------------------------------------------------- /src/cpp/exceptions/Exception.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | using namespace eprosima::fastcdr::exception; 18 | 19 | Exception::Exception( 20 | const char* const& message) noexcept 21 | : m_message(message) 22 | { 23 | } 24 | 25 | Exception::Exception( 26 | const Exception& ex) noexcept 27 | : m_message(ex.m_message) 28 | { 29 | } 30 | 31 | Exception::Exception( 32 | Exception&& ex) noexcept 33 | : m_message(std::move(ex.m_message)) 34 | { 35 | } 36 | 37 | Exception& Exception::operator =( 38 | const Exception& ex) noexcept 39 | { 40 | m_message = ex.m_message; 41 | return *this; 42 | } 43 | 44 | Exception& Exception::operator =( 45 | Exception&& ex) noexcept 46 | { 47 | m_message = std::move(ex.m_message); 48 | return *this; 49 | } 50 | 51 | Exception::~Exception() noexcept 52 | { 53 | } 54 | 55 | const char* Exception::what() const noexcept 56 | { 57 | return m_message; 58 | } 59 | -------------------------------------------------------------------------------- /src/cpp/exceptions/LockedExternalAccessException.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | using namespace eprosima::fastcdr::exception; 18 | 19 | const char* const LockedExternalAccessException::LOCKED_EXTERNAL_ACCESS_MESSAGE_DEFAULT = 20 | "Locked external: value cannot be set"; 21 | 22 | LockedExternalAccessException::LockedExternalAccessException( 23 | const char* const& message) noexcept 24 | : Exception(message) 25 | { 26 | } 27 | 28 | LockedExternalAccessException::LockedExternalAccessException( 29 | const LockedExternalAccessException& ex) noexcept 30 | : Exception(ex) 31 | { 32 | } 33 | 34 | LockedExternalAccessException::LockedExternalAccessException( 35 | LockedExternalAccessException&& ex) noexcept 36 | : Exception(std::move(ex)) 37 | { 38 | } 39 | 40 | LockedExternalAccessException& LockedExternalAccessException::operator =( 41 | const LockedExternalAccessException& ex) noexcept 42 | { 43 | if (this != &ex) 44 | { 45 | Exception::operator =( 46 | ex); 47 | } 48 | 49 | return *this; 50 | } 51 | 52 | LockedExternalAccessException& LockedExternalAccessException::operator =( 53 | LockedExternalAccessException&& ex) noexcept 54 | { 55 | if (this != &ex) 56 | { 57 | Exception::operator =( 58 | std::move(ex)); 59 | } 60 | 61 | return *this; 62 | } 63 | 64 | LockedExternalAccessException::~LockedExternalAccessException() noexcept 65 | { 66 | } 67 | 68 | void LockedExternalAccessException::raise() const 69 | { 70 | throw *this; 71 | } 72 | -------------------------------------------------------------------------------- /src/cpp/exceptions/NotEnoughMemoryException.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | using namespace eprosima::fastcdr::exception; 18 | 19 | const char* const NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT = 20 | "Not enough memory in the buffer stream"; 21 | 22 | NotEnoughMemoryException::NotEnoughMemoryException( 23 | const char* const& message) noexcept 24 | : Exception(message) 25 | { 26 | } 27 | 28 | NotEnoughMemoryException::NotEnoughMemoryException( 29 | const NotEnoughMemoryException& ex) noexcept 30 | : Exception(ex) 31 | { 32 | } 33 | 34 | NotEnoughMemoryException::NotEnoughMemoryException( 35 | NotEnoughMemoryException&& ex) noexcept 36 | : Exception(std::move(ex)) 37 | { 38 | } 39 | 40 | NotEnoughMemoryException& NotEnoughMemoryException::operator =( 41 | const NotEnoughMemoryException& ex) noexcept 42 | { 43 | if (this != &ex) 44 | { 45 | Exception::operator =( 46 | ex); 47 | } 48 | 49 | return *this; 50 | } 51 | 52 | NotEnoughMemoryException& NotEnoughMemoryException::operator =( 53 | NotEnoughMemoryException&& ex) noexcept 54 | { 55 | if (this != &ex) 56 | { 57 | Exception::operator =( 58 | std::move(ex)); 59 | } 60 | 61 | return *this; 62 | } 63 | 64 | NotEnoughMemoryException::~NotEnoughMemoryException() noexcept 65 | { 66 | } 67 | 68 | void NotEnoughMemoryException::raise() const 69 | { 70 | throw *this; 71 | } 72 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Require C++ 14 for testing (since ROS 2 requires it anyways) 16 | set(FORCE_CXX "14") 17 | check_stdcxx(${FORCE_CXX}) 18 | 19 | # Find GTest 20 | include(${PROJECT_SOURCE_DIR}/cmake/common/find_or_add_gtest.cmake) 21 | find_or_add_gtest() 22 | 23 | # Include functions to find and add tests dinamically 24 | include(${PROJECT_SOURCE_DIR}/cmake/testing/GoogleTest.cmake) 25 | 26 | add_subdirectory(cdr) 27 | add_subdirectory(xcdr) 28 | 29 | ############################################################################### 30 | # CMake modules tests 31 | ############################################################################### 32 | 33 | set(build_dir "${fastcdr_BINARY_DIR}/test/force_cxx") 34 | set(module_dir "${fastcdr_SOURCE_DIR}/cmake/common") 35 | set(script "${CMAKE_CURRENT_LIST_DIR}/cmake/build.cmake") 36 | 37 | # The C++ sources use fold expressions which were introduced in C++17 38 | 39 | # Tests that C++17 sources can be built enforcing C++17 through CMake 40 | add_test(NAME cmake.force_standard.positive.builtin 41 | COMMAND ${CMAKE_COMMAND} 42 | -DFORCE_CXX=17 -DTEST_FALLBACK=OFF 43 | -DEPROSIMA_MODULE_PATH=${module_dir} 44 | -DBUILD_DIR=${build_dir} 45 | -P ${script} 46 | ) 47 | 48 | # Tests that C++17 sources can be built enforcing C++17 manually 49 | add_test(NAME cmake.force_standard.positive.manual 50 | COMMAND ${CMAKE_COMMAND} 51 | -DFORCE_CXX=17 -DTEST_FALLBACK=ON 52 | -DEPROSIMA_MODULE_PATH=${module_dir} 53 | -DBUILD_DIR=${build_dir} 54 | -P ${script} 55 | ) 56 | 57 | # Tests that C++17 sources cannot be built enforcing C++14 through CMake 58 | add_test(NAME cmake.force_standard.negative.builtin 59 | COMMAND ${CMAKE_COMMAND} 60 | -DFORCE_CXX=14 -DTEST_FALLBACK=OFF 61 | -DEPROSIMA_MODULE_PATH=${module_dir} 62 | -DBUILD_DIR=${build_dir} 63 | -P ${script} 64 | ) 65 | 66 | # Tests that C++17 sources cannot be built enforcing C++14 manually 67 | add_test(NAME cmake.force_standard.negative.manual 68 | COMMAND ${CMAKE_COMMAND} 69 | -DFORCE_CXX=14 -DTEST_FALLBACK=ON 70 | -DEPROSIMA_MODULE_PATH=${module_dir} 71 | -DBUILD_DIR=${build_dir} 72 | -P ${script} 73 | ) 74 | 75 | # set the negative testing 76 | set_tests_properties( 77 | cmake.force_standard.negative.builtin 78 | cmake.force_standard.negative.manual 79 | PROPERTIES WILL_FAIL TRUE) 80 | -------------------------------------------------------------------------------- /test/cdr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ############################################################################### 16 | # fixed_size_string tests 17 | ############################################################################### 18 | add_executable(FixedSizeStringTests fixed_size_string.cpp) 19 | set_common_compile_options(FixedSizeStringTests) 20 | target_link_libraries(FixedSizeStringTests fastcdr GTest::gtest_main) 21 | gtest_discover_tests(FixedSizeStringTests) 22 | 23 | ############################################################################### 24 | # array_as_std_vector tests 25 | ############################################################################### 26 | add_executable(ArrayAsSTDVectorTests array_as_std_vector.cpp) 27 | set_common_compile_options(ArrayAsSTDVectorTests) 28 | target_link_libraries(ArrayAsSTDVectorTests fastcdr GTest::gtest_main) 29 | gtest_discover_tests(ArrayAsSTDVectorTests) 30 | 31 | ############################################################################### 32 | # Old cdr unit tests 33 | ############################################################################### 34 | set(UNITTESTS_SOURCE SimpleTest.cpp ResizeTest.cpp) 35 | add_executable(UnitTests ${UNITTESTS_SOURCE}) 36 | set_common_compile_options(UnitTests) 37 | target_link_libraries(UnitTests fastcdr GTest::gtest_main) 38 | gtest_discover_tests(UnitTests) 39 | -------------------------------------------------------------------------------- /test/cdr/fixed_size_string.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | using namespace eprosima::fastcdr; 19 | 20 | constexpr size_t MAX_CHARS = 255; 21 | constexpr size_t OTHER_MAX_CHARS = 127; 22 | 23 | class FixedSizeStringTests : public ::testing::Test 24 | { 25 | public: 26 | 27 | char const* pattern0 = "foo/bar/baz"; 28 | char const* long_pattern = 29 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 30 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 31 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 32 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 33 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 34 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 35 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" 36 | "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; 37 | 38 | size_t pattern0_len = strlen(pattern0); 39 | }; 40 | 41 | TEST_F(FixedSizeStringTests, default_constructor) 42 | { 43 | std::string std_s; 44 | fixed_string fixed_s; 45 | 46 | ASSERT_EQ(fixed_s.size(), 0u); 47 | ASSERT_EQ(fixed_s, ""); 48 | ASSERT_EQ(fixed_s, std_s); 49 | } 50 | 51 | TEST_F(FixedSizeStringTests, construct_with_empty_c_string) 52 | { 53 | std::string std_s; 54 | fixed_string fixed_s(""); 55 | 56 | ASSERT_EQ(fixed_s.size(), 0u); 57 | ASSERT_EQ(fixed_s, ""); 58 | ASSERT_EQ(fixed_s, std_s); 59 | } 60 | 61 | TEST_F(FixedSizeStringTests, construct_with_empty_std_string) 62 | { 63 | std::string std_s; 64 | fixed_string fixed_s(std_s); 65 | 66 | ASSERT_EQ(fixed_s.size(), 0u); 67 | ASSERT_EQ(fixed_s, ""); 68 | ASSERT_EQ(fixed_s, std_s); 69 | } 70 | 71 | TEST_F(FixedSizeStringTests, construct_with_c_string) 72 | { 73 | fixed_string fixed_s(pattern0); 74 | 75 | ASSERT_EQ(fixed_s.size(), pattern0_len); 76 | ASSERT_EQ(fixed_s, pattern0); 77 | } 78 | 79 | TEST_F(FixedSizeStringTests, construct_with_std_string) 80 | { 81 | std::string std_string(pattern0); 82 | fixed_string fixed_s(std_string); 83 | 84 | ASSERT_EQ(fixed_s.size(), pattern0_len); 85 | ASSERT_EQ(fixed_s, std_string); 86 | } 87 | 88 | TEST_F(FixedSizeStringTests, construct_with_long_c_string) 89 | { 90 | fixed_string fixed_s(long_pattern); 91 | 92 | ASSERT_EQ(fixed_s.size(), MAX_CHARS); 93 | ASSERT_EQ(fixed_s, long_pattern); 94 | } 95 | 96 | TEST_F(FixedSizeStringTests, construct_with_long_std_string) 97 | { 98 | std::string std_string(long_pattern); 99 | fixed_string fixed_s(std_string); 100 | 101 | ASSERT_EQ(fixed_s.size(), MAX_CHARS); 102 | ASSERT_EQ(fixed_s, std_string); 103 | } 104 | 105 | TEST_F(FixedSizeStringTests, assign_operators_and_inequality) 106 | { 107 | fixed_string fixed_s; 108 | 109 | std::string std_s_empty; 110 | std::string std_s(pattern0); 111 | std::string std_s_long(long_pattern); 112 | 113 | fixed_s = std_s_long; 114 | ASSERT_EQ(fixed_s.size(), MAX_CHARS); 115 | ASSERT_EQ(fixed_s, long_pattern); 116 | ASSERT_NE(fixed_s, pattern0); 117 | ASSERT_NE(fixed_s, ""); 118 | 119 | fixed_s = pattern0; 120 | ASSERT_EQ(fixed_s.size(), pattern0_len); 121 | ASSERT_EQ(fixed_s, std_s); 122 | ASSERT_NE(fixed_s, std_s_empty); 123 | ASSERT_NE(fixed_s, std_s_long); 124 | 125 | fixed_s = std_s_empty; 126 | ASSERT_EQ(fixed_s.size(), 0u); 127 | ASSERT_EQ(fixed_s, ""); 128 | ASSERT_NE(fixed_s, long_pattern); 129 | ASSERT_NE(fixed_s, pattern0); 130 | 131 | fixed_s = long_pattern; 132 | ASSERT_EQ(fixed_s.size(), MAX_CHARS); 133 | ASSERT_EQ(fixed_s, std_s_long); 134 | ASSERT_NE(fixed_s, std_s); 135 | ASSERT_NE(fixed_s, std_s_empty); 136 | 137 | fixed_s = std_s; 138 | ASSERT_EQ(fixed_s.size(), pattern0_len); 139 | ASSERT_EQ(fixed_s, pattern0); 140 | ASSERT_NE(fixed_s, ""); 141 | ASSERT_NE(fixed_s, long_pattern); 142 | 143 | fixed_s = ""; 144 | ASSERT_EQ(fixed_s.size(), 0u); 145 | ASSERT_EQ(fixed_s, std_s_empty); 146 | ASSERT_NE(fixed_s, std_s_long); 147 | ASSERT_NE(fixed_s, std_s); 148 | } 149 | 150 | TEST_F(FixedSizeStringTests, different_fixed_sizes) 151 | { 152 | fixed_string s1; 153 | fixed_string s2; 154 | 155 | ASSERT_EQ(s1, s2); 156 | 157 | s1 = long_pattern; 158 | ASSERT_NE(s1, s2); 159 | 160 | s2 = s1; 161 | ASSERT_EQ(s2, s1); 162 | 163 | s2 = pattern0; 164 | ASSERT_NE(s2, s1); 165 | 166 | s1 = s2; 167 | ASSERT_EQ(s1, s2); 168 | } 169 | 170 | TEST_F(FixedSizeStringTests, comparisons) 171 | { 172 | const char* c_string_short = "test string"; 173 | const char* c_string_a = "test string a"; 174 | const char* c_string_b = "test string b"; 175 | const char* c_string_c = "test string c"; 176 | const char* c_string_large = "test string b "; 177 | std::string std_string_short = "test string"; 178 | std::string std_string_a = "test string a"; 179 | std::string std_string_b = "test string b"; 180 | std::string std_string_c = "test string c"; 181 | std::string std_string_large = "test string b "; 182 | fixed_string fixed_short = "test string"; 183 | fixed_string fixed_a = "test string a"; 184 | fixed_string fixed_b = "test string b"; 185 | fixed_string fixed_c = "test string c"; 186 | fixed_string fixed_large = "test string b "; 187 | 188 | ASSERT_NE(fixed_b, c_string_short); 189 | ASSERT_NE(fixed_b, c_string_a); 190 | ASSERT_EQ(fixed_b, c_string_b); 191 | ASSERT_NE(fixed_b, c_string_c); 192 | ASSERT_NE(fixed_b, c_string_large); 193 | 194 | ASSERT_LT(0, fixed_b.compare(c_string_short)); 195 | ASSERT_LT(0, fixed_b.compare(c_string_a)); 196 | ASSERT_EQ(0, fixed_b.compare(c_string_b)); 197 | ASSERT_GT(0, fixed_b.compare(c_string_c)); 198 | ASSERT_GT(0, fixed_b.compare(c_string_large)); 199 | 200 | ASSERT_NE(fixed_b, std_string_short); 201 | ASSERT_NE(fixed_b, std_string_a); 202 | ASSERT_EQ(fixed_b, std_string_b); 203 | ASSERT_NE(fixed_b, std_string_c); 204 | ASSERT_NE(fixed_b, std_string_large); 205 | 206 | ASSERT_LE(0, fixed_b.compare(std_string_short)); 207 | ASSERT_LE(0, fixed_b.compare(std_string_a)); 208 | ASSERT_EQ(0, fixed_b.compare(std_string_b)); 209 | ASSERT_GT(0, fixed_b.compare(std_string_c)); 210 | ASSERT_GT(0, fixed_b.compare(std_string_large)); 211 | 212 | ASSERT_NE(fixed_b, fixed_short); 213 | ASSERT_NE(fixed_b, fixed_a); 214 | ASSERT_EQ(fixed_b, fixed_b); 215 | ASSERT_NE(fixed_b, fixed_c); 216 | ASSERT_NE(fixed_b, fixed_large); 217 | 218 | ASSERT_LE(0, fixed_b.compare(fixed_short)); 219 | ASSERT_LE(0, fixed_b.compare(fixed_a)); 220 | ASSERT_EQ(0, fixed_b.compare(fixed_b)); 221 | ASSERT_GT(0, fixed_b.compare(fixed_c)); 222 | ASSERT_GT(0, fixed_b.compare(fixed_large)); 223 | } 224 | 225 | TEST_F(FixedSizeStringTests, less_than_operator_fixed_string) 226 | { 227 | fixed_string fixed_string_short = "test string"; 228 | fixed_string fixed_string_long = "test string long"; 229 | 230 | ASSERT_FALSE(fixed_string_short < fixed_string_short); 231 | ASSERT_FALSE(fixed_string_long < fixed_string_long); 232 | ASSERT_TRUE(fixed_string_short < fixed_string_long); 233 | ASSERT_FALSE(fixed_string_long < fixed_string_short); 234 | } 235 | 236 | TEST_F(FixedSizeStringTests, less_than_operator_std_string) 237 | { 238 | fixed_string fixed_string_short = "test string"; 239 | std::string std_string_long = "test string long"; 240 | std::string std_string_short = "test"; 241 | 242 | ASSERT_TRUE(fixed_string_short < std_string_long); 243 | ASSERT_FALSE(fixed_string_short < std_string_short); 244 | } 245 | 246 | TEST_F(FixedSizeStringTests, greater_than_operator_fixed_string) 247 | { 248 | fixed_string fixed_string_short = "test string"; 249 | fixed_string fixed_string_long = "test string long"; 250 | 251 | ASSERT_FALSE(fixed_string_short > fixed_string_short); 252 | ASSERT_FALSE(fixed_string_long > fixed_string_long); 253 | ASSERT_FALSE(fixed_string_short > fixed_string_long); 254 | ASSERT_TRUE(fixed_string_long > fixed_string_short); 255 | } 256 | 257 | TEST_F(FixedSizeStringTests, greater_than_operator_std_string) 258 | { 259 | fixed_string fixed_string_short = "test string"; 260 | std::string std_string_long = "test string long"; 261 | std::string std_string_short = "test"; 262 | 263 | ASSERT_FALSE(fixed_string_short > std_string_long); 264 | ASSERT_TRUE(fixed_string_short > std_string_short); 265 | } 266 | -------------------------------------------------------------------------------- /test/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ############################################################################### 16 | # Auxiliary project for check_configuration.cmake module testing 17 | ############################################################################### 18 | cmake_minimum_required(VERSION 3.20) 19 | 20 | # setup 21 | option(TEST_FALLBACK "Ignore CMake builtin instrospection and use our original fallback" OFF) 22 | 23 | # Test preconditions 24 | if(NOT FORCE_CXX) 25 | message(FATAL_ERROR "The FORCE_CXX variable must specify the C++ standard to follow") 26 | endif() 27 | 28 | if(NOT EPROSIMA_MODULE_PATH) 29 | message(FATAL_ERROR "check_configuration.cmake path must be specified") 30 | endif() 31 | 32 | list(APPEND CMAKE_MODULE_PATH "${EPROSIMA_MODULE_PATH}") 33 | 34 | project(std_force_test VERSION 1.0.0 LANGUAGES CXX) 35 | 36 | include(check_configuration) 37 | 38 | if(TEST_FALLBACK) 39 | check_stdcxx(${FORCE_CXX} "run_fallback_test") 40 | else() 41 | check_stdcxx(${FORCE_CXX}) 42 | endif() 43 | 44 | add_executable(std_force_test fold.cpp) 45 | -------------------------------------------------------------------------------- /test/cmake/build.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Script that builds an external dummy project to check standard enforcement 16 | include(CMakePrintHelpers) 17 | 18 | # generate a per-test directory test to allow parallel execution 19 | string(MD5 TEST_DIR "${FORCE_CXX} ${TEST_FALLBACK} ${BUILD_DIR}") 20 | get_filename_component(BUILD_DIR ${BUILD_DIR} ABSOLUTE) 21 | string(JOIN "/" BUILD_DIR ${BUILD_DIR} ${TEST_DIR}) 22 | 23 | # clean build dir if exits 24 | if(EXISTS "${BUILD_DIR}") 25 | file(REMOVE_RECURSE "${BUILD_DIR}" ) 26 | endif() 27 | 28 | execute_process(COMMAND ${CMAKE_COMMAND} 29 | -DFORCE_CXX=${FORCE_CXX} -DTEST_FALLBACK=${TEST_FALLBACK} 30 | -DEPROSIMA_MODULE_PATH=${EPROSIMA_MODULE_PATH} 31 | -B${BUILD_DIR} . 32 | WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} 33 | OUTPUT_VARIABLE my_output 34 | ERROR_VARIABLE error_log 35 | RESULT_VARIABLE fail_to_build) 36 | 37 | if(fail_to_build) 38 | message(FATAL_ERROR "The dummy test fail to generate!!!") 39 | cmake_print_variables(my_output error_log) 40 | endif() 41 | 42 | execute_process(COMMAND ${CMAKE_COMMAND} 43 | --build ${BUILD_DIR} --target std_force_test 44 | OUTPUT_VARIABLE my_output 45 | ERROR_VARIABLE error_log 46 | RESULT_VARIABLE fail_to_build) 47 | 48 | if(fail_to_build OR (error_log MATCHES "[Ww][Aa][Rr][Nn][Ii][Nn][Gg]")) 49 | message(FATAL_ERROR "The dummy test fail to build!!!") 50 | cmake_print_variables(my_output error_log) 51 | endif() 52 | -------------------------------------------------------------------------------- /test/cmake/fold.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, Proyectos y Sistemas de Mantenimiento SL (eProsima). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | // fold.cpp 19 | #include 20 | 21 | using namespace std; 22 | 23 | template 24 | void printer( 25 | Args&&... args) 26 | { 27 | (cout << ... << args) << endl; 28 | } 29 | 30 | int main() 31 | { 32 | printer("eProsima", 0b101010, 'x'); 33 | } 34 | -------------------------------------------------------------------------------- /test/xcdr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ############################################################################### 16 | # Unit tests for XCDR extensions 17 | ############################################################################### 18 | set(XCDR_TEST_SOURCE 19 | appendable.cpp 20 | basic_types.cpp 21 | external.cpp 22 | final.cpp 23 | mutable.cpp 24 | optional.cpp 25 | xcdrv1.cpp 26 | xcdrv2.cpp 27 | ) 28 | add_executable(xcdr_tests ${XCDR_TEST_SOURCE}) 29 | set_common_compile_options(xcdr_tests) 30 | target_link_libraries(xcdr_tests fastcdr GTest::gtest_main) 31 | gtest_discover_tests(xcdr_tests) 32 | -------------------------------------------------------------------------------- /test/xcdr/utility.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _TEST_XCDR_UTILITY_HPP_ 16 | #define _TEST_XCDR_UTILITY_HPP_ 17 | 18 | #include 19 | 20 | static eprosima::fastcdr::CdrVersion get_version_from_algorithm( 21 | eprosima::fastcdr::EncodingAlgorithmFlag ef) 22 | { 23 | eprosima::fastcdr::CdrVersion cdr_version { eprosima::fastcdr::CdrVersion::XCDRv2 }; 24 | 25 | switch (ef) 26 | { 27 | case eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR: 28 | case eprosima::fastcdr::EncodingAlgorithmFlag::PL_CDR: 29 | cdr_version = eprosima::fastcdr::CdrVersion::XCDRv1; 30 | break; 31 | default: 32 | break; 33 | } 34 | 35 | return cdr_version; 36 | } 37 | 38 | #endif // _TEST_XCDR_UTILITY_HPP_ 39 | -------------------------------------------------------------------------------- /test/xcdr/xcdrv2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | using namespace eprosima::fastcdr; 27 | 28 | using XCdrStreamValues = 29 | std::array, 30 | 1 + Cdr::XCdrHeaderSelection::AUTO_WITH_LONG_HEADER_BY_DEFAULT>; 31 | 32 | class XCdrv2Test : public ::testing::TestWithParam> 33 | { 34 | }; 35 | 36 | class XCdrv2PLTest : public ::testing::TestWithParam< Cdr::XCdrHeaderSelection> 37 | { 38 | }; 39 | 40 | template 41 | void xcdrv2_serialize_the_value( 42 | const XCdrStreamValues& expected_streams, 43 | Cdr::XCdrHeaderSelection header_selection, 44 | _T value, 45 | uint8_t last_octet) 46 | { 47 | //{ Prepare buffer 48 | EncodingAlgorithmFlag encoding = EncodingAlgorithmFlag::PL_CDR2; 49 | Cdr::Endianness endianness = Cdr::Endianness::LITTLE_ENDIANNESS; 50 | uint8_t tested_stream = 0 + static_cast(header_selection); 51 | size_t total_size = expected_streams[tested_stream].size() + 4; // Extra needed space for temp LongMemberHeader 52 | auto buffer = 53 | std::unique_ptr{reinterpret_cast(calloc(total_size, sizeof(char))), free}; 55 | FastBuffer fast_buffer(buffer.get(), total_size); 56 | Cdr cdr(fast_buffer, endianness, CdrVersion::XCDRv2); 57 | //} 58 | 59 | //{ 60 | cdr.set_encoding_flag(encoding); 61 | cdr.serialize_encapsulation(); 62 | Cdr::state enc_state(cdr); 63 | cdr.begin_serialize_type(enc_state, encoding); 64 | cdr.serialize_member(MemberId(1), value, header_selection); 65 | cdr.end_serialize_type(enc_state); 66 | cdr.set_dds_cdr_options({0, 0}); 67 | Cdr::state enc_state_end(cdr); 68 | //} 69 | 70 | //{ Test encoded content 71 | auto it = std::find(expected_streams[tested_stream].begin(), expected_streams[tested_stream].end(), last_octet); 72 | ASSERT_EQ(cdr.get_serialized_data_length(), 73 | static_cast(std::distance(expected_streams[tested_stream].begin(), ++it))); 74 | ASSERT_EQ(0, memcmp(buffer.get(), expected_streams[tested_stream].data(), expected_streams[tested_stream].size())); 75 | //} 76 | 77 | //{ Decoding optional not present 78 | _T dec_value {0}; 79 | cdr.reset(); 80 | cdr.read_encapsulation(); 81 | ASSERT_EQ(cdr.get_encoding_flag(), encoding); 82 | ASSERT_EQ(cdr.endianness(), endianness); 83 | cdr.deserialize_type(encoding, [&dec_value](Cdr& cdr_inner, const MemberId& mid) -> bool 84 | { 85 | bool ret_value = true; 86 | switch (mid.id) 87 | { 88 | case 1: 89 | cdr_inner.deserialize_member(dec_value); 90 | break; 91 | default: 92 | ret_value = false; 93 | break; 94 | } 95 | 96 | return ret_value; 97 | }); 98 | ASSERT_EQ(value, dec_value); 99 | Cdr::state dec_state_end(cdr); 100 | ASSERT_EQ(enc_state_end, dec_state_end); 101 | //} 102 | } 103 | 104 | /*! 105 | * @test Test the decoder can get the XCDR version from the encapsulation. 106 | * @code{.idl} 107 | * struct AutoSelectStruct 108 | * { 109 | * @id(0) 110 | * unsigned short value1; 111 | * @id(1) 112 | * unsigned long value2; 113 | * }; 114 | * @endcode 115 | */ 116 | TEST_P(XCdrv2Test, auto_selection_on_decode) 117 | { 118 | EncodingAlgorithmFlag encoding = std::get<0>(GetParam()); 119 | Cdr::Endianness endianness = Cdr::Endianness::LITTLE_ENDIANNESS; 120 | auto buffer = 121 | std::unique_ptr{reinterpret_cast(calloc(100, sizeof(char))), free}; 123 | FastBuffer fast_buffer(buffer.get(), 100); 124 | 125 | //{ Encode an ushort and an ulong. 126 | Cdr cdr(fast_buffer, endianness, CdrVersion::XCDRv2); 127 | const uint16_t us {0x01FC}; 128 | const uint32_t ul {0x01FC1FCD}; 129 | cdr.set_encoding_flag(encoding); 130 | cdr.serialize_encapsulation(); 131 | Cdr::state enc_state(cdr); 132 | cdr.begin_serialize_type(enc_state, encoding); 133 | cdr << MemberId(0) << us; 134 | cdr << MemberId(1) << ul; 135 | cdr.end_serialize_type(enc_state); 136 | cdr.set_dds_cdr_options({0, 0}); 137 | //} 138 | 139 | //{ Decode an ushort and an ulong. 140 | Cdr dcdr(fast_buffer, endianness, std::get<1>(GetParam())); 141 | uint16_t dus{0}; 142 | uint32_t dul{0}; 143 | dcdr.read_encapsulation(); 144 | ASSERT_EQ(dcdr.get_encoding_flag(), encoding); 145 | ASSERT_EQ(dcdr.endianness(), endianness); 146 | dcdr.deserialize_type(encoding, [&](Cdr& dcdr_inner, const MemberId& mid) -> bool 147 | { 148 | bool ret_value = true; 149 | switch (mid.id) 150 | { 151 | case 0: 152 | dcdr_inner >> dus; 153 | break; 154 | case 1: 155 | dcdr_inner >> dul; 156 | break; 157 | default: 158 | ret_value = false; 159 | break; 160 | } 161 | 162 | return ret_value; 163 | }); 164 | ASSERT_EQ(us, dus); 165 | ASSERT_EQ(ul, dul); 166 | } 167 | 168 | /*! 169 | * @test Test serialization of an octet member changing the XCdrHeaderSelection 170 | * @code{.idl} 171 | * struct PLOctetStruct 172 | * { 173 | * @id(1) 174 | * octet value1; 175 | * }; 176 | * @endcode 177 | */ 178 | TEST_P(XCdrv2PLTest, pl_octet_member) 179 | { 180 | constexpr unsigned char octet_value = 0xCD; 181 | 182 | //{ Defining expected XCDR streams 183 | XCdrStreamValues expected_streams; 184 | expected_streams[0 + Cdr::XCdrHeaderSelection::SHORT_HEADER] = 185 | { 186 | 0x00, 0x0b, 0x00, 0x03, // Encapsulation 187 | 0x05, 0x00, 0x00, 0x00, // DHEADER 188 | 0x01, 0x00, 0x00, 0x00, // EMHEADER1(M) without NEXTINT 189 | octet_value // Octet 190 | }; 191 | expected_streams[0 + Cdr::XCdrHeaderSelection::LONG_HEADER] = 192 | { 193 | 0x00, 0x0b, 0x00, 0x03, // Encapsulation 194 | 0x09, 0x00, 0x00, 0x00, // DHEADER 195 | 0x01, 0x00, 0x00, 0x40, // EMHEADER1(M) with NEXTINT 196 | 0x01, 0x00, 0x00, 0x00, // Member size 197 | octet_value // Octet 198 | }; 199 | expected_streams[0 + Cdr::XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT] = 200 | { 201 | 0x00, 0x0b, 0x00, 0x03, // Encapsulation 202 | 0x05, 0x00, 0x00, 0x00, // DHEADER 203 | 0x01, 0x00, 0x00, 0x00, // EMHEADER1(M) without NEXTINT 204 | octet_value // Octet 205 | }; 206 | expected_streams[0 + Cdr::XCdrHeaderSelection::AUTO_WITH_LONG_HEADER_BY_DEFAULT] = 207 | { 208 | 0x00, 0x0b, 0x00, 0x03, // Encapsulation 209 | 0x05, 0x00, 0x00, 0x00, // DHEADER 210 | 0x01, 0x00, 0x00, 0x00, // EMHEADER1(M) without NEXTINT 211 | octet_value // Octet 212 | }; 213 | //} 214 | 215 | Cdr::XCdrHeaderSelection header_selection {GetParam()}; 216 | xcdrv2_serialize_the_value(expected_streams, header_selection, octet_value, octet_value); 217 | } 218 | 219 | /*! 220 | * @test Test serialization of a long member changing the XCdrHeaderSelection 221 | * @code{.idl} 222 | * struct PLLongStruct 223 | * { 224 | * @id(1) 225 | * long value1; 226 | * }; 227 | * @endcode 228 | */ 229 | TEST_P(XCdrv2PLTest, pl_long_member) 230 | { 231 | constexpr int32_t long_value {static_cast(0xDCCDCDCD)}; 232 | constexpr uint8_t ival {0xCD}; 233 | constexpr uint8_t fval {0xDC}; 234 | 235 | //{ Defining expected XCDR streams 236 | XCdrStreamValues expected_streams; 237 | expected_streams[0 + Cdr::XCdrHeaderSelection::SHORT_HEADER] = 238 | { 239 | 0x00, 0x0b, 0x00, 0x00, // Encapsulation 240 | 0x08, 0x00, 0x00, 0x00, // DHEADER 241 | 0x01, 0x00, 0x00, 0x20, // EMHEADER1(M) without NEXTINT 242 | ival, ival, ival, fval // Long 243 | }; 244 | expected_streams[0 + Cdr::XCdrHeaderSelection::LONG_HEADER] = 245 | { 246 | 0x00, 0x0b, 0x00, 0x00, // Encapsulation 247 | 0x0c, 0x00, 0x00, 0x00, // DHEADER 248 | 0x01, 0x00, 0x00, 0x40, // EMHEADER1(M) with NEXTINT 249 | 0x04, 0x00, 0x00, 0x00, // Member size 250 | ival, ival, ival, fval // Long 251 | }; 252 | expected_streams[0 + Cdr::XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT] = 253 | { 254 | 0x00, 0x0b, 0x00, 0x00, // Encapsulation 255 | 0x08, 0x00, 0x00, 0x00, // DHEADER 256 | 0x01, 0x00, 0x00, 0x20, // EMHEADER1(M) without NEXTINT 257 | ival, ival, ival, fval // Long 258 | }; 259 | expected_streams[0 + Cdr::XCdrHeaderSelection::AUTO_WITH_LONG_HEADER_BY_DEFAULT] = 260 | { 261 | 0x00, 0x0b, 0x00, 0x00, // Encapsulation 262 | 0x08, 0x00, 0x00, 0x00, // DHEADER 263 | 0x01, 0x00, 0x00, 0x20, // EMHEADER1(M) without NEXTINT 264 | ival, ival, ival, fval // Long 265 | }; 266 | //} 267 | 268 | Cdr::XCdrHeaderSelection header_selection {GetParam()}; 269 | xcdrv2_serialize_the_value(expected_streams, header_selection, long_value, fval); 270 | } 271 | 272 | /*! 273 | * @test Test an exception is thrown when the user sets XCdrHeaderSelection::SHORT_HEADER but a long header is needed. 274 | * @code{.idl} 275 | * struct PLExceptionStruct 276 | * { 277 | * @id(1) 278 | * long double value; 279 | * }; 280 | * @endcode 281 | */ 282 | TEST(XCdrv2PLTest, exception_long_header) 283 | { 284 | //{ Prepare buffer 285 | EncodingAlgorithmFlag encoding = EncodingAlgorithmFlag::PL_CDR2; 286 | Cdr::Endianness endianness = Cdr::Endianness::LITTLE_ENDIANNESS; 287 | auto buffer = 288 | std::unique_ptr{reinterpret_cast(calloc(40, sizeof(char))), free}; 290 | FastBuffer fast_buffer(buffer.get(), 40); 291 | Cdr cdr(fast_buffer, endianness, CdrVersion::XCDRv2); 292 | //} 293 | 294 | //{ 295 | cdr.set_encoding_flag(encoding); 296 | cdr.serialize_encapsulation(); 297 | Cdr::state enc_state(cdr); 298 | cdr.begin_serialize_type(enc_state, encoding); 299 | long double value {1}; 300 | EXPECT_THROW(cdr.serialize_member(MemberId(1), value, Cdr::XCdrHeaderSelection::SHORT_HEADER), 301 | exception::BadParamException); 302 | //} 303 | } 304 | 305 | INSTANTIATE_TEST_SUITE_P( 306 | XCdrTest, 307 | XCdrv2Test, 308 | ::testing::Values( 309 | std::make_tuple(EncodingAlgorithmFlag::PLAIN_CDR2, CdrVersion::XCDRv1), 310 | std::make_tuple(EncodingAlgorithmFlag::PLAIN_CDR2, CdrVersion::XCDRv2), 311 | std::make_tuple(EncodingAlgorithmFlag::DELIMIT_CDR2, CdrVersion::XCDRv1), 312 | std::make_tuple(EncodingAlgorithmFlag::DELIMIT_CDR2, CdrVersion::XCDRv2), 313 | std::make_tuple(EncodingAlgorithmFlag::PL_CDR2, CdrVersion::XCDRv1), 314 | std::make_tuple(EncodingAlgorithmFlag::PL_CDR2, CdrVersion::XCDRv2) 315 | )); 316 | 317 | INSTANTIATE_TEST_SUITE_P( 318 | XCdrTest, 319 | XCdrv2PLTest, 320 | ::testing::Values( 321 | Cdr::XCdrHeaderSelection::SHORT_HEADER, 322 | Cdr::XCdrHeaderSelection::LONG_HEADER, 323 | Cdr::XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT, 324 | Cdr::XCdrHeaderSelection::AUTO_WITH_LONG_HEADER_BY_DEFAULT 325 | )); 326 | 327 | -------------------------------------------------------------------------------- /utils/doxygen/doxygenfiles/eProsimaLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/utils/doxygen/doxygenfiles/eProsimaLogo.png -------------------------------------------------------------------------------- /utils/doxygen/doxygenfiles/logoEprosimaBlueRTI.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/utils/doxygen/doxygenfiles/logoEprosimaBlueRTI.gif -------------------------------------------------------------------------------- /utils/doxygen/doxygenfiles/mainpage.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | * @mainpage FastCDR Serializer 3 | * 4 | *
FastCDR Serializer library

5 | *
6 | * @image html eProsimaLogo.png 7 | * @image latex eProsimaLogo.png "" width=5cm 8 | *
eProsima
9 | * 10 | * FastCDR Serializer is a little and fast library that serializes data using CDR format. Its API provides you an easy way 11 | * to serialize common basic types of data. This first release of this library is implemented in C++11. 12 | * 13 | */ 14 | 15 | /*! 16 | * @defgroup FASTCDRAPIREFERENCE FastCDR Serializer API Reference 17 | * @brief FastCDR Serializer internal API groped in modules. 18 | */ 19 | 20 | /*! 21 | * @defgroup EXCEPTIONMODULE Exceptions 22 | * @ingroup FASTCDRAPIREFERENCE 23 | * @brief Exceptions used by the FastCDR API. 24 | * All exceptions defined in this module are thrown by the FastCDR library. 25 | */ 26 | -------------------------------------------------------------------------------- /utils/doxygen/pages/eprosima_footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /utils/doxygen/pages/eprosima_header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $projectname: $title 8 | $title 9 | 10 | 11 | 12 | $treeview 13 | $search 14 | $mathjax 15 | 16 | $extrastylesheet 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
31 |
$projectname 32 |  $projectnumber 33 |
34 |
$projectbrief
35 |
40 |
$projectbrief
41 |
$searchbox
52 |
53 | 54 | 55 | -------------------------------------------------------------------------------- /utils/images/icon/eprosima_icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/utils/images/icon/eprosima_icon.bmp -------------------------------------------------------------------------------- /utils/images/icon/eprosima_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/utils/images/icon/eprosima_icon.ico -------------------------------------------------------------------------------- /utils/images/logo/eProsimaLogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/utils/images/logo/eProsimaLogo.jpg -------------------------------------------------------------------------------- /utils/images/logo/eProsimaLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eProsima/Fast-CDR/0d97440090b5655f19b23042794310747a08c254/utils/images/logo/eProsimaLogo.png -------------------------------------------------------------------------------- /valgrind.supp: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | match-leak-kinds: reachable 5 | fun:*alloc 6 | ... 7 | obj:*ld-* 8 | ... 9 | } 10 | { 11 | 12 | Memcheck:Leak 13 | fun:malloc 14 | fun:CRYPTO_zalloc 15 | ... 16 | obj:*libcrypto* 17 | } 18 | -------------------------------------------------------------------------------- /versions.md: -------------------------------------------------------------------------------- 1 | # v2.3.0 2 | * Fix symbol visibility for exception classes 3 | 4 | `Exception` changed to be a base class without inheriting from `std::exception`. 5 | Exception classes are exported. 6 | 7 | # v2.0.0 8 | 9 | * Support of Extended CDR Representation: encoding versions 1 and 2. 10 | 11 | Introduced API break with previous versions. 12 | Mainly `CdrType` enumeration, used in the constructor of `Cdr,` was renamed to `CdrVersion`. 13 | And `DDSCdrPlFlag` enumeration was also renamed to `EncodingAlgorithmFlag`. 14 | --------------------------------------------------------------------------------