-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathPathName.cpp
More file actions
76 lines (59 loc) · 2.04 KB
/
PathName.cpp
File metadata and controls
76 lines (59 loc) · 2.04 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ======================================================================
// \title PathName.cpp
// \author bocchino
// \brief cpp file for FilePacket::PathName
//
// \copyright
// Copyright 2009-2016, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#include <cstring>
#include <Fw/FilePacket/FilePacket.hpp>
#include <Fw/Types/Assert.hpp>
#include <Fw/Types/StringUtils.hpp>
namespace Fw {
void FilePacket::PathName ::initialize(const char* const value) {
const U8 length = static_cast<U8>(StringUtils::string_length(value, static_cast<FwSizeType>(MAX_LENGTH)));
this->m_length = length;
this->m_value = value;
}
U32 FilePacket::PathName ::bufferSize() const {
return static_cast<U32>(sizeof(this->m_length) + this->m_length);
}
SerializeStatus FilePacket::PathName ::fromSerialBuffer(SerialBuffer& serialBuffer) {
{
const SerializeStatus status = serialBuffer.deserializeTo(this->m_length);
if (status != FW_SERIALIZE_OK) {
return status;
}
}
{
const U8* addrLeft = serialBuffer.getBuffAddrLeft();
U8 bytes[MAX_LENGTH];
const SerializeStatus status = serialBuffer.popBytes(bytes, MAX_LENGTH, this->m_length);
if (status != FW_SERIALIZE_OK) {
return status;
}
this->m_value = reinterpret_cast<const char*>(addrLeft);
}
return FW_SERIALIZE_OK;
}
SerializeStatus FilePacket::PathName ::toSerialBuffer(SerialBuffer& serialBuffer) const {
{
const SerializeStatus status = serialBuffer.serializeFrom(this->m_length);
if (status != FW_SERIALIZE_OK) {
return status;
}
}
{
const SerializeStatus status =
serialBuffer.pushBytes(reinterpret_cast<const U8*>(this->m_value), this->m_length);
if (status != FW_SERIALIZE_OK) {
return status;
}
}
return FW_SERIALIZE_OK;
}
} // namespace Fw