22 #ifndef INCLUDE_OLA_IO_BIGENDIANSTREAM_H_ 23 #define INCLUDE_OLA_IO_BIGENDIANSTREAM_H_ 26 #include <ola/io/InputStream.h> 27 #include <ola/io/OutputStream.h> 28 #include <ola/network/NetworkUtils.h> 50 bool operator>>(int8_t &val) {
return ExtractAndConvert(&val); }
51 bool operator>>(uint8_t &val) {
return ExtractAndConvert(&val); }
52 bool operator>>(int16_t &val) {
return ExtractAndConvert(&val); }
53 bool operator>>(uint16_t &val) {
return ExtractAndConvert(&val); }
54 bool operator>>(int32_t &val) {
return ExtractAndConvert(&val); }
55 bool operator>>(uint32_t &val) {
return ExtractAndConvert(&val); }
57 unsigned int ReadString(std::string *output,
unsigned int size) {
58 return m_stream->ReadString(output, size);
65 bool ExtractAndConvert(T *val) {
66 bool ok = (*m_stream) >> *val;
82 : m_input_stream(buffer),
83 m_adaptor(&m_input_stream) {
87 bool operator>>(int8_t &val) {
return m_adaptor >> val; }
88 bool operator>>(uint8_t &val) {
return m_adaptor >> val; }
89 bool operator>>(int16_t &val) {
return m_adaptor >> val; }
90 bool operator>>(uint16_t &val) {
return m_adaptor >> val; }
91 bool operator>>(int32_t &val) {
return m_adaptor >> val; }
92 bool operator>>(uint32_t &val) {
return m_adaptor >> val; }
94 unsigned int ReadString(std::string *output,
unsigned int size) {
95 return m_adaptor.ReadString(output, size);
122 void Write(
const uint8_t *data,
unsigned int length) {
123 m_stream->Write(data, length);
127 return ConvertAndWrite(val);
131 return ConvertAndWrite(val);
135 return ConvertAndWrite(val);
139 return ConvertAndWrite(val);
143 return ConvertAndWrite(val);
147 return ConvertAndWrite(val);
153 template <
typename T>
170 : m_output_stream(buffer),
171 m_adaptor(&m_output_stream) {
175 void Write(
const uint8_t *data,
unsigned int length) {
176 m_adaptor.Write(data, length);
190 template <
typename T>
200 #endif // INCLUDE_OLA_IO_BIGENDIANSTREAM_H_ Definition: OutputStream.h:35
uint16_t HostToNetwork(uint16_t value)
16-bit unsigned host to network conversion.
Definition: NetworkUtils.cpp:159
Definition: BigEndianStream.h:166
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
Definition: OutputBuffer.h:36
uint16_t NetworkToHost(uint16_t value)
16-bit unsigned network to host conversion.
Definition: NetworkUtils.cpp:143
Definition: BigEndianStream.h:114
std::ostream & operator<<(std::ostream &out, const DmxBuffer &data)
Stream operator to allow DmxBuffer to be output to stdout.
Definition: DmxBuffer.cpp:402
Definition: OutputStream.h:54
Definition: BigEndianStream.h:107
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44