mirror of
https://github.com/nasa/fpp.git
synced 2025-12-13 16:47:48 -06:00
280 lines
5.4 KiB
C++
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;
|
|
}
|
|
|
|
NATIVE_UINT_TYPE Default::StringSize40 ::
|
|
getCapacity() const
|
|
{
|
|
return sizeof(this->m_buf);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Constructors
|
|
// ----------------------------------------------------------------------
|
|
|
|
Default ::
|
|
Default() :
|
|
Serializable(),
|
|
m_varU32(54),
|
|
m_S1("hello"),
|
|
m_varF64(0.0)
|
|
{
|
|
|
|
}
|
|
|
|
Default ::
|
|
Default(
|
|
U32 varU32,
|
|
const StringSize40& S1,
|
|
F64 varF64
|
|
) :
|
|
Serializable(),
|
|
m_varU32(varU32),
|
|
m_S1(S1),
|
|
m_varF64(varF64)
|
|
{
|
|
|
|
}
|
|
|
|
Default ::
|
|
Default(const Default& obj) :
|
|
Serializable(),
|
|
m_varU32(obj.m_varU32),
|
|
m_S1(obj.m_S1),
|
|
m_varF64(obj.m_varF64)
|
|
{
|
|
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Operators
|
|
// ----------------------------------------------------------------------
|
|
|
|
Default& Default ::
|
|
operator=(const Default& obj)
|
|
{
|
|
if (this == &obj) {
|
|
return *this;
|
|
}
|
|
|
|
set(obj.m_varU32, obj.m_S1, obj.m_varF64);
|
|
return *this;
|
|
}
|
|
|
|
bool Default ::
|
|
operator==(const Default& obj) const
|
|
{
|
|
return (
|
|
(this->m_varU32 == obj.m_varU32) &&
|
|
(this->m_S1 == obj.m_S1) &&
|
|
(this->m_varF64 == obj.m_varF64)
|
|
);
|
|
}
|
|
|
|
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_varU32);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
status = buffer.serialize(this->m_S1);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
status = buffer.serialize(this->m_varF64);
|
|
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_varU32);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
status = buffer.deserialize(this->m_S1);
|
|
if (status != Fw::FW_SERIALIZE_OK) {
|
|
return status;
|
|
}
|
|
status = buffer.deserialize(this->m_varF64);
|
|
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 =
|
|
"( "
|
|
"m_varU32 = %" PRIu32 ", "
|
|
"m_S1 = %s, "
|
|
"m_varF64 = %f"
|
|
" )";
|
|
|
|
char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE];
|
|
(void) snprintf(
|
|
outputString,
|
|
FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE,
|
|
formatString,
|
|
this->m_varU32,
|
|
this->m_S1.toChar(),
|
|
this->m_varF64
|
|
);
|
|
|
|
outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
|
|
sb = outputString;
|
|
}
|
|
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Setter functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
void Default ::
|
|
set(
|
|
U32 varU32,
|
|
const StringSize40& S1,
|
|
F64 varF64
|
|
)
|
|
{
|
|
this->m_varU32 = varU32;
|
|
this->m_S1 = S1;
|
|
this->m_varF64 = varF64;
|
|
}
|
|
|
|
void Default ::
|
|
setvarU32(U32 varU32)
|
|
{
|
|
this->m_varU32 = varU32;
|
|
}
|
|
|
|
void Default ::
|
|
setS1(const StringSize40& S1)
|
|
{
|
|
this->m_S1 = S1;
|
|
}
|
|
|
|
void Default ::
|
|
setvarF64(F64 varF64)
|
|
{
|
|
this->m_varF64 = varF64;
|
|
}
|