FastLED 3.10.6
Loading...
Searching...
No Matches
fled_impl.hpp
Go to the documentation of this file.
1#pragma once
2
3// Internal PIMPL for fl::Fled. Owns either a heap-backed byte buffer
4// (load + loadFromVector) or borrows a static span (loadFromStatic).
5// Lives in fl::fled per the subsystem namespace rule (#3311).
6
7#include "fl/stl/int.h"
8#include "fl/stl/json.h"
9#include "fl/stl/move.h"
10#include "fl/stl/noexcept.h"
11#include "fl/stl/span.h"
12#include "fl/stl/vector.h"
13
14namespace fl {
15namespace fled {
16
17class FledImpl {
18 public:
20
21 // Owned: takes ownership of an already-loaded byte vector.
33
34 // Static: borrows the caller's span (no copy, no free).
46
47 const fl::u8 *bytes() const FL_NO_EXCEPT {
48 return mOwnership == kOwned ? mOwned.data() : mStaticPtr;
49 }
50 fl::size totalLen() const FL_NO_EXCEPT {
51 return mOwnership == kOwned ? mOwned.size() : mStaticLen;
52 }
55 fl::size payloadOffset() const FL_NO_EXCEPT { return mPayloadOffset; }
56 fl::size payloadLen() const FL_NO_EXCEPT {
57 const fl::size total = totalLen();
58 return total > mPayloadOffset ? total - mPayloadOffset : 0;
59 }
60 const fl::json &envelope() const FL_NO_EXCEPT { return mJson; }
61
62 private:
65 fl::size mStaticLen;
71};
72
73} // namespace fled
74} // namespace fl
fl::size mPayloadOffset
Definition fled_impl.hpp:69
fl::vector< fl::u8 > mOwned
Definition fled_impl.hpp:63
fl::u8 versionByte() const FL_NO_EXCEPT
Definition fled_impl.hpp:53
FledImpl(fl::vector< fl::u8 > &&owned, fl::u8 versionByte, fl::u8 pixelFormatByte, fl::size payloadOffset, fl::json envelope) FL_NO_EXCEPT
Definition fled_impl.hpp:22
const fl::u8 * mStaticPtr
Definition fled_impl.hpp:64
FledImpl(fl::span< const fl::u8 > staticBytes, fl::u8 versionByte, fl::u8 pixelFormatByte, fl::size payloadOffset, fl::json envelope) FL_NO_EXCEPT
Definition fled_impl.hpp:35
fl::size payloadOffset() const FL_NO_EXCEPT
Definition fled_impl.hpp:55
Ownership mOwnership
Definition fled_impl.hpp:66
const fl::u8 * bytes() const FL_NO_EXCEPT
Definition fled_impl.hpp:47
fl::size totalLen() const FL_NO_EXCEPT
Definition fled_impl.hpp:50
fl::u8 pixelFormatByte() const FL_NO_EXCEPT
Definition fled_impl.hpp:54
fl::size payloadLen() const FL_NO_EXCEPT
Definition fled_impl.hpp:56
const fl::json & envelope() const FL_NO_EXCEPT
Definition fled_impl.hpp:60
FastLED's Elegant JSON Library: fl::json
unsigned char u8
Definition stdint.h:131
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition move.h:28
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
Base definition for an LED controller.
Definition crgb.hpp:179