-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamSerialization.cpp
More file actions
36 lines (26 loc) · 1.04 KB
/
StreamSerialization.cpp
File metadata and controls
36 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*******************************************************************************
* Rohan data serialization library.
* Serialization to unix++ streams
*
* © 2020—2024, Sauron
******************************************************************************/
#include "StreamSerialization.hpp"
using namespace rohan;
using upp::Stream;
StreamSerializer::StreamSerializer(Stream &stream) : stream(stream) {}
/******************************************************************************/
StreamReader::StreamReader(Stream &stream) : StreamSerializer(stream) {}
size_t StreamReader::read(void * to, size_t length) {
return stream.read(to, length);
}
size_t StreamReader::skip(size_t length) {
(void)length;
throw "not implemented";
}
/******************************************************************************/
StreamWriter::StreamWriter(Stream &stream) : StreamSerializer(stream) {}
void StreamWriter::write(const void * from, size_t length) {
size_t n=stream.write(from, length);
if (n!=length)
throw End();
}