Sen API
Sen Libraries
Loading...
Searching...
No Matches
fom_common.h
Go to the documentation of this file.
1// === fom_common.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_CORE_SRC_LANG_FOM_COMMON_H
9#define SEN_LIBS_CORE_SRC_LANG_FOM_COMMON_H
10
11// sen
14#include "sen/core/meta/type.h"
15
16// xml parser
17#include "pugixml.hpp"
18
19// std
20#include <cstddef>
21#include <cstdint>
22#include <optional>
23#include <string>
24#include <string_view>
25#include <vector>
26
28{
29
31constexpr std::size_t maxStaticVectorSize = 1024 * 1024;
32
33//--------------------------------------------------------------------------------------------------------------
34// Names
35//--------------------------------------------------------------------------------------------------------------
36
38[[nodiscard]] bool startsWith(const std::string& str, const std::string subStr) noexcept;
39
41[[nodiscard]] bool isNumber(const std::string& s);
42
46[[nodiscard]] std::optional<std::uint64_t> parseUnsigned(std::string_view text);
47
49[[nodiscard]] std::vector<std::string_view> splitString(std::string_view input, std::string_view delimiters);
50
52[[nodiscard]] std::string toLower(const std::string& original);
53
56[[nodiscard]] std::string toLowerCamelCase(const std::string& original);
57
59[[nodiscard]] bool findStringIgnoreCase(const std::string& strHaystack, const std::string& strNeedle);
60
63[[nodiscard]] std::string toSenPropertyName(const std::string& original);
64
66[[nodiscard]] std::string formatSemantics(std::string str);
67
69[[nodiscard]] bool isTrue(std::string_view str, std::string_view attribute);
70
71//--------------------------------------------------------------------------------------------------------------
72// Nodes
73//--------------------------------------------------------------------------------------------------------------
74
77void collectClassesNodes(pugi::xml_node node, std::vector<pugi::xml_node>& result);
78
80void collectInteractionNodes(pugi::xml_node node, std::vector<pugi::xml_node>& result);
81
85[[nodiscard]] std::string computeInteractionPath(const pugi::xpath_node& interactionNode);
86
90[[nodiscard]] std::string interactionClassPath(pugi::xml_node node);
91
94[[nodiscard]] std::string objectClassPath(pugi::xml_node node);
95
96//--------------------------------------------------------------------------------------------------------------
97// Types
98//--------------------------------------------------------------------------------------------------------------
99
101[[nodiscard]] std::string computeClassPath(const ClassType* parent, const std::string& child, const ClassType* root);
102
104void collectConstructorArgs(std::vector<Arg>& list, const ClassType& type);
105
107void collectConstructorArgs(std::vector<Arg>& list, const ClassSpec& spec);
108
110[[nodiscard]] std::vector<Arg> prependArgs(const std::vector<Arg>& currentArgs, const std::vector<Arg>& argsToPrepend);
111
114[[nodiscard]] std::optional<TransportMode> getTransportMode(const std::string& hlaTransport);
115
117[[nodiscard]] std::optional<TransportMode> getMethodTransportMode(const std::string& hlaTransport);
118
120[[nodiscard]] std::optional<TransportMode> getEventTransportMode(const std::string& hlaTransport);
121
122} // namespace sen::lang::fom
123
124#endif // SEN_LIBS_CORE_SRC_LANG_FOM_COMMON_H
Definition fom_common.h:28
void collectInteractionNodes(pugi::xml_node node, std::vector< pugi::xml_node > &result)
The same for interaction classes, on semantics or at least one parameter.
std::string toSenPropertyName(const std::string &original)
An HLA attribute name as a sen property name. Five names belong to the Object class,...
void collectClassesNodes(pugi::xml_node node, std::vector< pugi::xml_node > &result)
Collects the object class nodes that declare a class, descending through nested ones....
std::string computeClassPath(const ClassType *parent, const std::string &child, const ClassType *root)
The path of a class in the FOM hierarchy, up to but not including root.
std::vector< std::string_view > splitString(std::string_view input, std::string_view delimiters)
Splits input on any of the delimiters. Empty pieces are kept.
std::string computeInteractionPath(const pugi::xpath_node &interactionNode)
The path of an interaction's PARENT, without the interaction root, which is what walking up the hiera...
bool isTrue(std::string_view str, std::string_view attribute)
Reads true or false, ignoring case. An empty string is false; anything else throws.
std::optional< std::uint64_t > parseUnsigned(std::string_view text)
Reads a decimal unsigned value, or nothing if the text is not one or does not fit in 64 bits....
bool isNumber(const std::string &s)
True if s is not empty and holds digits only.
std::string objectClassPath(pugi::xml_node node)
The nested path of an object class node, without the HLA root, joined with dots. A class is identifie...
bool findStringIgnoreCase(const std::string &strHaystack, const std::string &strNeedle)
True if strNeedle appears anywhere in strHaystack, ignoring case.
std::string toLowerCamelCase(const std::string &original)
An HLA name as a sen member name: words split on _ and -, lower camel case, and a Val suffix where th...
std::optional< TransportMode > getTransportMode(const std::string &hlaTransport)
The transport mode for a property, from the FOM transportation. Nothing for a value the DIF does not ...
bool startsWith(const std::string &str, const std::string subStr) noexcept
True if str begins with subStr.
std::string toLower(const std::string &original)
A copy of original with every ASCII upper case letter lowered.
std::optional< TransportMode > getMethodTransportMode(const std::string &hlaTransport)
The same for a method: best effort is unicast there, because a call goes to one object.
std::string formatSemantics(std::string str)
Semantics text as a description: newlines become spaces and quotes become apostrophes.
void collectConstructorArgs(std::vector< Arg > &list, const ClassType &type)
The static read-write properties of a class, parents first: these are its constructor arguments.
std::optional< TransportMode > getEventTransportMode(const std::string &hlaTransport)
The same for an event.
std::vector< Arg > prependArgs(const std::vector< Arg > &currentArgs, const std::vector< Arg > &argsToPrepend)
argsToPrepend followed by currentArgs.
std::string interactionClassPath(pugi::xml_node node)
The nested path of an interaction class node, without the interaction root, joined with dots....
constexpr std::size_t maxStaticVectorSize
The largest maximum a bounded sequence is given. Above this an array becomes unbounded.
Definition fom_common.h:31