{#-
 # Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 # Copyright (C) 2021  UAVCAN Development Team  <uavcan.org>
 # This software is distributed under the terms of the MIT License.
 # Authors: David Lenfesty, Scott Dixon <dixonsco@amazon.com>, Pavel Kirienko <pavel@uavcan.org>,
 #          Peter van der Perk <peter.vanderperk@nxp.com>
-#}

{%- macro assert(expression) -%}
    {%- if options.enable_serialization_asserts -%}
    NUNAVUT_ASSERT({{ expression }});
    {%- endif -%}
{%- endmacro -%}

// UAVCAN common serialization support routines.                                                             +-+ +-+
// This file is based on canard_dsdl.h, which is part of Libcanard.                                          | | | |
//                                                                                                           \  -  /
// AUTOGENERATED, DO NOT EDIT.                                                                                 ---
//                                                                                                              o
//---------------------------------------------------------------------------------------------------------------------
// Language Options
{% for key, value in options.items() -%}
//     {{ key }}:  {{ value }}
{% endfor %}

#ifndef NUNAVUT_SUPPORT_SERIALIZATION_HPP_INCLUDED
#define NUNAVUT_SUPPORT_SERIALIZATION_HPP_INCLUDED

static_assert(__cplusplus >= 201100L,
              "Unsupported language: ISO C11, C++11, or a newer version of either is required.");

#include <cstring> // for std::size_t
{% if not options.omit_float_serialization_support %}
#include <cmath>  // For isfinite().
{% endif -%}
#include <cstdint>

static_assert(sizeof({{ typename_unsigned_bit_length }}) >= sizeof({{ typename_unsigned_length }}),
    "The bit-length type used by Nunavut, {{ typename_unsigned_bit_length }}, "
    "is smaller than this platform's {{ typename_unsigned_length }} type. "
    "Nunavut serialization relies on {{ typename_unsigned_length }} to {{ typename_unsigned_bit_length }} conversions "
    "that do not lose data. You will need to regenerate Nunavut serialization support with a larger "
    "unsigned_bit_length type specified.");

namespace nunavut
{
namespace support
{

namespace options
{
{% for key, value in options.items() -%}
constexpr std::uint32_t {{ key | id }} = {{ value | ln.c.to_static_assertion_value }};
{% endfor %}
} // end namespace options
} // end namespace support
} // end namespace nunavut

#endif // NUNAVUT_SUPPORT_SERIALIZATION_HPP_INCLUDED
