2021-07-26 21:15:20 -04:00
|
|
|
/*
|
|
|
|
pdu-stream.cpp
|
|
|
|
|
|
|
|
Copyright (c) 2020 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include "pdu-stream.h"
|
|
|
|
|
|
|
|
namespace ACN {
|
|
|
|
namespace PDU {
|
|
|
|
|
2021-07-26 22:48:01 -04:00
|
|
|
/**
|
|
|
|
* @brief pdu_stream::pdu_stream
|
|
|
|
* @param p the packet buffer
|
|
|
|
* @param l buffer length
|
|
|
|
*/
|
|
|
|
pdu_stream::pdu_stream(uint8_t * p, std::streamsize l)
|
|
|
|
: std::basic_streambuf<uint8_t>()
|
|
|
|
, std::basic_iostream<uint8_t>(this)
|
|
|
|
{
|
|
|
|
setg(p, p, p + l);
|
|
|
|
setp(p, p + l);
|
|
|
|
}
|
|
|
|
|
2021-07-26 21:15:20 -04:00
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator >>
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator>> (uint8_t& val)
|
|
|
|
{
|
|
|
|
val = readType<uint8_t>();
|
|
|
|
return *this;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator >>
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator>> (uint16_t& val)
|
|
|
|
{
|
|
|
|
val = readType<uint16_t>();
|
|
|
|
return *this;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator >>
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator>> (uint32_t& val)
|
|
|
|
{
|
|
|
|
val = readType<uint32_t>();
|
|
|
|
return *this;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator >>
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator>> (uint64_t& val)
|
|
|
|
{
|
|
|
|
val = readType<uint64_t>();
|
|
|
|
return *this;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator <<
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator<< (const uint8_t& val)
|
|
|
|
{
|
|
|
|
writeType<uint8_t>(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator <<
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator<< (const uint16_t& val)
|
|
|
|
{
|
|
|
|
writeType<uint16_t>(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator <<
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator<< (const uint32_t& val)
|
|
|
|
{
|
|
|
|
writeType<uint32_t>(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief pdu_stream::operator <<
|
|
|
|
* @param val
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
pdu_stream& pdu_stream::operator<< (const uint64_t& val)
|
|
|
|
{
|
|
|
|
writeType<uint64_t>(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // PDU
|
|
|
|
} // ACN
|