6 #include <boost/iostreams/copy.hpp> 7 #include <boost/iostreams/filter/bzip2.hpp> 8 #include <boost/iostreams/device/file.hpp> 9 #include <boost/iostreams/filtering_stream.hpp> 18 string name = argv[0];
21 std::uniform_real_distribution<double> distribution(0.0,1.0);
22 auto uni = std::bind(distribution, generator);
24 cout <<
"Generating data\n";
25 const int nbins = 500;
26 const int narrays = 100;
29 for (
int ind=0; ind<narrays; ++ind) {
31 for (
int ibin=0; ibin<
nbins; ++ibin) {
33 data[ind][ibin] = number;
41 string fname = name+
".bin";
42 cout <<
"writing " << fname <<
endl;
43 fstream myfile(fname.c_str(), ios::out | ios::binary);
44 myfile.write((
char*)data, nbins*narrays*
sizeof(
double));
49 string fname = name+
".json";
50 cout <<
"writing " << fname <<
endl;
51 ofstream jout(fname.c_str());
52 Json::FastWriter jwriter;
53 jout << jwriter.write(jroot);
57 string fname = name+
".json.bz2";
58 cout <<
"writing " << fname <<
endl;
59 std::fstream jbz2file(fname.c_str(), std::ios::binary|std::ios::out);
60 boost::iostreams::filtering_stream<boost::iostreams::output> outfilt;
61 outfilt.push(boost::iostreams::bzip2_compressor());
62 outfilt.push(jbz2file);
68 string fname = name+
".json.bz2";
69 cout <<
"reading " << fname <<
endl;
70 std::fstream jbz2file(fname.c_str(), std::ios::binary|std::ios::in);
71 boost::iostreams::filtering_stream<boost::iostreams::input> infilt;
72 infilt.push(boost::iostreams::bzip2_decompressor());
73 infilt.push(jbz2file);
78 string fname = name +
"2.json";
79 cout <<
"writing " << fname <<
endl;
80 ofstream jout2(fname.c_str());
81 Json::FastWriter jwriter2;
82 jout2 << jwriter2.write(jroot2);
int main(int argc, char *argv[])
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
QTextStream & endl(QTextStream &s)