|
Sen API
Sen Libraries
|
Helpers for working with meta types. More...
Classes | |
| struct | sen::TypeMatchIssue |
| Information about a type matching issue. More... | |
| struct | sen::TypesMatch |
| Types are compatible. More... | |
| struct | sen::TypesDontMatch |
| Types do not match. More... | |
| class | sen::CustomTypeRegistry |
| A registry of custom types. More... | |
| class | sen::FullTypeVisitor |
| A Visitor for constant types. This class is based on the GoF Visitor design pattern. You can use it to perform operations on types without having to do dynamic_casts (or switch-based casts). More... | |
| class | sen::TypeVisitor |
| All the apply virtual methods are overriden to empty methods. Use TypeVisitor if you only need to handle some of the types. More... | |
| struct | sen::UnitSpec |
| Data about a given unit definition. Given f, x, y: More... | |
| class | sen::Unit |
| Represents the definition of a unit. More... | |
| class | sen::UnitRegistry |
| A registry of units. More... | |
| struct | sen::Var |
| Can hold any supported value type. Wraps std::variant to allow recursion and implements some helpers. More... | |
| struct | sen::IsVariantMember< T, Var > |
Typedefs | |
| using | sen::TypeMatch = Result<TypesMatch, TypesDontMatch> |
| The result of a type matching analysis. | |
| using | sen::VarList = std::vector<Var> |
| A list of vars to represent sequences. | |
| using | sen::VarMap = std::map<std::string, Var, std::less<>> |
| A map of vars to represent structures. | |
| using | sen::KeyedVar = std::tuple<uint32_t, std::shared_ptr<Var>> |
| A key-var tuple, to represent variants. | |
Enumerations | |
| enum class | sen::TypeMatchProblem { sen::TypeMatchProblem::compatible , sen::TypeMatchProblem::incompatible , sen::TypeMatchProblem::missing } |
| Kind of problem found when matching types. More... | |
| enum class | sen::UnitCategory { sen::UnitCategory::length , sen::UnitCategory::mass , sen::UnitCategory::time , sen::UnitCategory::angle , sen::UnitCategory::temperature , sen::UnitCategory::density , sen::UnitCategory::pressure , sen::UnitCategory::area , sen::UnitCategory::force , sen::UnitCategory::frequency , sen::UnitCategory::velocity , sen::UnitCategory::angularVelocity , sen::UnitCategory::acceleration , sen::UnitCategory::angularAcceleration } |
| Type of measurement. More... | |
Functions | |
| TypeMatch | sen::canConvert (const Type &from, const Type &to) |
| Analyze if a type can be converted to another. | |
| void | sen::iterateOverDependentTypes (const Type &type, std::function< void(ConstTypeHandle<> type)> &callback) |
| Helper that iterates over dependent types. The callback function is invoked for all used sub-types recursively. | |
| std::string | sen::toJson (const Var &var, int indent=2) |
| Converts a variant into its Json representation. See https://www.Json.org/Json-en.html for details. | |
| Var | sen::fromJson (const std::string &str) |
| Inverse as toJson. | |
| std::vector< std::uint8_t > | sen::toBson (const Var &var) |
| Converts a variant into its bson (Binary JSON) representation. See https://bsonspec.org/ for details. | |
| Var | sen::fromBson (const std::vector< std::uint8_t > &bson) |
| Inverse as toBson. | |
| std::vector< std::uint8_t > | sen::toCbor (const Var &var) |
| Converts a variant into its MessagePack representation. See https://msgpack.org/ for details. | |
| Var | sen::fromCbor (const std::vector< std::uint8_t > &cbor) |
| Inverse as toCbor. | |
| std::vector< std::uint8_t > | sen::toMsgpack (const Var &var) |
| Converts a variant into its msgpack representation. See https://cbor.io/ for details. | |
| Var | sen::fromMsgpack (const std::vector< std::uint8_t > &msgpack) |
| Inverse as toMsgpack. | |
| std::vector< std::uint8_t > | sen::toUbjson (const Var &var) |
| Converts a variant into its UBJSON (Universal Binary JSON Specification) representation. See https://ubjson.org/ for details. | |
| Var | sen::fromUbjson (const std::vector< std::uint8_t > &ubson) |
| Inverse as toUbjson. | |
| Duration | sen::stringToDuration (const std::string &str) |
| Converts a string to a duration. | |
| template<typename To, bool checkedConversion = false> | |
| To | sen::getCopyAs (const Var &var) |
| Tries to transform the stored value to T. For expensive types, like strings, maps or lists is better use: | |
| const Var & | sen::findElement (const VarMap &map, const std::string &key, const std::string &errorMessage) |
| Finds an element in a map or throws std::exception containing the provided string otherwise. | |
| template<typename T> | |
| T | sen::findElementAs (const VarMap &map, const std::string &key, const std::string &errorMessage) |
| Finds an element in a map or throws std::exception containing the provided string otherwise. | |
Variables | |
| template<typename T> | |
| constexpr bool | sen::isVarTypeMemberV = IsVariantMember<T, Var>::value |
Helpers for working with meta types.
| struct sen::TypeMatchIssue |
Information about a type matching issue.
| Class Members | ||
|---|---|---|
| TypeMatchProblem | problem | |
| string | description | |
| struct sen::TypesMatch |
Types are compatible.
| Class Members | ||
|---|---|---|
| vector< TypeMatchIssue > | issues | |
| struct sen::TypesDontMatch |
Types do not match.
| Class Members | ||
|---|---|---|
| vector< TypeMatchIssue > | issues | |
| using sen::TypeMatch = Result<TypesMatch, TypesDontMatch> |
The result of a type matching analysis.
| using sen::VarList = std::vector<Var> |
A list of vars to represent sequences.
| using sen::VarMap = std::map<std::string, Var, std::less<>> |
A map of vars to represent structures.
| using sen::KeyedVar = std::tuple<uint32_t, std::shared_ptr<Var>> |
A key-var tuple, to represent variants.
|
strong |
|
strong |
Type of measurement.
| Enumerator | |
|---|---|
| length | |
| mass | |
| time | |
| angle | |
| temperature | |
| density | |
| pressure | |
| area | |
| force | |
| frequency | |
| velocity | |
| angularVelocity | |
| acceleration | |
| angularAcceleration | |
Analyze if a type can be converted to another.
| void sen::iterateOverDependentTypes | ( | const Type & | type, |
| std::function< void(ConstTypeHandle<> type)> & | callback ) |
Helper that iterates over dependent types. The callback function is invoked for all used sub-types recursively.
|
nodiscard |
Converts a variant into its Json representation. See https://www.Json.org/Json-en.html for details.
|
nodiscard |
Inverse as toJson.
|
nodiscard |
Converts a variant into its bson (Binary JSON) representation. See https://bsonspec.org/ for details.
|
nodiscard |
Inverse as toBson.
|
nodiscard |
Converts a variant into its MessagePack representation. See https://msgpack.org/ for details.
|
nodiscard |
Inverse as toCbor.
|
nodiscard |
Converts a variant into its msgpack representation. See https://cbor.io/ for details.
|
nodiscard |
Inverse as toMsgpack.
|
nodiscard |
Converts a variant into its UBJSON (Universal Binary JSON Specification) representation. See https://ubjson.org/ for details.
|
nodiscard |
Inverse as toUbjson.
|
nodiscard |
Converts a string to a duration.
|
inlinenodiscard |
Tries to transform the stored value to T. For expensive types, like strings, maps or lists is better use:
Rules:
Throws std::exception if the conversion could not be made
| To | type to transform to |
| checkedConversion | whether conversions should be checked against precision loss/truncation |
| var | Var containing the value that should be converted |
|
inlinenodiscard |
Finds an element in a map or throws std::exception containing the provided string otherwise.
|
nodiscard |
Finds an element in a map or throws std::exception containing the provided string otherwise.
|
constexpr |