Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
apps/elftosb/common/Blob.h
1 /*
2  * File: Blob.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 #if !defined(_Blob_h_)
8 #define _Blob_h_
9 
10 #include "stdafx.h"
11 
18 class Blob
19 {
20 public:
22  Blob();
23 
25  Blob(const uint8_t *data, unsigned length);
26 
28  Blob(const Blob &other);
29 
31  virtual ~Blob();
32 
34 
35  void setData(const uint8_t *data, unsigned length);
37 
39  void setLength(unsigned length);
40 
42  void append(const uint8_t *newData, unsigned newDataLength);
43 
45  void clear();
46 
48  void relinquish();
50 
52 
53  uint8_t *getData() { return m_data; }
54  const uint8_t *getData() const { return m_data; }
55  unsigned getLength() const { return m_length; }
57 
59 
60  operator uint8_t *() { return m_data; }
61  operator const uint8_t *() const { return m_data; }
63 
64 protected:
65  uint8_t *m_data;
66  unsigned m_length;
67 };
68 
69 #endif // _Blob_h_
Blob()
Default constructor.
Definition: apps/elftosb/common/Blob.cpp:13
unsigned m_length
Number of bytes pointed to by m_data.
Definition: apps/elftosb/common/Blob.h:66
uint8_t * m_data
The binary data held by this object.
Definition: apps/elftosb/common/Blob.h:65
virtual ~Blob()
Destructor.
Definition: apps/elftosb/common/Blob.cpp:40
void setData(const uint8_t *data, unsigned length)
Replaces the blob's data.
Definition: apps/elftosb/common/Blob.cpp:54
void relinquish()
Tell the blob that it no longer owns its data.
Definition: apps/elftosb/common/Blob.cpp:118
void setLength(unsigned length)
Change the size of the blob's data.
Definition: apps/elftosb/common/Blob.cpp:66
void append(const uint8_t *newData, unsigned newDataLength)
Adds data to the end of the blob.
Definition: apps/elftosb/common/Blob.cpp:98
void clear()
Disposes of the data.
Definition: apps/elftosb/common/Blob.cpp:107
Manages a binary object of arbitrary length.
Definition: apps/elftosb/common/Blob.h:18