fprime/Fw/Types/SerialBuffer.cpp
M Starch ec08d43dd3
Removes NATIVE_INT_TYPE, NATIVE_UINT_TYPE, and POINTER_CAST from Fw (#3286)
* NATIVE_INT_TYPE use in toString

* NATIVE_INT_TYPE use in SimpleObjRegistry

* NATIVE_INT_TYPE use in Asserts

* NATIVE_INT_TYPE use in Fw/Comp

* NATIVE_INT_TYPE use in getCapacity

* NATIVE_INT_TYPE use in getEntries

* NATIVE_INT_TYPE use in size/length

* NATIVE_INT_TYPE use in FILE_NAME_ARG

* NATIVE_INT_TYPE use in Fw (misc)

* NATIVE_INT_TYPE use in identifier

* NATIVE_INT_TYPE use in Fw (misc II)

* POINTER_CAST in Buffer

* POINTER_CAST in Serializable

* sp

* Removing no longer used DefaultTypes.hpp

* Fixes to accomidate Fw refactor

* Unit-test and CI fixes

* Fixing review comments - pt 1
2025-03-04 14:42:48 -08:00

48 lines
1.3 KiB
C++

// ======================================================================
// \title SerialBuffer.cpp
// \author bocchino
// \brief cpp file for SerialBuffer type
//
// \copyright
// Copyright (C) 2016 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/SerialBuffer.hpp"
namespace Fw {
SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {}
FwSizeType SerialBuffer ::getBuffCapacity() const {
return m_capacity;
}
U8* SerialBuffer ::getBuffAddr() {
return m_data;
}
const U8* SerialBuffer ::getBuffAddr() const {
return m_data;
}
void SerialBuffer ::fill() {
const SerializeStatus status = this->setBuffLen(this->m_capacity);
FW_ASSERT(status == FW_SERIALIZE_OK);
}
SerializeStatus SerialBuffer ::pushBytes(const U8* const addr, const FwSizeType n) {
// "true" means "just push the bytes"
return this->serialize(const_cast<U8*>(addr), n, true);
}
SerializeStatus SerialBuffer ::popBytes(U8* const addr, FwSizeType n) {
// "true" means "just pop the bytes"
return this->deserialize(addr, n, true);
}
} // namespace Fw