fpp/compiler/tools/fpp-to-cpp/test/struct/StringArraySerializableAc.ref.cpp
2022-08-17 14:22:23 -07:00

402 lines
8.0 KiB
C++

// ======================================================================
// \title StringArraySerializableAc.cpp
// \author Generated by fpp-to-cpp
// \brief cpp file for StringArray struct
// ======================================================================
#include "cstdio"
#include "cstring"
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/StringUtils.hpp"
#include "StringArraySerializableAc.hpp"
// ----------------------------------------------------------------------
// StringSize80 class
// ----------------------------------------------------------------------
StringArray::StringSize80 ::
StringSize80() :
StringBase()
{
this->m_buf[0] = 0;
}
StringArray::StringSize80 ::
StringSize80(const char* src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
}
StringArray::StringSize80 ::
StringSize80(const Fw::StringBase& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringArray::StringSize80 ::
StringSize80(const StringSize80& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringArray::StringSize80 ::
~StringSize80()
{
}
StringArray::StringSize80& StringArray::StringSize80 ::
operator=(const StringSize80& other)
{
if (this == &other) {
return *this;
}
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
return *this;
}
StringArray::StringSize80& StringArray::StringSize80 ::
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;
}
StringArray::StringSize80& StringArray::StringSize80 ::
operator=(const char* other)
{
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
return *this;
}
const char* StringArray::StringSize80 ::
toChar() const
{
return this->m_buf;
}
NATIVE_UINT_TYPE StringArray::StringSize80 ::
getCapacity() const
{
return sizeof(this->m_buf);
}
// ----------------------------------------------------------------------
// StringSize40 class
// ----------------------------------------------------------------------
StringArray::StringSize40 ::
StringSize40() :
StringBase()
{
this->m_buf[0] = 0;
}
StringArray::StringSize40 ::
StringSize40(const char* src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
}
StringArray::StringSize40 ::
StringSize40(const Fw::StringBase& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringArray::StringSize40 ::
StringSize40(const StringSize40& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringArray::StringSize40 ::
~StringSize40()
{
}
StringArray::StringSize40& StringArray::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;
}
StringArray::StringSize40& StringArray::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;
}
StringArray::StringSize40& StringArray::StringSize40 ::
operator=(const char* other)
{
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
return *this;
}
const char* StringArray::StringSize40 ::
toChar() const
{
return this->m_buf;
}
NATIVE_UINT_TYPE StringArray::StringSize40 ::
getCapacity() const
{
return sizeof(this->m_buf);
}
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
StringArray ::
StringArray() :
Serializable(),
s1("")
{
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
this->s2[i] = "";
}
}
StringArray ::
StringArray(
const StringSize80& s1,
const Type_of_s2& s2
) :
Serializable(),
s1(s1)
{
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
this->s2[i] = s2[i];
}
}
StringArray ::
StringArray(const StringArray& obj) :
Serializable(),
s1(obj.s1)
{
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
this->s2[i] = obj.s2[i];
}
}
StringArray ::
StringArray(
const StringSize80& s1,
const StringSize40& s2
) :
Serializable(),
s1(s1)
{
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
this->s2[i] = s2;
}
}
// ----------------------------------------------------------------------
// Operators
// ----------------------------------------------------------------------
StringArray& StringArray ::
operator=(const StringArray& obj)
{
if (this == &obj) {
return *this;
}
set(obj.s1, obj.s2);
return *this;
}
bool StringArray ::
operator==(const StringArray& obj) const
{
// Compare non-array members
if (!(this->s1 == obj.s1)) {
return false;
}
// Compare array members
if (!(this->s2 == obj.s2)) {
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
if (!(this->s2[i] == obj.s2[i])) {
return false;
}
}
}
return true;
}
bool StringArray ::
operator!=(const StringArray& obj) const
{
return !(*this == obj);
}
#ifdef BUILD_UT
std::ostream& operator<<(std::ostream& os, const StringArray& obj) {
Fw::String s;
obj.toString(s);
os << s.toChar();
return os;
}
#endif
// ----------------------------------------------------------------------
// Member functions
// ----------------------------------------------------------------------
Fw::SerializeStatus StringArray ::
serialize(Fw::SerializeBufferBase& buffer) const
{
Fw::SerializeStatus status;
status = buffer.serialize(this->s1);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
status = buffer.serialize(this->s2[i]);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
}
return status;
}
Fw::SerializeStatus StringArray ::
deserialize(Fw::SerializeBufferBase& buffer)
{
Fw::SerializeStatus status;
status = buffer.deserialize(this->s1);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
status = buffer.deserialize(this->s2[i]);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
}
return status;
}
#if FW_SERIALIZABLE_TO_STRING || BUILD_UT
void StringArray ::
toString(Fw::StringBase& sb) const
{
static const char* formatString =
"( "
"s1 = %s, "
"s2 = [ %s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s, "
"%s ]"
" )";
char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE];
(void) snprintf(
outputString,
FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE,
formatString,
this->s1.toChar(),
this->s2[0].toChar(),
this->s2[1].toChar(),
this->s2[2].toChar(),
this->s2[3].toChar(),
this->s2[4].toChar(),
this->s2[5].toChar(),
this->s2[6].toChar(),
this->s2[7].toChar(),
this->s2[8].toChar(),
this->s2[9].toChar(),
this->s2[10].toChar(),
this->s2[11].toChar(),
this->s2[12].toChar(),
this->s2[13].toChar(),
this->s2[14].toChar(),
this->s2[15].toChar()
);
outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
sb = outputString;
}
#endif
// ----------------------------------------------------------------------
// Setter functions
// ----------------------------------------------------------------------
void StringArray ::
set(
const StringSize80& s1,
const Type_of_s2& s2
)
{
this->s1 = s1;
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
this->s2[i] = s2[i];
}
}
void StringArray ::
sets1(const StringSize80& s1)
{
this->s1 = s1;
}
void StringArray ::
sets2(const Type_of_s2& s2)
{
for (NATIVE_UINT_TYPE i = 0; i < 16; i++) {
this->s2[i] = s2[i];
}
}