mirror of
https://github.com/nasa/fpp.git
synced 2025-12-12 04:41:37 -06:00
155 lines
3.2 KiB
C++
155 lines
3.2 KiB
C++
// ======================================================================
|
|
// \title PrimitiveStructSerializableAc.cpp
|
|
// \author Generated by fpp-to-cpp
|
|
// \brief cpp file for PrimitiveStruct struct
|
|
// ======================================================================
|
|
|
|
#include "cstdio"
|
|
#include "cstring"
|
|
|
|
#include "Fw/Types/Assert.hpp"
|
|
#include "Fw/Types/StringUtils.hpp"
|
|
#include "PrimitiveStructSerializableAc.hpp"
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Constructors
|
|
// ----------------------------------------------------------------------
|
|
|
|
PrimitiveStruct ::
|
|
PrimitiveStruct() :
|
|
Serializable(),
|
|
s1(0.0f, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, false, "")
|
|
{
|
|
|
|
}
|
|
|
|
PrimitiveStruct ::
|
|
PrimitiveStruct(const Primitive& s1) :
|
|
Serializable(),
|
|
s1(s1)
|
|
{
|
|
|
|
}
|
|
|
|
PrimitiveStruct ::
|
|
PrimitiveStruct(const PrimitiveStruct& obj) :
|
|
Serializable(),
|
|
s1(obj.s1)
|
|
{
|
|
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Operators
|
|
// ----------------------------------------------------------------------
|
|
|
|
PrimitiveStruct& PrimitiveStruct ::
|
|
operator=(const PrimitiveStruct& obj)
|
|
{
|
|
if (this == &obj) {
|
|
return *this;
|
|
}
|
|
|
|
set(obj.s1);
|
|
return *this;
|
|
}
|
|
|
|
bool PrimitiveStruct ::
|
|
operator==(const PrimitiveStruct& obj) const
|
|
{
|
|
return (this->s1 == obj.s1);
|
|
}
|
|
|
|
bool PrimitiveStruct ::
|
|
operator!=(const PrimitiveStruct& obj) const
|
|
{
|
|
return !(*this == obj);
|
|
}
|
|
|
|
#ifdef BUILD_UT
|
|
|
|
std::ostream& operator<<(std::ostream& os, const PrimitiveStruct& obj) {
|
|
Fw::String s;
|
|
obj.toString(s);
|
|
os << s.toChar();
|
|
return os;
|
|
}
|
|
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
Fw::SerializeStatus PrimitiveStruct ::
|
|
serialize(Fw::SerializeBufferBase& buffer) const
|
|
{
|
|
Fw::SerializeStatus status;
|
|
|
|
status = buffer.serialize(this->s1);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
Fw::SerializeStatus PrimitiveStruct ::
|
|
deserialize(Fw::SerializeBufferBase& buffer)
|
|
{
|
|
Fw::SerializeStatus status;
|
|
|
|
status = buffer.deserialize(this->s1);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
#if FW_SERIALIZABLE_TO_STRING || BUILD_UT
|
|
|
|
void PrimitiveStruct ::
|
|
toString(Fw::StringBase& sb) const
|
|
{
|
|
static const char* formatString =
|
|
"( "
|
|
"s1 = %s"
|
|
" )";
|
|
|
|
// Declare strings to hold any serializable toString() arguments
|
|
Fw::String s1Str;
|
|
|
|
// Call toString for arrays and serializable types
|
|
this->s1.toString(s1Str);
|
|
|
|
char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE];
|
|
(void) snprintf(
|
|
outputString,
|
|
FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE,
|
|
formatString,
|
|
s1Str.toChar()
|
|
);
|
|
|
|
outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
|
|
sb = outputString;
|
|
}
|
|
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Setter functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
void PrimitiveStruct ::
|
|
set(const Primitive& s1)
|
|
{
|
|
this->s1 = s1;
|
|
}
|
|
|
|
void PrimitiveStruct ::
|
|
sets1(const Primitive& s1)
|
|
{
|
|
this->s1 = s1;
|
|
}
|