Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/dater.cpp
Go to the documentation of this file.
1 #include <xstream/dater.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  const size_t len = 4*1024;
13  char buf[len];
14 
15  ostream* out;
16 
17  try{
18  if(2==argc){
19  out = new ofstream(argv[1]);
20  }else{
21  out=&cout;
22  }
23 
24  dater dsb(out->rdbuf());
25  //dater dsb(out->rdbuf(),"{%F %T %z}-> ");
26  ostream dout(&dsb);
27 
28  //raise exceptions
29  dout.exceptions(ios::badbit);
30 
31  while(cin.good()){
32  cin.read(buf,len);
33  dout.write(buf,cin.gcount());
34  }
35 
36  dout.flush();
37 
38  }
39  catch(exception& e){
40  cerr<<"Error: "<<e.what()<<endl;
41  }
42 
43 
44  //pointers not being freed
45 
46  return 0;
47 }
#define dout
Definition: Diostream.h:7
TEllipse * e
C++ objects to date output lines.
filter that add a time stamp on the begining of each line
Definition: dater.h:23
int main(int argc, char *argv[])
Definition: gendoc.cc:6