Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
n_tee.cpp
Go to the documentation of this file.
1 #include <xstream/tee.h>
2 
3 #include <iostream>
4 #include <fstream>
5 
6 
7 using namespace std;;
8 using namespace xstream;;
9 
10 
11 int main(int argc, char* argv[]){
12 
13  try{
14  if(1<argc){
15  tee::ostreambuf Tee;
16  for(int i=1; i<argc;++i){
17  ofstream* file = new ofstream(argv[i]);
18  Tee.add(file->rdbuf());
19  }
20 
21  ostream tee(&Tee);
22 
23  //raise exceptions
24  tee.exceptions(ios::badbit);
25 
26  tee<<cin.rdbuf();
27  tee.flush();
28 
29  }else{
30  cerr<<argv[0]<<" file1 file2 ... filen"<<endl;
31  }
32  }
33  catch(exception& e){
34  cerr<<"Error: "<<e.what()<<endl;
35  }
36 
37  return 0;
38 }
fork output stream class
Definition: tee.h:36
C++ streambuf to fork output data written to it is also written to several other streambufs.
TEllipse * e
void add(std::streambuf *sb)
add an output streembuf to write to
Definition: tee.cpp:15
int main(int argc, char *argv[])
Definition: gendoc.cc:6