fsfw/src/fsfw/cfdp/tlv/Lv.h

63 lines
1.5 KiB
C
Raw Normal View History

2022-08-10 09:39:57 +02:00
#ifndef FSFW_CFDP_LV_H_
#define FSFW_CFDP_LV_H_
#include <vector>
#include "fsfw/serialize/SerialBufferAdapter.h"
namespace cfdp {
/**
* @brief Length-Value field implementation
* @details
* Thin abstraction layer around a serial buffer adapter
*/
2022-02-02 10:29:30 +01:00
class Lv : public SerializeIF {
public:
2022-08-10 09:39:57 +02:00
explicit Lv(const std::vector<uint8_t>& data);
2022-02-02 10:29:30 +01:00
Lv(const uint8_t* value, size_t size);
Lv();
2023-07-27 14:55:46 +02:00
// Semantically, this class is a zero-copy helper, so the copy ctor and copy assigment do not
// really make sense here.
Lv(const Lv&) = delete;
Lv& operator=(const Lv&) = delete;
Lv(Lv&&) noexcept;
Lv& operator=(Lv&&) noexcept;
2022-02-02 10:29:30 +01:00
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
2022-08-08 18:29:32 +02:00
[[nodiscard]] size_t getSerializedSize() const override;
2022-02-02 10:29:30 +01:00
/**
* @brief Deserialize a LV field from a raw buffer
* @param buffer Raw buffer including the size field
* @param size
* @param streamEndianness
* @return
*/
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
2023-07-27 17:15:01 +02:00
size_t getValueLen() const;
2022-02-02 10:29:30 +01:00
/**
* Get value field and its size.
* @param size Optionally retrieve size. Size will be the size of the actual value field
* without the length field of the LV
* @return
*/
const uint8_t* getValue(size_t* size) const;
2023-08-30 11:34:38 +02:00
bool isEmpty() const;
2022-02-02 10:29:30 +01:00
private:
bool zeroLen = true;
SerialBufferAdapter<uint8_t> value;
};
2022-02-02 10:29:30 +01:00
} // namespace cfdp
2022-08-10 09:39:57 +02:00
#endif /* FSFW_CFDP_LV_H_ */