blob: a8f69eb2a42dcd216a6b5a6e2d88c7c3b5141659 (
plain)
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
37
|
/*
* MRustC - Rust Compiler
* - By John Hodge (Mutabah/thePowersGang)
*
* hir/serialise_lowlevel.cpp
* - HIR (De)Serialisation low-level "protocol"
*/
#include "serialise_lowlevel.hpp"
#include <boost/iostreams/filter/zlib.hpp>
::HIR::serialise::Writer::Writer(const ::std::string& filename):
m_backing( filename )
{
m_os.push( ::boost::iostreams::zlib_compressor() );
m_os.push( m_backing );
}
void ::HIR::serialise::Writer::write(const void* buf, size_t len)
{
m_os.write(reinterpret_cast<const char*>(buf), len);
}
::HIR::serialise::Reader::Reader(const ::std::string& filename):
m_backing( filename )
{
m_is.push( ::boost::iostreams::zlib_decompressor() );
m_is.push( m_backing );
}
void ::HIR::serialise::Reader::read(void* buf, size_t len)
{
m_is.read(reinterpret_cast<char*>(buf), len);
if( !m_is ) {
throw "";
}
}
|