fpp/compiler/tools/fpp-to-cpp/test/struct/StringArraySerializableAc.ref.cpp
2024-04-29 19:47:09 -07:00

402 lines
8.1 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;
}
Fw::StringBase::SizeType 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;
}
Fw::StringBase::SizeType StringArray::StringSize40 ::
getCapacity() const
{
return sizeof(this->m_buf);
}
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
StringArray ::
StringArray() :
Serializable(),
m_s1("")
{
for (FwSizeType i = 0; i < 16; i++) {
this->m_s2[i] = "";
}
}
StringArray ::
StringArray(
const Fw::StringBase& s1,
const Type_of_s2& s2
) :
Serializable(),
m_s1(s1)
{
for (FwSizeType i = 0; i < 16; i++) {
this->m_s2[i] = s2[i];
}
}
StringArray ::
StringArray(const StringArray& obj) :
Serializable(),
m_s1(obj.m_s1)
{
for (FwSizeType i = 0; i < 16; i++) {
this->m_s2[i] = obj.m_s2[i];
}
}
StringArray ::
StringArray(
const Fw::StringBase& s1,
const Fw::StringBase& s2
) :
Serializable(),
m_s1(s1)
{
for (FwSizeType i = 0; i < 16; i++) {
this->m_s2[i] = s2;
}
}
// ----------------------------------------------------------------------
// Operators
// ----------------------------------------------------------------------
StringArray& StringArray ::
operator=(const StringArray& obj)
{
if (this == &obj) {
return *this;
}
set(obj.m_s1, obj.m_s2);
return *this;
}
bool StringArray ::
operator==(const StringArray& obj) const
{
// Compare non-array members
if (!(this->m_s1 == obj.m_s1)) {
return false;
}
// Compare array members
if (!(this->m_s2 == obj.m_s2)) {
for (FwSizeType i = 0; i < 16; i++) {
if (!(this->m_s2[i] == obj.m_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->m_s1);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
for (FwSizeType i = 0; i < 16; i++) {
status = buffer.serialize(this->m_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->m_s1);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
for (FwSizeType i = 0; i < 16; i++) {
status = buffer.deserialize(this->m_s2[i]);
if (status != Fw::FW_SERIALIZE_OK) {
return status;
}
}
return status;
}
#if FW_SERIALIZABLE_TO_STRING
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->m_s1.toChar(),
this->m_s2[0].toChar(),
this->m_s2[1].toChar(),
this->m_s2[2].toChar(),
this->m_s2[3].toChar(),
this->m_s2[4].toChar(),
this->m_s2[5].toChar(),
this->m_s2[6].toChar(),
this->m_s2[7].toChar(),
this->m_s2[8].toChar(),
this->m_s2[9].toChar(),
this->m_s2[10].toChar(),
this->m_s2[11].toChar(),
this->m_s2[12].toChar(),
this->m_s2[13].toChar(),
this->m_s2[14].toChar(),
this->m_s2[15].toChar()
);
outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
sb = outputString;
}
#endif
// ----------------------------------------------------------------------
// Setter functions
// ----------------------------------------------------------------------
void StringArray ::
set(
const Fw::StringBase& s1,
const Type_of_s2& s2
)
{
this->m_s1 = s1;
for (FwSizeType i = 0; i < 16; i++) {
this->m_s2[i] = s2[i];
}
}
void StringArray ::
sets1(const Fw::StringBase& s1)
{
this->m_s1 = s1;
}
void StringArray ::
sets2(const Type_of_s2& s2)
{
for (FwSizeType i = 0; i < 16; i++) {
this->m_s2[i] = s2[i];
}
}