18 namespace duds {
namespace hardware {
namespace interface {
53 Conversation::PartVector::const_iterator
piter;
89 c(nullptr), pos(cp.start()), remain(cp.length()) { }
156 void advance(std::size_t bytes);
178 template <
typename Int>
180 static_assert(std::is_integral<Int>::value,
181 "Only integer values can be read by this function.");
182 if (remain <
sizeof(Int)) {
186 for (std::size_t loop =
sizeof(Int); loop; --loop, ++p) {
188 i = (((
typename std::make_unsigned<Int>::type)i >> 8) |
189 (((Int)*p) << (8 * (
sizeof(Int) - 1)))
192 advance(
sizeof(Int));
207 template <
typename Int>
209 static_assert(std::is_integral<Int>::value,
210 "Only integer values can be read by this function.");
211 if (remain <
sizeof(Int)) {
215 for (std::size_t loop =
sizeof(Int); loop; --loop, ++p) {
218 advance(
sizeof(Int));
233 template <
typename Int>
239 if ((*piter)->bigEndian()) {
259 template <
typename Int>
261 static_assert(std::is_integral<Int>::value,
262 "Only integer values can be read by this function.");
263 int len = (int)
sizeof(Int) * count;
268 for (; count; --count, ++a) {
269 for (std::size_t loop =
sizeof(Int); loop; --loop, ++p) {
271 *a = ((((
typename std::make_unsigned<Int>::type)*a) >> 8) |
272 (((Int)*p) << (8 * (
sizeof(Int) - 1)))
292 template <
typename Int>
294 static_assert(std::is_integral<Int>::value,
295 "Only integer values can be read by this function.");
296 int len = (int)
sizeof(Int) * count;
301 for (; count; --count, ++a) {
302 for (std::size_t loop =
sizeof(Int); loop; --loop, ++p) {
322 template <
typename Int, std::
size_t N>
340 template <
typename Int, std::
size_t N>
358 template <
typename Int>
359 void read(Int *a, std::size_t count) {
364 if ((*piter)->bigEndian()) {
384 template <
typename Int, std::
size_t N>
390 if ((*piter)->bigEndian()) {
408 void read(
char *dest, std::size_t len);
424 template <
class Cont,
typename Iter>
425 void read(Cont &cont, Iter &start, std::size_t len) {
429 cont.insert(start, pos, pos + len);
449 template <
typename Int>
471 template <
typename Int, std::
size_t N>
An attempt was made to extract data past the end of a conversation or a conversation part...
A ConversationExtractor was asked to operate on a Conversation, but one is not set.
Represents a section of a half-duplex conversation with a device.
Base class for conversation related errors.
ConversationExtractor & operator>>(ConversationExtractor &ce, Int &i)
Extraction operator to read an integer from a Conversation through a ConversationExtractor object...
virtual std::size_t length() const =0
Returns the length of the buffer following the start pointer.
virtual char * start() const =0
Returns a pointer to the begining of the conversation part's buffer.
Header for Conversarion; includes ConversationVector.hpp and ConversationExternal.hpp.
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
Represents a two-way conversation with a device.