fpp/compiler/tools/fpp-to-cpp/test/port/StringPortAc.ref.cpp
2022-11-01 20:51:09 -07:00

273 lines
5.2 KiB
C++

// ======================================================================
// \title StringPortAc.cpp
// \author Generated by fpp-to-cpp
// \brief cpp file for String port
// ======================================================================
#include <cstdio>
#include <cstring>
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/StringUtils.hpp"
#include "StringPortAc.hpp"
// ----------------------------------------------------------------------
// StringSize80 class
// ----------------------------------------------------------------------
StringSize80 ::
StringSize80() :
StringBase()
{
this->m_buf[0] = 0;
}
StringSize80 ::
StringSize80(const char* src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
}
StringSize80 ::
StringSize80(const Fw::StringBase& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringSize80 ::
StringSize80(const StringSize80& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringSize80 ::
~StringSize80()
{
}
StringSize80& 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;
}
StringSize80& 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;
}
StringSize80& StringSize80 ::
operator=(const char* other)
{
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
return *this;
}
const char* StringSize80 ::
toChar() const
{
return this->m_buf;
}
NATIVE_UINT_TYPE StringSize80 ::
getCapacity() const
{
return sizeof(this->m_buf);
}
// ----------------------------------------------------------------------
// StringSize100 class
// ----------------------------------------------------------------------
StringSize100 ::
StringSize100() :
StringBase()
{
this->m_buf[0] = 0;
}
StringSize100 ::
StringSize100(const char* src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
}
StringSize100 ::
StringSize100(const Fw::StringBase& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringSize100 ::
StringSize100(const StringSize100& src) :
StringBase()
{
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
}
StringSize100 ::
~StringSize100()
{
}
StringSize100& StringSize100 ::
operator=(const StringSize100& other)
{
if (this == &other) {
return *this;
}
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
return *this;
}
StringSize100& StringSize100 ::
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;
}
StringSize100& StringSize100 ::
operator=(const char* other)
{
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
return *this;
}
const char* StringSize100 ::
toChar() const
{
return this->m_buf;
}
NATIVE_UINT_TYPE StringSize100 ::
getCapacity() const
{
return sizeof(this->m_buf);
}
// ----------------------------------------------------------------------
// Input Port Member functions
// ----------------------------------------------------------------------
InputStringPort ::
InputStringPort() :
Fw::InputPortBase(),
m_func(nullptr)
{
}
void InputStringPort ::
init()
{
Fw::InputPortBase::init();
}
void InputStringPort ::
addCallComp(
Fw::PassiveComponentBase* callComp,
CompFuncPtr funcPtr
)
{
FW_ASSERT(callComp);
FW_ASSERT(funcPtr);
this->m_comp = callComp;
this->m_func = funcPtr;
this->m_connObj = callComp;
}
void InputStringPort ::
invoke(
const StringSize80& str80,
StringSize80& str80Ref,
const StringSize100& str100,
StringSize100& str100Ref
)
{
#if FW_PORT_TRACING == 1
this->trace();
#endif
FW_ASSERT(this->m_comp);
FW_ASSERT(this->m_func);
return this->m_func(this->m_comp, this->m_portNum, str80, str80Ref, str100, str100Ref);
}
// ----------------------------------------------------------------------
// Output Port Member functions
// ----------------------------------------------------------------------
OutputStringPort ::
OutputStringPort() :
Fw::OutputPortBase(),
m_port(nullptr)
{
}
void OutputStringPort ::
init()
{
Fw::OutputPortBase::init();
}
void OutputStringPort ::
addCallPort(InputStringPort* callPort)
{
FW_ASSERT(callPort);
this->m_port = callPort;
this->m_connObj = callPort;
#if FW_PORT_SERIALIZATION == 1
this->m_serPort = nullptr;
#endif
}
void OutputStringPort ::
invoke(
const StringSize80& str80,
StringSize80& str80Ref,
const StringSize100& str100,
StringSize100& str100Ref
)
{
#if FW_PORT_TRACING == 1
this->trace();
#endif
#if FW_PORT_SERIALIZATION
FW_ASSERT(this->m_port || this->m_serPort);
#else
FW_ASSERT(this->m_port);
#endif
return this->m_port->invoke(str80, str80Ref, str100, str100Ref);
}