MCPcopy Create free account
hub / github.com/ElementsProject/elements / OverrideStream

Class OverrideStream

src/streams.h:27–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template<typename Stream>
27class OverrideStream
28{
29 Stream* stream;
30
31 const int nType;
32 const int nVersion;
33
34public:
35 OverrideStream(Stream* stream_, int nType_, int nVersion_) : stream(stream_), nType(nType_), nVersion(nVersion_) {}
36
37 template<typename T>
38 OverrideStream<Stream>& operator<<(const T& obj)
39 {
40 // Serialize to this stream
41 ::Serialize(*this, obj);
42 return (*this);
43 }
44
45 template<typename T>
46 OverrideStream<Stream>& operator>>(T&& obj)
47 {
48 // Unserialize from this stream
49 ::Unserialize(*this, obj);
50 return (*this);
51 }
52
53 void write(Span<const std::byte> src)
54 {
55 stream->write(src);
56 }
57
58 void read(Span<std::byte> dst)
59 {
60 stream->read(dst);
61 }
62
63 int GetVersion() const { return nVersion; }
64 int GetType() const { return nType; }
65 size_t size() const { return stream->size(); }
66 void ignore(size_t size) { return stream->ignore(size); }
67};
68
69/* Minimal stream for overwriting and/or appending to an existing byte vector
70 *

Callers

nothing calls this directly

Calls 2

UnserializeFunction · 0.85
SerializeFunction · 0.70

Tested by

no test coverage detected