OSFI-C++
3.9.2
OpenSF Integration Library
base.h
1
/*
2
* openSF Integration Libraries (OSFI)
3
* Deimos Space, S.L.U.
4
*
5
* This file is part of OSFI. OSFI is free software; you can redistribute it
6
* and/or modify it under the terms of the 'ESA Software Community Licence Permissive' as
7
* published by the European Space Agency; either version 2.4 of the License,
8
* or (at your option) any later version. You should have received a
9
* copy of the 'ESA Software Community Licence Permissive - v2.4' along with this program
10
* or one can be found at <http://eop-cfi.esa.int/index.php/docs-and-mission-data/licensing-documents>.
11
*
12
* @file
13
* @brief OSFI-C++ header common to many classes in the ConFM module.
14
*/
15
16
#ifndef OSFI_CONFM_BASE_H_
17
#define OSFI_CONFM_BASE_H_
18
19
#if __cplusplus >= 201402L
20
21
# define OSFI_DEPRECATED(reason) [[deprecated(reason)]]
22
#else
23
# define OSFI_DEPRECATED(reason)
/*deprecated*/
24
#endif
25
26
#include <string>
27
#include <vector>
28
#include <iosfwd>
29
#include <utility>
30
#include <cstdint>
31
32
namespace
osfi {
34
namespace
confm {
38
enum class
ElementType
{
39
INTEGER = 1,
40
FLOAT, BOOLEAN, STRING, FILE, FOLDER, TIME
41
};
45
std::string
to_string
(
ElementType
et);
49
ElementType
as_ElementType
(
const
std::string& str);
50
54
struct
TimeValue
{
55
std::int16_t year;
56
std::int8_t month, dom, hour, minute, sec;
57
std::int32_t nanosec;
58
// TODO in the future, implement operator<=> for C++20-compliant compilers
59
// auto operator<=>(const TimeValue& other) const = default;
60
};
62
std::string
to_string
(
const
TimeValue
&);
64
std::ostream&
operator<<
(std::ostream&,
const
TimeValue
&);
69
bool
operator==
(
const
TimeValue
& a,
const
TimeValue
& b);
74
bool
operator<
(
const
TimeValue
& a,
const
TimeValue
& b);
76
#define OSFI_RELOP_IMPL(op, T) \
77
inline bool operator op(const T& a, const T& b) { \
78
return std::rel_ops::operator op(a, b); \
79
}
80
OSFI_RELOP_IMPL(!=,
TimeValue
)
81
OSFI_RELOP_IMPL(<=,
TimeValue
)
82
OSFI_RELOP_IMPL(>=,
TimeValue
)
83
OSFI_RELOP_IMPL(>,
TimeValue
)
84
#undef OSFI_RELOP_IMPL
85
87
template
<ElementType et>
88
struct
parsed_type
;
89
// Specializations for each element type
90
template
<>
struct
parsed_type
<
ElementType
::INTEGER> {
using
type = int; };
91
template
<>
struct
parsed_type
<
ElementType
::FLOAT> {
using
type = double; };
92
template
<>
struct
parsed_type
<
ElementType
::BOOLEAN> {
using
type = bool; };
93
template
<>
struct
parsed_type
<
ElementType
::STRING> {
using
type = std::string; };
94
template
<>
struct
parsed_type
<
ElementType
::FILE> {
using
type = std::string; };
95
template
<>
struct
parsed_type
<
ElementType
::FOLDER> {
using
type = std::string; };
96
template
<>
struct
parsed_type
<
ElementType
::TIME> {
using
type
=
TimeValue
; };
97
99
template
<ElementType et>
100
using
parsed_type_t
=
typename
parsed_type<et>::type
;
101
}
102
}
103
104
#endif // OSFI_CONFM_BASE_H_
osfi::confm::parsed_type
Definition:
base.h:88
osfi::confm::to_string
std::string to_string(ElementType et)
osfi::confm::TimeValue
Definition:
base.h:54
osfi::confm::operator<
bool operator<(const TimeValue &a, const TimeValue &b)
osfi::confm::ElementType
ElementType
Definition:
base.h:38
osfi::confm::parsed_type_t
typename parsed_type< et >::type parsed_type_t
Definition:
base.h:100
osfi::confm::operator==
bool operator==(const TimeValue &a, const TimeValue &b)
osfi::confm::operator<<
std::ostream & operator<<(std::ostream &, const TimeValue &)
osfi::confm::as_ElementType
ElementType as_ElementType(const std::string &str)
include
cpp
ConFM
base.h
Generated by
1.8.17