diff --git a/lib/bufferstream/bufferstream.cpp b/lib/bufferstream/bufferstream.cpp index 9764936..00af4e9 100644 --- a/lib/bufferstream/bufferstream.cpp +++ b/lib/bufferstream/bufferstream.cpp @@ -30,7 +30,7 @@ * @param l * @param o */ -bufferstream::bufferstream(uint8_t * p, std::streamsize l, byteorder o) +bufferstream::bufferstream(uint8_t * p, std::streamsize l, endian o) : std::basic_streambuf() , std::basic_iostream(this) , order_(o) diff --git a/lib/bufferstream/bufferstream.h b/lib/bufferstream/bufferstream.h index 5c94a24..958af43 100644 --- a/lib/bufferstream/bufferstream.h +++ b/lib/bufferstream/bufferstream.h @@ -31,6 +31,8 @@ struct streamable; /** * @brief Input/Output stream for unsigned 8-bit buffers + * + * By default, wide types will be handled as big-endian, the network byte order. */ class bufferstream : public std::enable_shared_from_this @@ -38,13 +40,22 @@ class bufferstream , public std::basic_iostream { public: - /// @brief The byteorder enum - enum byteorder { - LittleEndian, //!< Little Endian - BigEndian, //!< Big Endian, Network Order + /** + * @brief The endian enum is not available until C++20. + * + * \note This implimentation may be compiler dependant. + * + * \note After upgrading the project to C++20 or better, drop this if favor of + * the standard implimentation in + */ + enum class endian + { + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__, }; - bufferstream(uint8_t *p, std::streamsize l, byteorder o = BigEndian); + bufferstream(uint8_t *p, std::streamsize l, endian o = endian::big); // default network byte-order // input sequence size_t available(); @@ -155,7 +166,7 @@ public: } private: - byteorder order_; + endian order_; }; diff --git a/platform/qt/dmxwidget/dmxwidget.cpp b/platform/qt/dmxwidget/dmxwidget.cpp index 6f08bc3..29074ef 100644 --- a/platform/qt/dmxwidget/dmxwidget.cpp +++ b/platform/qt/dmxwidget/dmxwidget.cpp @@ -126,7 +126,7 @@ void DmxWidget::parseMessageBuffer() // fill it with data std::shared_ptr stream(new bufferstream( reinterpret_cast(message_rx_buffer_.data()+fixed_length-1), - length, bufferstream::LittleEndian)); + length, bufferstream::endian::little)); msg->iStream(stream); // ship it routeRxMessage(msg); @@ -144,7 +144,7 @@ void DmxWidget::sendMessage(std::shared_ptr msg) const char buffer[length + fixed_length]; std::shared_ptr stream(new bufferstream(reinterpret_cast(buffer), sizeof(buffer), - bufferstream::LittleEndian)); + bufferstream::endian::little)); *stream << ENTTEC::Pro::START_DELIMITER; *stream << msg->label; *stream << length;