fpp/compiler/tools/fpp-to-cpp/test/array/PrimitiveU16ArrayAc.ref.cpp
2024-06-20 08:22:22 -07:00

196 lines
4.4 KiB
C++
Vendored

// ======================================================================
// \title PrimitiveU16ArrayAc.cpp
// \author Generated by fpp-to-cpp
// \brief cpp file for PrimitiveU16 array
// ======================================================================
#include "Fw/Types/Assert.hpp"
#include "PrimitiveU16ArrayAc.hpp"
namespace M {
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
PrimitiveU16 ::
PrimitiveU16() :
Serializable()
{
// Construct using element-wise constructor
*this = PrimitiveU16(
1,
2,
3
);
}
PrimitiveU16 ::
PrimitiveU16(const ElementType (&a)[SIZE]) :
Serializable()
{
for (U32 index = 0; index < SIZE; index++) {
this->elements[index] = a[index];
}
}
PrimitiveU16 ::
PrimitiveU16(const ElementType& e) :
Serializable()
{
for (U32 index = 0; index < SIZE; index++) {
this->elements[index] = e;
}
}
PrimitiveU16 ::
PrimitiveU16(
const ElementType& e1,
const ElementType& e2,
const ElementType& e3
) :
Serializable()
{
this->elements[0] = e1;
this->elements[1] = e2;
this->elements[2] = e3;
}
PrimitiveU16 ::
PrimitiveU16(const PrimitiveU16& obj) :
Serializable()
{
for (U32 index = 0; index < SIZE; index++) {
this->elements[index] = obj.elements[index];
}
}
// ----------------------------------------------------------------------
// Operators
// ----------------------------------------------------------------------
PrimitiveU16::ElementType& PrimitiveU16 ::
operator[](const U32 i)
{
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}
const PrimitiveU16::ElementType& PrimitiveU16 ::
operator[](const U32 i) const
{
FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
return this->elements[i];
}
PrimitiveU16& PrimitiveU16 ::
operator=(const PrimitiveU16& obj)
{
if (this == &obj) {
return *this;
}
for (U32 index = 0; index < SIZE; index++) {
this->elements[index] = obj.elements[index];
}
return *this;
}
PrimitiveU16& PrimitiveU16 ::
operator=(const ElementType (&a)[SIZE])
{
for (U32 index = 0; index < SIZE; index++) {
this->elements[index] = a[index];
}
return *this;
}
PrimitiveU16& PrimitiveU16 ::
operator=(const ElementType& e)
{
for (U32 index = 0; index < SIZE; index++) {
this->elements[index] = e;
}
return *this;
}
bool PrimitiveU16 ::
operator==(const PrimitiveU16& obj) const
{
for (U32 index = 0; index < SIZE; index++) {
if (!((*this)[index] == obj[index])) {
return false;
}
}
return true;
}
bool PrimitiveU16 ::
operator!=(const PrimitiveU16& obj) const
{
return !(*this == obj);
}
#ifdef BUILD_UT
std::ostream& operator<<(std::ostream& os, const PrimitiveU16& obj) {
Fw::String s;
obj.toString(s);
os << s;
return os;
}
#endif
// ----------------------------------------------------------------------
// Public member functions
// ----------------------------------------------------------------------
Fw::SerializeStatus PrimitiveU16 ::
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 PrimitiveU16 ::
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;
}
#if FW_SERIALIZABLE_TO_STRING
void PrimitiveU16 ::
toString(Fw::StringBase& sb) const
{
static const char *formatString = "[ "
"%" PRIu16 " "
"%" PRIu16 " "
"%" PRIu16 " ]";
sb.format(
formatString,
this->elements[0],
this->elements[1],
this->elements[2]
);
}
#endif
}