rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
block_data.hpp
Go to the documentation of this file.
1 
7 #ifndef ROHDESCHWARZ_SCPI_BLOCK_DATA_HPP
8 #define ROHDESCHWARZ_SCPI_BLOCK_DATA_HPP
9 
10 
11 // std lib
12 #include <cstddef>
13 #include <vector>
14 
15 
17 {
18 
19 
23 class BlockData
24 {
25 
26 public:
27 
28  // life cycle
29 
33  BlockData();
34 
35 
43  BlockData(std::vector<unsigned char> data);
44 
45 
46  // header
47 
55  bool isHeaderError() const;
56 
57 
61  bool isHeader() const;
62 
63 
67  bool isComplete() const;
68 
69 
70  // push back
71 
75  void push_back(std::vector<unsigned char>::const_iterator begin, std::size_t size);
76 
77 
78  // payload data
79 
87  std::size_t size() const;
88 
89 
97  unsigned char* data();
98 
99 
100 private:
101 
102  // header members
103  bool _isHeader;
104  std::size_t _headerSize_B;
105  std::size_t _payloadSize_B;
106  std::size_t _blockSize_B;
107 
108 
109  // data
110  std::vector<unsigned char> _data;
111 
112 
113  // helpers
114 
115 
116  // header
117 
124  std::size_t parseNumberOfSizeDigits() const;
125 
126 
132  std::size_t parsePayloadSize_B() const;
133 
134 
140  std::size_t parseBlockSize_B() const;
141 
142 
148  void processHeader();
149 
150 
151  // payload
152 
158  std::size_t bytesRemaining() const;
159 
160 
161 }; // BlockData
162 
163 
164 } // rohdeschwarz::scpi
165 #endif // ROHDESCHWARZ_SCPI_BLOCK_DATA_HPP
Object-oriented Block Data storage and manipulation.
Definition: block_data.hpp:24
bool isHeaderError() const
Checks the header for errors.
Definition: block_data.cpp:38
bool isComplete() const
Checks for complete Block Data header and payload.
Definition: block_data.cpp:99
BlockData()
Default Constructor.
Definition: block_data.cpp:17
std::size_t size() const
Gets payload size, in bytes, from a complete header.
Definition: block_data.cpp:136
unsigned char * data()
Gets a pointer to the payload data.
Definition: block_data.cpp:142
bool isHeader() const
Checks for a valid and complete Block Data header.
Definition: block_data.cpp:93
void push_back(std::vector< unsigned char >::const_iterator begin, std::size_t size)
Copies data to block.
Definition: block_data.cpp:109