-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathString2ArrayAc.ref.hpp
More file actions
189 lines (142 loc) · 5.1 KB
/
String2ArrayAc.ref.hpp
File metadata and controls
189 lines (142 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// ======================================================================
// \title String2ArrayAc.hpp
// \author Generated by fpp-to-cpp
// \brief hpp file for String2 array
// ======================================================================
#ifndef String2ArrayAc_HPP
#define String2ArrayAc_HPP
#include <initializer_list>
#include "Fw/FPrimeBasicTypes.hpp"
#include "Fw/Types/ExternalString.hpp"
#include "Fw/Types/Serializable.hpp"
#include "Fw/Types/String.hpp"
#include "config/FwSizeStoreTypeAliasAc.hpp"
//! An array of strings with specified default value and format string
class String2 :
public Fw::Serializable
{
public:
// ----------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------
//! The element type
using ElementType = Fw::ExternalString;
public:
// ----------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------
enum {
//! The size of the array
SIZE = 2,
//! The string size of each element
ELEMENT_STRING_SIZE = static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE),
//! The buffer size of each element
ELEMENT_BUFFER_SIZE = Fw::StringBase::BUFFER_SIZE(ELEMENT_STRING_SIZE),
//! The serialized size of each element
ELEMENT_SERIALIZED_SIZE = Fw::StringBase::STATIC_SERIALIZED_SIZE(ELEMENT_STRING_SIZE),
//! The size of the serial representation
SERIALIZED_SIZE = SIZE * ELEMENT_SERIALIZED_SIZE
};
public:
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
//! Constructor (default value)
String2();
//! Constructor (primitive array)
String2(
const ElementType (&a)[SIZE] //!< The array
);
//! Constructor (single element)
explicit String2(
const Fw::StringBase& e //!< The element
);
//! Constructor (initializer list)
String2(
const std::initializer_list<Fw::String>& il //!< The initializer list
);
//! Copy constructor
String2(
const String2& obj //!< The source object
);
public:
// ----------------------------------------------------------------------
// Operators
// ----------------------------------------------------------------------
//! Subscript operator
ElementType& operator[](
const FwSizeType i //!< The subscript index
);
//! Const subscript operator
const ElementType& operator[](
const FwSizeType i //!< The subscript index
) const;
//! Copy assignment operator (object)
String2& operator=(
const String2& obj //!< The source object
);
//! Copy assignment operator (primitive array)
String2& operator=(
const ElementType (&a)[SIZE] //!< The source array
);
//! Copy assignment operator (initializer list)
String2& operator=(
const std::initializer_list<Fw::String>& il //!< The initializer list
);
//! Copy assignment operator (single element)
String2& operator=(
const ElementType& e //!< The element
);
//! Equality operator
bool operator==(
const String2& obj //!< The other object
) const;
//! Inequality operator
bool operator!=(
const String2& obj //!< The other object
) const;
#ifdef BUILD_UT
//! Ostream operator
friend std::ostream& operator<<(
std::ostream& os, //!< The ostream
const String2& obj //!< The object
);
#endif
public:
// ----------------------------------------------------------------------
// Public member functions
// ----------------------------------------------------------------------
//! Serialization
Fw::SerializeStatus serializeTo(
Fw::SerialBufferBase& buffer, //!< The serial buffer
Fw::Endianness mode = Fw::Endianness::BIG //!< Endianness of serialized buffer
) const;
//! Deserialization
Fw::SerializeStatus deserializeFrom(
Fw::SerialBufferBase& buffer, //!< The serial buffer
Fw::Endianness mode = Fw::Endianness::BIG //!< Endianness of serialized buffer
);
//! Get the dynamic serialized size of the array
FwSizeType serializedSize() const;
#if FW_SERIALIZABLE_TO_STRING
//! Convert array to string
void toString(
Fw::StringBase& sb //!< The StringBase object to hold the result
) const;
#endif
private:
// ----------------------------------------------------------------------
// Private member functions
// ----------------------------------------------------------------------
//! Initialize elements
void initElements();
private:
// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------
//! The char buffers
char buffers[SIZE][ELEMENT_BUFFER_SIZE];
//! The array elements
ElementType elements[SIZE];
};
#endif