@addtogroup BLOBs @{
| 22 | /// @addtogroup BLOBs |
| 23 | /// @{ |
| 24 | class TBlob { |
| 25 | public: |
| 26 | class TBase { |
| 27 | public: |
| 28 | inline TBase() noexcept = default; |
| 29 | virtual ~TBase() = default; |
| 30 | |
| 31 | virtual void Ref() noexcept = 0; |
| 32 | virtual void UnRef() noexcept = 0; |
| 33 | }; |
| 34 | |
| 35 | private: |
| 36 | struct TStorage { |
| 37 | const void* Data; |
| 38 | size_t Length; |
| 39 | TBase* Base; |
| 40 | |
| 41 | inline TStorage(const void* data, size_t length, TBase* base) noexcept |
| 42 | : Data(data) |
| 43 | , Length(length) |
| 44 | , Base(base) |
| 45 | { |
| 46 | } |
| 47 | |
| 48 | inline ~TStorage() = default; |
| 49 | |
| 50 | inline void Swap(TStorage& r) noexcept { |
| 51 | DoSwap(Data, r.Data); |
| 52 | DoSwap(Length, r.Length); |
| 53 | DoSwap(Base, r.Base); |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | public: |
| 58 | using value_type = ui8; |
| 59 | using const_reference = const value_type&; |
| 60 | using const_pointer = const value_type*; |
| 61 | using const_iterator = const_pointer; |
| 62 | |
| 63 | /** |
| 64 | * Constructs a null blob (data array points to nullptr). |
| 65 | */ |
| 66 | TBlob() noexcept |
| 67 | : S_(nullptr, 0, nullptr) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | inline TBlob(const TBlob& r) noexcept |
| 72 | : S_(r.S_) |
| 73 | { |
| 74 | Ref(); |
| 75 | } |
| 76 | |
| 77 | TBlob(TBlob&& r) noexcept |
| 78 | : TBlob() |
| 79 | { |
| 80 | this->Swap(r); |
| 81 | } |