![]() |
THM1176InstrumentManager
1.0
Qt Object abstraction for Metrolab THM1176
|
Instrument Buffer. More...
#include <SCPIInstrumentBuffer.h>
Public Member Functions | |
CSCPIBuffer (size_t InitialCapacity=2048) | |
Constructor: new empty buffer. More... | |
CSCPIBuffer (const MTL_INSTRUMENT_BUFFER_TYPE *pData, size_t DataLen) | |
Constructor: initialize with data provided. More... | |
virtual | ~CSCPIBuffer () |
Destructor. More... | |
void | clear () |
Clear by setting the buffer size to zero. More... | |
void | reserve (size_t capacity) |
Allocate at least a given amount of space. More... | |
void | resize (size_t size) |
Resize the buffer. More... | |
size_t | size () const |
Return the buffer size. More... | |
size_t | capacity () const |
Return the buffer capacity (allocated size). More... | |
std::vector< MTL_INSTRUMENT_BUFFER_TYPE >::iterator | begin () |
Return an iterator to the beginning of the buffer. More... | |
std::vector< MTL_INSTRUMENT_BUFFER_TYPE >::const_iterator | begin () const |
Return a const iterator to the beginning of the buffer. More... | |
std::vector< MTL_INSTRUMENT_BUFFER_TYPE >::iterator | end () |
Return an iterator to the end of the buffer. More... | |
std::vector< MTL_INSTRUMENT_BUFFER_TYPE >::const_iterator | end () const |
Return a const iterator to the end of the buffer. More... | |
MTL_INSTRUMENT_BUFFER_TYPE * | data () noexcept |
Return a pointer to the data. More... | |
const MTL_INSTRUMENT_BUFFER_TYPE * | data () const noexcept |
Return a const pointer to the data. More... | |
MTL_INSTRUMENT_BUFFER_TYPE & | operator[] (size_t n) |
Return byte n of the buffer. More... | |
const MTL_INSTRUMENT_BUFFER_TYPE & | operator[] (size_t n) const |
Return byte n of the buffer as const. More... | |
void | assign (const MTL_INSTRUMENT_BUFFER_TYPE *First, const MTL_INSTRUMENT_BUFFER_TYPE *Last) |
Copy the given data into the buffer: variant with begin/end. More... | |
void | assign (const MTL_INSTRUMENT_BUFFER_TYPE *pData, size_t n) |
Copy the given data into the buffer: variant with pointer/size. More... | |
Instrument Buffer.
This class is intended to provide an efficient way of reading data and parsing a SCPI response. Read operations require an allocated buffer pointer and its length. Parsing methods (regex, find etc...) require std::string object or iterators.
This class holds data in a std::vector. Storage is thus allocated in contiguous memory and memory allocation/deallocation is automatically handled. A size member is managed by this class itself and can be set by a method. We must ensure that this class size is always less than or equal to the contained vector size (the class capacity is equivalent to the contained vector size).
Definition at line 43 of file SCPIInstrumentBuffer.h.
|
inline |
Constructor: new empty buffer.
[in] | InitialCapacity | Initial buffer size, in bytes. |
Definition at line 52 of file SCPIInstrumentBuffer.h.
|
inline |
Constructor: initialize with data provided.
[in] | pData | Data buffer location. |
[in] | DataLen | Data buffer size, in bytes. |
Definition at line 63 of file SCPIInstrumentBuffer.h.
|
inlinevirtual |
Destructor.
Definition at line 70 of file SCPIInstrumentBuffer.h.
|
inline |
Copy the given data into the buffer: variant with begin/end.
[in] | First | Pointer to first byte of data. |
[in] | Last | Pointer to first byte past the data. |
Definition at line 188 of file SCPIInstrumentBuffer.h.
|
inline |
Copy the given data into the buffer: variant with pointer/size.
[in] | pData | Pointer to first byte of data. |
[in] | n | Number of bytes. |
Definition at line 201 of file SCPIInstrumentBuffer.h.
|
inline |
Return an iterator to the beginning of the buffer.
Definition at line 122 of file SCPIInstrumentBuffer.h.
|
inline |
Return a const iterator to the beginning of the buffer.
Definition at line 130 of file SCPIInstrumentBuffer.h.
|
inline |
Return the buffer capacity (allocated size).
Definition at line 114 of file SCPIInstrumentBuffer.h.
|
inline |
Clear by setting the buffer size to zero.
Definition at line 74 of file SCPIInstrumentBuffer.h.
|
inlinenoexcept |
Return a const pointer to the data.
Definition at line 162 of file SCPIInstrumentBuffer.h.
|
inlinenoexcept |
Return a pointer to the data.
Definition at line 154 of file SCPIInstrumentBuffer.h.
|
inline |
Return an iterator to the end of the buffer.
Definition at line 138 of file SCPIInstrumentBuffer.h.
|
inline |
Return a const iterator to the end of the buffer.
Definition at line 146 of file SCPIInstrumentBuffer.h.
|
inline |
Return byte n of the buffer.
Definition at line 170 of file SCPIInstrumentBuffer.h.
|
inline |
Return byte n of the buffer as const.
Definition at line 178 of file SCPIInstrumentBuffer.h.
|
inline |
Allocate at least a given amount of space.
[in] | capacity | Desired capacity. |
Definition at line 83 of file SCPIInstrumentBuffer.h.
|
inline |
Resize the buffer.
[in] | size | New buffer size. |
Definition at line 93 of file SCPIInstrumentBuffer.h.
|
inline |
Return the buffer size.
Definition at line 106 of file SCPIInstrumentBuffer.h.