# eprosima/fast-cdr architecture

> Architecture diagram of the GitHub repository eprosima/fast-cdr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eprosima/fast-cdr
- Repository: https://github.com/eprosima/fast-cdr

## Overview

Fast-CDR is a C++ serialization library offering standard CDR and a faster variant. A caller supplies values to the library’s serialization APIs and receives encoded data in a buffer; deserialization reads from that buffer back into values. The repository also exposes size calculation and XCDR-related facilities, including optional, external, and fixed-size string types. The README establishes the two serialization mechanisms; implementation relationships below are limited to connections supported by the supplied source index or excerpts.

Main entry points: [`include/fastcdr/Cdr.h`](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/Cdr.h) (CDR API), [`include/fastcdr/FastCdr.h`](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/FastCdr.h) (Fast CDR API), [`src/cpp/FastBuffer.cpp`](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/FastBuffer.cpp) (Fast buffer), [`src/cpp/helpers/memory_helpers.hpp`](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/helpers/memory_helpers.hpp) (Memory helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serialization["Serialization"]
  node_cdr["CDR codec<br/>[Cdr.cpp]"]
  node_fastcdr["Fast CDR codec<br/>[FastCdr.cpp]"]
  node_sizecalc["Size calculator"]
  node_cdr_api["CDR API<br/>[Cdr.h]"]
  node_fastcdr_api["Fast CDR API<br/>[FastCdr.h]"]
end

subgraph group_encoding["Encoding support"]
  node_encoding["Encoding flags<br/>[CdrEncoding.hpp]"]
  node_context["CDR context<br/>[CdrContext.hpp]"]
  node_memberid["XCDR member IDs<br/>[MemberId.hpp]"]
  node_optional["XCDR optional<br/>[optional.hpp]"]
  node_external["XCDR external<br/>[external.hpp]"]
  node_fixedstring["Fixed strings"]
end

subgraph group_runtime["Runtime support"]
  node_buffer["Fast buffer<br/>[FastBuffer.cpp]"]
  node_memory["Memory helpers<br/>[memory_helpers.hpp]"]
  node_exceptions["Exceptions<br/>[Exception.h]"]
end

node_caller(("Library caller"))

node_caller -->|"uses API"| node_cdr_api
node_caller -->|"uses API"| node_fastcdr_api
node_cdr_api -->|"uses buffer"| node_buffer
node_fastcdr_api -->|"uses buffer"| node_buffer
node_cdr -->|"uses helpers"| node_memory
node_fastcdr -->|"uses helpers"| node_memory
node_cdr_api -->|"accepts context"| node_context
node_cdr_api -->|"uses encoding"| node_encoding
node_cdr_api -->|"uses member IDs"| node_memberid
node_cdr_api -->|"supports optional"| node_optional
node_cdr_api -->|"supports external"| node_external
node_cdr_api -->|"supports strings"| node_fixedstring
node_cdr_api -->|"may throw"| node_exceptions

click node_cdr "https://github.com/eprosima/fast-cdr/blob/master/src/cpp/Cdr.cpp"
click node_fastcdr "https://github.com/eprosima/fast-cdr/blob/master/src/cpp/FastCdr.cpp"
click node_buffer "https://github.com/eprosima/fast-cdr/blob/master/src/cpp/FastBuffer.cpp"
click node_sizecalc "https://github.com/eprosima/fast-cdr/blob/master/src/cpp/CdrSizeCalculator.cpp"
click node_cdr_api "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/Cdr.h"
click node_fastcdr_api "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/FastCdr.h"
click node_encoding "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/CdrEncoding.hpp"
click node_context "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/CdrContext.hpp"
click node_memberid "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/xcdr/MemberId.hpp"
click node_optional "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/xcdr/optional.hpp"
click node_external "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/xcdr/external.hpp"
click node_fixedstring "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/cdr/fixed_size_string.hpp"
click node_memory "https://github.com/eprosima/fast-cdr/blob/master/src/cpp/helpers/memory_helpers.hpp"
click node_exceptions "https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/exceptions/Exception.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cdr,node_fastcdr,node_sizecalc,node_cdr_api,node_fastcdr_api toneBlue
class node_encoding,node_context,node_memberid,node_optional,node_external,node_fixedstring toneAmber
class node_buffer,node_memory,node_exceptions toneMint
class node_caller toneIndigo
```

## Components

### Serialization

- [CDR codec](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/Cdr.cpp): `src/cpp/Cdr.cpp`
- [Fast CDR codec](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/FastCdr.cpp): `src/cpp/FastCdr.cpp`
- [Size calculator](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/CdrSizeCalculator.cpp): `src/cpp/CdrSizeCalculator.cpp`
- [CDR API](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/Cdr.h): `include/fastcdr/Cdr.h`
- [Fast CDR API](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/FastCdr.h): `include/fastcdr/FastCdr.h`

### Encoding support

- [Encoding flags](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/CdrEncoding.hpp): `include/fastcdr/CdrEncoding.hpp`
- [CDR context](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/CdrContext.hpp): `include/fastcdr/CdrContext.hpp`
- [XCDR member IDs](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/xcdr/MemberId.hpp): `include/fastcdr/xcdr/MemberId.hpp`
- [XCDR optional](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/xcdr/optional.hpp): `include/fastcdr/xcdr/optional.hpp`
- [XCDR external](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/xcdr/external.hpp): `include/fastcdr/xcdr/external.hpp`
- [Fixed strings](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/cdr/fixed_size_string.hpp): `include/fastcdr/cdr/fixed_size_string.hpp`

### Runtime support

- [Fast buffer](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/FastBuffer.cpp): `src/cpp/FastBuffer.cpp`
- [Memory helpers](https://github.com/eprosima/fast-cdr/blob/master/src/cpp/helpers/memory_helpers.hpp): `src/cpp/helpers/memory_helpers.hpp`
- [Exceptions](https://github.com/eprosima/fast-cdr/blob/master/include/fastcdr/exceptions/Exception.h): `include/fastcdr/exceptions/Exception.h`

### Other components

- **Library caller**

## Connections

- Library caller → CDR API: uses API (evidence: `README.md`)
- Library caller → Fast CDR API: uses API (evidence: `README.md`)
- CDR API → Fast buffer: uses buffer (evidence: `include/fastcdr/Cdr.h`)
- Fast CDR API → Fast buffer: uses buffer (evidence: `include/fastcdr/FastCdr.h`)
- CDR codec → Memory helpers: uses helpers (evidence: `src/cpp/Cdr.cpp`)
- Fast CDR codec → Memory helpers: uses helpers (evidence: `src/cpp/FastCdr.cpp`)
- CDR API → CDR context: accepts context (evidence: `include/fastcdr/Cdr.h`)
- CDR API → Encoding flags: uses encoding (evidence: `include/fastcdr/Cdr.h`)
- CDR API → XCDR member IDs: uses member IDs (evidence: `include/fastcdr/Cdr.h`)
- CDR API → XCDR optional: supports optional (evidence: `include/fastcdr/Cdr.h`)
- CDR API → XCDR external: supports external (evidence: `include/fastcdr/Cdr.h`)
- CDR API → Fixed strings: supports strings (evidence: `include/fastcdr/Cdr.h`)
- CDR API → Exceptions: may throw (evidence: `include/fastcdr/Cdr.h`)
