F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
StatementArgBuffer.cpp
Go to the documentation of this file.
2 #include <Fw/Types/Assert.hpp>
4 
5 namespace Fw {
6 
8  : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {
10  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
11 }
12 
13 StatementArgBuffer::StatementArgBuffer() : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {}
14 
16 
17 // m_bufferData contents are copied via setBuff below
18 // cppcheck-suppress missingMemberCopy
20  : Fw::LinearBufferBase(m_bufferData, sizeof(m_bufferData)) {
21  SerializeStatus stat = LinearBufferBase::setBuff(other.m_bufferData, other.getSize());
22  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
23 }
24 
26  if (this == &other) {
27  return *this;
28  }
29 
30  SerializeStatus stat = LinearBufferBase::setBuff(other.m_bufferData, other.getSize());
31  FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
32  return *this;
33 }
34 
35 Serializable::SizeType StatementArgBuffer::getBuffCapacity() const {
36  return this->getCapacity();
37 }
38 
40  if (this->getSize() != other.getSize()) {
41  return false;
42  }
43 
44  const U8* us = this->getBuffAddr();
45  const U8* them = other.getBuffAddr();
46 
47  FW_ASSERT(us != nullptr);
48  FW_ASSERT(them != nullptr);
49 
50  const Serializable::SizeType size = this->getSize();
51  for (Serializable::SizeType byte = 0; byte < size; byte++) {
52  if (us[byte] != them[byte]) {
53  return false;
54  }
55  }
56 
57  return true;
58 }
59 
60 #if FW_SERIALIZABLE_TO_STRING
61 void StatementArgBuffer::toString(Fw::StringBase& text) const {
62  static const char* formatString = "(data = %p, size = %" PRI_FwSizeType ")";
63  (void)text.format(formatString, &this->m_bufferData, this->getSize()); // display string may safely truncate
64 }
65 #endif
66 } // namespace Fw
Serialization/Deserialization operation was successful.
SerializeStatus setBuff(const U8 *src, Serializable::SizeType length) override
Set buffer contents from external source.
PlatformSizeType FwSizeType
StatementArgBuffer & operator=(const StatementArgBuffer &other)
#define PRI_FwSizeType
Serializable::SizeType getSize() const override
Get current buffer size.
Serializable::SizeType getCapacity() const override
Get buffer capacity.
SerializeStatus
forward declaration for string
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
FwSizeType SizeType
bool operator==(const StatementArgBuffer &other) const
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
Declares F Prime string base class.
Implementation of malloc based allocator.
#define FW_ASSERT(...)
Definition: Assert.hpp:14