F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
PathName.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title PathName.cpp
3// \author bocchino
4// \brief cpp file for FilePacket::PathName
5//
6// \copyright
7// Copyright 2009-2016, by the California Institute of Technology.
8// ALL RIGHTS RESERVED. United States Government Sponsorship
9// acknowledged.
10//
11// ======================================================================
12
13#include <cstring>
14
16#include <Fw/Types/Assert.hpp>
18
19namespace Fw {
20
21 void FilePacket::PathName ::
22 initialize(const char *const value)
23 {
24 const U8 length = static_cast<U8>(StringUtils::string_length(value, static_cast<FwSizeType>(MAX_LENGTH)));
25 this->m_length = length;
26 this->m_value = value;
27 }
28
29 U32 FilePacket::PathName ::
30 bufferSize() const
31 {
32 return static_cast<U32>(sizeof(this->m_length) + this->m_length);
33 }
34
35 SerializeStatus FilePacket::PathName ::
36 fromSerialBuffer(SerialBuffer& serialBuffer)
37 {
38
39 {
40 const SerializeStatus status =
41 serialBuffer.deserialize(this->m_length);
42
43 if (status != FW_SERIALIZE_OK) {
44 return status;
45 }
46 }
47
48 {
49 const U8* addrLeft = serialBuffer.getBuffAddrLeft();
50 U8 bytes[MAX_LENGTH];
51 const SerializeStatus status =
52 serialBuffer.popBytes(bytes, this->m_length);
53
54 if (status != FW_SERIALIZE_OK) {
55 return status;
56 }
57
58 this->m_value = reinterpret_cast<const char*>(addrLeft);
59 }
60
61 return FW_SERIALIZE_OK;
62
63 }
64
65 SerializeStatus FilePacket::PathName ::
66 toSerialBuffer(SerialBuffer& serialBuffer) const
67 {
68
69 {
70 const SerializeStatus status =
71 serialBuffer.serialize(this->m_length);
72
73 if (status != FW_SERIALIZE_OK) {
74 return status;
75 }
76 }
77
78 {
79 const SerializeStatus status = serialBuffer.pushBytes(
80 reinterpret_cast<const U8 *>(this->m_value),
81 this->m_length
82 );
83
84 if (status != FW_SERIALIZE_OK) {
85 return status;
86 }
87 }
88
89 return FW_SERIALIZE_OK;
90
91 }
92
93}
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
PlatformSizeType FwSizeType
Definition FpConfig.h:35
A variable-length serializable buffer.
SerializeStatus popBytes(U8 *const addr, NATIVE_UINT_TYPE n)
Pop n bytes off the buffer.
const U8 * getBuffAddrLeft() const
gets address of remaining non-deserialized data.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
FwSizeType string_length(const CHAR *source, FwSizeType buffer_size)
get the length of the source string
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.