Sen API
Sen Libraries
Loading...
Searching...
No Matches
variant_conversion.h
Go to the documentation of this file.
1// === variant_conversion.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_LIBS_DB_BINDINGS_PYTHON_VARIANT_CONVERSION_H
9#define SEN_LIBS_DB_BINDINGS_PYTHON_VARIANT_CONVERSION_H
10
11// sen
12#include "sen/core/meta/type.h"
13#include "sen/core/meta/var.h"
14
15// pybind
16#include <pybind11/pybind11.h> // NOLINT(misc-include-cleaner)
17#include <pybind11/pytypes.h>
18
19// With `type`, KeyedVar tags emit the alternative's qualified type name; without, they emit
20// the numeric variant index as a string.
21[[nodiscard]] pybind11::object toPython(const sen::Var& var, const sen::Type* type = nullptr);
22
23// Walk a Var into a Python object without performing any KeyedVar adaptation. The caller is
24// responsible for running adaptVariant(useStrings=true) beforehand if string variant tags are
25// wanted; otherwise KeyedVar tags surface as their numeric index.
26[[nodiscard]] pybind11::object visitVar(const sen::Var& var);
27
28#endif // SEN_LIBS_DB_BINDINGS_PYTHON_VARIANT_CONVERSION_H
Represents a type that can be used to define variables and arguments for methods or functions....
Definition type.h:71
Can hold any supported value type. Wraps std::variant to allow recursion and implements some helpers.
Definition var.h:119
pybind11::object visitVar(const sen::Var &var)
pybind11::object toPython(const sen::Var &var, const sen::Type *type=nullptr)