-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathSerialBuffer.cpp
More file actions
49 lines (38 loc) · 1.38 KB
/
SerialBuffer.cpp
File metadata and controls
49 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// ======================================================================
// \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/SerialBuffer.hpp"
#include "Fw/Types/Assert.hpp"
namespace Fw {
SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {}
FwSizeType SerialBuffer ::getCapacity() const {
return m_capacity;
}
FwSizeType SerialBuffer ::getBuffCapacity() const {
return this->getCapacity();
}
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) {
return this->serializeFrom(const_cast<U8*>(addr), n, Fw::Serialization::OMIT_LENGTH);
}
SerializeStatus SerialBuffer ::popBytes(U8* const addr, FwSizeType buffCapacity, FwSizeType n) {
return this->deserializeTo(addr, buffCapacity, n, Fw::Serialization::OMIT_LENGTH);
}
} // namespace Fw