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.
|
|
|
|
*/
|
2021-08-20 10:13:00 -04:00
|
|
|
|
2023-04-02 13:24:55 -04:00
|
|
|
#include "pdu-stream.h"
|
2021-08-20 10:13:00 -04:00
|
|
|
|
|
|
|
|
2021-08-16 21:20:19 -04:00
|
|
|
/**
|
2023-05-18 14:42:06 -04:00
|
|
|
* @brief operator >>
|
|
|
|
* @param buffer
|
2021-08-16 21:20:19 -04:00
|
|
|
* @param uuid
|
|
|
|
* @return
|
|
|
|
*/
|
2023-05-18 14:42:06 -04:00
|
|
|
bufferstream &operator>> (bufferstream &buffer, UUID::uuid &uuid)
|
2021-08-16 21:20:19 -04:00
|
|
|
{
|
2023-05-18 14:42:06 -04:00
|
|
|
uint8_t data[UUID_LENGTH];
|
|
|
|
buffer.read(data, UUID_LENGTH);
|
|
|
|
if (buffer.gcount() == UUID_LENGTH)
|
|
|
|
uuid.setBytes(data);
|
|
|
|
else
|
|
|
|
buffer.setstate(std::ios_base::badbit);
|
|
|
|
return buffer;
|
2021-08-16 21:20:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-08-20 09:58:59 -04:00
|
|
|
/**
|
2023-05-18 14:42:06 -04:00
|
|
|
* @brief operator <<
|
|
|
|
* @param buffer
|
2021-08-16 21:20:19 -04:00
|
|
|
* @param uuid
|
|
|
|
* @return
|
|
|
|
*/
|
2023-05-18 14:42:06 -04:00
|
|
|
bufferstream &operator<< (bufferstream &buffer, const UUID::uuid &uuid)
|
2021-08-16 21:20:19 -04:00
|
|
|
{
|
2023-05-18 14:42:06 -04:00
|
|
|
buffer.write(uuid.bytes(), UUID_LENGTH);
|
|
|
|
return buffer;
|
2021-08-16 21:20:19 -04:00
|
|
|
}
|