| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 15 | #include <Fw/FilePacket/FilePacket.hpp> | ||
| 16 | #include <Fw/Types/Assert.hpp> | ||
| 17 | #include <Fw/Types/StringUtils.hpp> | ||
| 18 | |||
| 19 | namespace Fw { | ||
| 20 | |||
| 21 | 2 | void FilePacket::PathName ::initialize(const char* const value) { | |
| 22 | 2 | const U8 length = static_cast<U8>(StringUtils::string_length(value, static_cast<FwSizeType>(MAX_LENGTH))); | |
| 23 | 2 | this->m_length = length; | |
| 24 | 2 | this->m_value = value; | |
| 25 | 2 | } | |
| 26 | |||
| 27 | 2 | U32 FilePacket::PathName ::bufferSize() const { | |
| 28 | 2 | return static_cast<U32>(sizeof(this->m_length) + this->m_length); | |
| 29 | } | ||
| 30 | |||
| 31 | 2 | SerializeStatus FilePacket::PathName ::fromSerialBuffer(SerialBuffer& serialBuffer) { | |
| 32 | { | ||
| 33 | 2 | const SerializeStatus status = serialBuffer.deserializeTo(this->m_length); | |
| 34 | |||
| 35 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (status != FW_SERIALIZE_OK) { |
| 36 | ✗ | return status; | |
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | { | ||
| 41 |
1/1✓ Branch 5 taken 2 times.
|
2 | const U8* addrLeft = serialBuffer.getBuffAddrLeft(); |
| 42 | 2 | U8 bytes[MAX_LENGTH]; | |
| 43 |
1/1✓ Branch 5 taken 2 times.
|
2 | const SerializeStatus status = serialBuffer.popBytes(bytes, this->m_length); |
| 44 | |||
| 45 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (status != FW_SERIALIZE_OK) { |
| 46 | ✗ | return status; | |
| 47 | } | ||
| 48 | |||
| 49 | 2 | this->m_value = reinterpret_cast<const char*>(addrLeft); | |
| 50 | } | ||
| 51 | |||
| 52 | 2 | return FW_SERIALIZE_OK; | |
| 53 | } | ||
| 54 | |||
| 55 | 2 | SerializeStatus FilePacket::PathName ::toSerialBuffer(SerialBuffer& serialBuffer) const { | |
| 56 | { | ||
| 57 | 2 | const SerializeStatus status = serialBuffer.serializeFrom(this->m_length); | |
| 58 | |||
| 59 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (status != FW_SERIALIZE_OK) { |
| 60 | ✗ | return status; | |
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | { | ||
| 65 | const SerializeStatus status = | ||
| 66 | 2 | serialBuffer.pushBytes(reinterpret_cast<const U8*>(this->m_value), this->m_length); | |
| 67 | |||
| 68 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (status != FW_SERIALIZE_OK) { |
| 69 | ✗ | return status; | |
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | 2 | return FW_SERIALIZE_OK; | |
| 74 | } | ||
| 75 | |||
| 76 | } // namespace Fw | ||
| 77 |