F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
SerialBuffer.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SerialBuffer.cpp
3 // \author bocchino
4 // \brief cpp file for SerialBuffer type
5 //
6 // \copyright
7 // Copyright (C) 2016 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
14 #include "Fw/Types/Assert.hpp"
15 
16 namespace Fw {
17 
18 SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : LinearBufferBase(data, capacity) {}
19 
20 FwSizeType SerialBuffer ::getBuffCapacity() const {
21  return this->getCapacity();
22 }
23 
25  const SerializeStatus status = this->setBuffLen(this->getCapacity());
26  FW_ASSERT(status == FW_SERIALIZE_OK);
27 }
28 
30  return this->serializeFrom(const_cast<U8*>(addr), n, Fw::Serialization::OMIT_LENGTH);
31 }
32 
34  return this->deserializeTo(addr, n, Fw::Serialization::OMIT_LENGTH);
35 }
36 
37 } // namespace Fw
Serialization/Deserialization operation was successful.
PlatformSizeType FwSizeType
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
void fill()
Fill the buffer to capacity with preexisting data.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
Serializable::SizeType getCapacity() const override
Get buffer capacity.
SerializeStatus
forward declaration for string
SerializeStatus popBytes(U8 *const addr, FwSizeType n)
Pop n bytes off the buffer.
Omit length from serialization.
SerializeStatus pushBytes(const U8 *const addr, const FwSizeType n)
Push n bytes onto the buffer.
SerialBuffer(U8 *const data, const FwSizeType capacity)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
Implementation of malloc based allocator.
#define FW_ASSERT(...)
Definition: Assert.hpp:14