27 #define HAVE_BOOST_IOSTREAMS
28 #ifdef HAVE_BOOST_IOSTREAMS
40 return out << std::setw(62) << di.name
41 << std::setw(8) << di.type_size
42 << std::setw(8) << di.ispod;
48 out <<
"------------------------------------------------------------------------------\n";
49 out <<
" Binary datatype output manifest \n";
50 out <<
" data type size is_pod\n";
51 out <<
"------------------------------------------------------------------------------\n";
53 for(
int i = 0; i != manifest.size(); i++)
55 out << manifest[i] <<
"\n";
74 int demo_binarystream()
76 using namespace peyton::io;
84 fstream io(
"bla.bin", ios::in | ios::out | ios::binary | ios::trunc);
86 bio.exceptions(ifstream::eofbit | ifstream::failbit | ifstream::badbit);
91 FOR(0, v.size()) { v[i] = i; }
94 test_t t = {
'a', -2, 1., 2. },
x;
97 typedef map<int, std::string> M;
99 a[1] =
"jedan"; a[2] =
"dva"; a[3] =
"tri";
105 cout <<
"number of elements read: " << w.size() <<
"\nelements:";
106 FOR(0, w.size()) { cout <<
" " << w[i]; }
110 cout <<
"User defined plain struct: " <<
x.c <<
" " <<
x.s <<
" " <<
x.f <<
" " <<
x.d <<
"\n\n";
113 cout <<
"map size: " << b.size() <<
"\n";
114 cout <<
"map elements:";
115 FOREACH2(M::const_iterator, b) { cout <<
" (" << (*i).first <<
"->" << (*i).second <<
")"; }
130 #include <boost/iostreams/filtering_stream.hpp>
131 #include <boost/iostreams/filter/bzip2.hpp>
132 #include <boost/iostreams/filter/gzip.hpp>
133 #include <boost/iostreams/device/file.hpp>
135 void demo_binarystream_with_boost_iostreams()
137 using namespace boost::iostreams;
138 using namespace peyton::io;
140 filtering_streambuf<output> out(bzip2_compressor() | file_sink(
"bla.bin.bz2"));
143 std::valarray<int> v, w;
145 FOR(0, v.size()) { v[i] = i; }
149 filtering_streambuf<input> in(bzip2_decompressor() | file_source(
"bla.bin.bz2"));
152 std::cout <<
"size=" << w.size() <<
"\n";
153 FOR(0, w.size()) { std::cout << w[i] <<
" "; } std::cout <<
"\n";
157 #else // HAVE_BOOST_IOSTREAMS
161 int demo_binarystream()
163 std::cerr <<
"Boost.Iostream support not compiled in.";
167 #endif // HAVE_BOOST_IOSTREAMS