Sen API
Sen Libraries
Loading...
Searching...
No Matches
basic_traits.h
Go to the documentation of this file.
1// === basic_traits.h ==================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_CORE_META_BASIC_TRAITS_H
9#define SEN_CORE_META_BASIC_TRAITS_H
10
14#include "sen/core/io/util.h"
15#include "sen/core/meta/type.h"
16
17namespace sen
18{
19
20struct Var;
21
24
33template <typename T>
35{
36 static constexpr bool available = true;
37
38 static void variantToValue(const Var& var, T& val) { val = getCopyAs<T>(var); }
39 static void valueToVariant(T val, Var& var) { var = val; }
40 static constexpr uint32_t serializedSize(T val) noexcept { return impl::getSerializedSize(val); }
41};
42
44
45} // namespace sen
46
47#endif // SEN_CORE_META_BASIC_TRAITS_H
To getCopyAs(const Var &var)
Tries to transform the stored value to T. For expensive types, like strings, maps or lists is better ...
Definition var.h:325
Definition assert.h:17
Helper class that traits classes can inherit from when the type at hand is basic (native or trivial).
Definition basic_traits.h:35
static constexpr uint32_t serializedSize(T val) noexcept
Definition basic_traits.h:40
static constexpr bool available
Definition basic_traits.h:36
static void variantToValue(const Var &var, T &val)
Definition basic_traits.h:38
static void valueToVariant(T val, Var &var)
Definition basic_traits.h:39
Can hold any supported value type. Wraps std::variant to allow recursion and implements some helpers.
Definition var.h:119