mirror of
https://github.com/nasa/fpp.git
synced 2025-12-12 04:41:37 -06:00
226 lines
4.8 KiB
C++
Vendored
226 lines
4.8 KiB
C++
Vendored
// ======================================================================
|
|
// \title Struct1ArrayAc.cpp
|
|
// \author Generated by fpp-to-cpp
|
|
// \brief cpp file for Struct1 array
|
|
// ======================================================================
|
|
|
|
#include "Fw/Types/Assert.hpp"
|
|
#include "Struct1ArrayAc.hpp"
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Constructors
|
|
// ----------------------------------------------------------------------
|
|
|
|
Struct1 ::
|
|
Struct1() :
|
|
Serializable()
|
|
{
|
|
// Construct using element-wise constructor
|
|
*this = Struct1(
|
|
M::S1(0.0f, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, false, Fw::String("")),
|
|
M::S1(0.0f, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, false, Fw::String("")),
|
|
M::S1(0.0f, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, false, Fw::String("")),
|
|
M::S1(0.0f, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, false, Fw::String("")),
|
|
M::S1(0.0f, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, false, Fw::String(""))
|
|
);
|
|
}
|
|
|
|
Struct1 ::
|
|
Struct1(const ElementType (&a)[SIZE]) :
|
|
Serializable()
|
|
{
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
this->elements[index] = a[index];
|
|
}
|
|
}
|
|
|
|
Struct1 ::
|
|
Struct1(const ElementType& e) :
|
|
Serializable()
|
|
{
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
this->elements[index] = e;
|
|
}
|
|
}
|
|
|
|
Struct1 ::
|
|
Struct1(
|
|
const ElementType& e1,
|
|
const ElementType& e2,
|
|
const ElementType& e3,
|
|
const ElementType& e4,
|
|
const ElementType& e5
|
|
) :
|
|
Serializable()
|
|
{
|
|
this->elements[0] = e1;
|
|
this->elements[1] = e2;
|
|
this->elements[2] = e3;
|
|
this->elements[3] = e4;
|
|
this->elements[4] = e5;
|
|
}
|
|
|
|
Struct1 ::
|
|
Struct1(const Struct1& obj) :
|
|
Serializable()
|
|
{
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
this->elements[index] = obj.elements[index];
|
|
}
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Operators
|
|
// ----------------------------------------------------------------------
|
|
|
|
Struct1::ElementType& Struct1 ::
|
|
operator[](const U32 i)
|
|
{
|
|
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
|
|
return this->elements[i];
|
|
}
|
|
|
|
const Struct1::ElementType& Struct1 ::
|
|
operator[](const U32 i) const
|
|
{
|
|
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
|
|
return this->elements[i];
|
|
}
|
|
|
|
Struct1& Struct1 ::
|
|
operator=(const Struct1& obj)
|
|
{
|
|
if (this == &obj) {
|
|
return *this;
|
|
}
|
|
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
this->elements[index] = obj.elements[index];
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
Struct1& Struct1 ::
|
|
operator=(const ElementType (&a)[SIZE])
|
|
{
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
this->elements[index] = a[index];
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
Struct1& Struct1 ::
|
|
operator=(const ElementType& e)
|
|
{
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
this->elements[index] = e;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
bool Struct1 ::
|
|
operator==(const Struct1& obj) const
|
|
{
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
if (!((*this)[index] == obj[index])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool Struct1 ::
|
|
operator!=(const Struct1& obj) const
|
|
{
|
|
return !(*this == obj);
|
|
}
|
|
|
|
#ifdef BUILD_UT
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Struct1& obj) {
|
|
Fw::String s;
|
|
obj.toString(s);
|
|
os << s;
|
|
return os;
|
|
}
|
|
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Public member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
Fw::SerializeStatus Struct1 ::
|
|
serialize(Fw::SerializeBufferBase& buffer) const
|
|
{
|
|
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
status = buffer.serialize((*this)[index]);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
}
|
|
return status;
|
|
}
|
|
|
|
Fw::SerializeStatus Struct1 ::
|
|
deserialize(Fw::SerializeBufferBase& buffer)
|
|
{
|
|
Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK;
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
status = buffer.deserialize((*this)[index]);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
}
|
|
return status;
|
|
}
|
|
|
|
FwSizeType Struct1 ::
|
|
serializedSize() const
|
|
{
|
|
FwSizeType size = 0;
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
size += this->elements[index].serializedSize();
|
|
}
|
|
return size;
|
|
}
|
|
|
|
#if FW_SERIALIZABLE_TO_STRING
|
|
|
|
void Struct1 ::
|
|
toString(Fw::StringBase& sb) const
|
|
{
|
|
// Clear the output string
|
|
sb = "";
|
|
|
|
// Array prefix
|
|
if (sb.length() + 2 <= sb.maxLength()) {
|
|
sb += "[ ";
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
for (U32 index = 0; index < SIZE; index++) {
|
|
Fw::String tmp;
|
|
this->elements[index].toString(tmp);
|
|
|
|
FwSizeType size = tmp.length() + (index > 0 ? 2 : 0);
|
|
if ((size + sb.length()) <= sb.maxLength()) {
|
|
if (index > 0) {
|
|
sb += ", ";
|
|
}
|
|
sb += tmp;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Array suffix
|
|
if (sb.length() + 2 <= sb.maxLength()) {
|
|
sb += " ]";
|
|
}
|
|
}
|
|
|
|
#endif
|