fpp/compiler/tools/fpp-to-cpp/test/struct/DefaultSerializableAc.ref.cpp
Robert L. Bocchino Jr dab91ee1b3 Revise C++ code gen
Remove uses of NATIVE_UINT_TYPE
2024-02-27 22:48:34 -08:00

280 lines
5.4 KiB
C++

// ======================================================================
// \title DefaultSerializableAc.cpp
// \author Generated by fpp-to-cpp
// \brief cpp file for Default struct
// ======================================================================
#include "cstdio"
#include "cstring"
#include "DefaultSerializableAc.hpp"
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/StringUtils.hpp"
// ----------------------------------------------------------------------
// StringSize40 class
// ----------------------------------------------------------------------
Default::StringSize40 ::
StringSize40() :
StringBase()
{
this->m_buf[0] = 0;
}
Default::StringSize40 ::
StringSize40(const char* src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
}
Default::StringSize40 ::
StringSize40(const Fw::StringBase& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
Default::StringSize40 ::
StringSize40(const StringSize40& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
Default::StringSize40 ::
~StringSize40()
{
}
Default::StringSize40& Default::StringSize40 ::
operator=(const StringSize40& other)
{
if (this == &other) {
return *this;
}
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
return *this;
}
Default::StringSize40& Default::StringSize40 ::
operator=(const Fw::StringBase& other)
{
if (this == &other) {
return *this;
}
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
return *this;
}
Default::StringSize40& Default::StringSize40 ::
operator=(const char* other)
{
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
return *this;
}
const char* Default::StringSize40 ::
toChar() const
{
return this->m_buf;
}
Fw::StringBase::SizeType Default::StringSize40 ::
getCapacity() const
{
return sizeof(this->m_buf);
}
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
Default ::
Default() :
Serializable(),
m_mU32(54),
m_mS1("hello"),
m_mF64(0.0)
{
}
Default ::
Default(
U32 mU32,
const StringSize40& mS1,
F64 mF64
) :
Serializable(),
m_mU32(mU32),
m_mS1(mS1),
m_mF64(mF64)
{
}
Default ::
Default(const Default& obj) :
Serializable(),
m_mU32(obj.m_mU32),
m_mS1(obj.m_mS1),
m_mF64(obj.m_mF64)
{
}
// ----------------------------------------------------------------------
// Operators
// ----------------------------------------------------------------------
Default& Default ::
operator=(const Default& obj)
{
if (this == &obj) {
return *this;
}
set(obj.m_mU32, obj.m_mS1, obj.m_mF64);
return *this;
}
bool Default ::
operator==(const Default& obj) const
{
return (
(this->m_mU32 == obj.m_mU32) &&
(this->m_mS1 == obj.m_mS1) &&
(this->m_mF64 == obj.m_mF64)
);
}
bool Default ::
operator!=(const Default& obj) const
{
return !(*this == obj);
}
#ifdef BUILD_UT
std::ostream& operator<<(std::ostream& os, const Default& obj) {
Fw::String s;
obj.toString(s);
os << s.toChar();
return os;
}
#endif
// ----------------------------------------------------------------------
// Member functions
// ----------------------------------------------------------------------
Fw::SerializeStatus Default ::
serialize(Fw::SerializeBufferBase& buffer) const
{
Fw::SerializeStatus status;
status = buffer.serialize(this->m_mU32);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
status = buffer.serialize(this->m_mS1);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
status = buffer.serialize(this->m_mF64);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
return status;
}
Fw::SerializeStatus Default ::
deserialize(Fw::SerializeBufferBase& buffer)
{
Fw::SerializeStatus status;
status = buffer.deserialize(this->m_mU32);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
status = buffer.deserialize(this->m_mS1);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
status = buffer.deserialize(this->m_mF64);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
return status;
}
#if FW_SERIALIZABLE_TO_STRING
void Default ::
toString(Fw::StringBase& sb) const
{
static const char* formatString =
"( "
"mU32 = %" PRIu32 ", "
"mS1 = %s, "
"mF64 = %f"
" )";
char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE];
(void) snprintf(
outputString,
FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE,
formatString,
this->m_mU32,
this->m_mS1.toChar(),
this->m_mF64
);
outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
sb = outputString;
}
#endif
// ----------------------------------------------------------------------
// Setter functions
// ----------------------------------------------------------------------
void Default ::
set(
U32 mU32,
const StringSize40& mS1,
F64 mF64
)
{
this->m_mU32 = mU32;
this->m_mS1 = mS1;
this->m_mF64 = mF64;
}
void Default ::
setmU32(U32 mU32)
{
this->m_mU32 = mU32;
}
void Default ::
setmS1(const StringSize40& mS1)
{
this->m_mS1 = mS1;
}
void Default ::
setmF64(F64 mF64)
{
this->m_mF64 = mF64;
}