22 #ifndef INCLUDE_OLA_IO_BIGENDIANSTREAM_H_
23 #define INCLUDE_OLA_IO_BIGENDIANSTREAM_H_
25 #include <ola/io/InputStream.h>
26 #include <ola/io/OutputStream.h>
27 #include <ola/network/NetworkUtils.h>
49 bool operator>>(int8_t &val) {
return ExtractAndConvert(&val); }
50 bool operator>>(uint8_t &val) {
return ExtractAndConvert(&val); }
51 bool operator>>(int16_t &val) {
return ExtractAndConvert(&val); }
52 bool operator>>(uint16_t &val) {
return ExtractAndConvert(&val); }
53 bool operator>>(int32_t &val) {
return ExtractAndConvert(&val); }
54 bool operator>>(uint32_t &val) {
return ExtractAndConvert(&val); }
56 unsigned int ReadString(std::string *output,
unsigned int size) {
57 return m_stream->ReadString(output, size);
64 bool ExtractAndConvert(T *val) {
65 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);
123 void Write(
const uint8_t *data,
unsigned int length) {
124 m_stream->Write(data, length);
128 return ConvertAndWrite(val);
132 return ConvertAndWrite(val);
136 return ConvertAndWrite(val);
140 return ConvertAndWrite(val);
144 return ConvertAndWrite(val);
148 return ConvertAndWrite(val);
154 template <
typename T>
173 : m_output_stream(buffer),
174 m_adaptor(&m_output_stream) {
178 void Write(
const uint8_t *data,
unsigned int length) {
179 m_adaptor.Write(data, length);
193 template <
typename T>
204 #endif // INCLUDE_OLA_IO_BIGENDIANSTREAM_H_
Definition: OutputStream.h:34
uint16_t HostToNetwork(uint16_t value)
16-bit unsigned host to network conversion.
Definition: NetworkUtils.cpp:155
Definition: BigEndianStream.h:169
Definition: OutputBuffer.h:36
uint16_t NetworkToHost(uint16_t value)
16-bit unsigned network to host conversion.
Definition: NetworkUtils.cpp:139
Definition: BigEndianStream.h:115
Definition: OutputStream.h:53
Definition: BigEndianStream.h:108
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44