00001 #include "zipios++/zipios-config.h"
00002
00003 #include "zipios++/meta-iostreams.h"
00004 #include <string>
00005 #include <exception>
00006
00007 #include "zipios++/gzipoutputstream.h"
00008
00009 using namespace zipios ;
00010
00011 using std::cerr ;
00012 using std::cout ;
00013 using std::endl ;
00014 using std::ifstream ;
00015 using std::ofstream ;
00016 using std::ios ;
00017 using std::string ;
00018 using std::exception ;
00019
00020 void writeFileToGZIPOutputStream( GZIPOutputStream &zos, const string &filename ) ;
00021
00022 int main() {
00023 try {
00024
00025 GZIPOutputStream ozs("zos.gz") ;
00026
00027 writeFileToGZIPOutputStream( ozs, "test.xml" ) ;
00028
00029 cerr << "End of main" << endl ;
00030
00031 return 0;
00032 }
00033 catch( exception &excp ) {
00034 cerr << "Exception caught in main() :" << endl ;
00035 cerr << excp.what() << endl ;
00036 }
00037 return -1;
00038 }
00039
00040 void writeFileToGZIPOutputStream( GZIPOutputStream &zos, const string &filename ) {
00041
00042 ifstream ifs( filename.c_str(), ios::in | ios::binary ) ;
00043
00044 zos.setFilename(filename);
00045 zos.setComment("ZIPIOS++ TestFile");
00046 zos << ifs.rdbuf() ;
00047
00048 cerr << "ostream Stream state: " ;
00049 cerr << "good() = " << zos.good() << ",\t" ;
00050 cerr << "fail() = " << zos.fail() << ",\t" ;
00051 cerr << "bad() = " << zos.bad() << ",\t" ;
00052 cerr << "eof() = " << zos.eof() << endl ;
00053
00054 cerr << "istream Stream state: " ;
00055 cerr << "good() = " << ifs.good() << ",\t" ;
00056 cerr << "fail() = " << ifs.fail() << ",\t" ;
00057 cerr << "bad() = " << ifs.bad() << ",\t" ;
00058 cerr << "eof() = " << ifs.eof() << endl ;
00059
00060 }
00061
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083