pintee.cxx (904B)
1 /* 2 * 3 * C++ Portable Types Library (PTypes) 4 * Version 2.1.1 Released 27-Jun-2007 5 * 6 * Copyright (C) 2001-2007 Hovik Melikyan 7 * 8 * http://www.melikyan.com/ptypes/ 9 * 10 */ 11 12 #include "pstreams.h" 13 14 15 namespace ptypes { 16 17 18 intee::intee(instm* istm, const char* ifn, bool iappend) 19 : infilter(istm, -1), file(ifn, iappend) 20 { 21 } 22 23 24 intee::intee(instm* istm, const string& ifn, bool iappend) 25 : infilter(istm, -1), file(ifn, iappend) 26 { 27 } 28 29 30 intee::~intee() 31 { 32 close(); 33 } 34 35 36 void intee::doopen() 37 { 38 infilter::doopen(); 39 file.open(); 40 } 41 42 43 void intee::doclose() 44 { 45 file.close(); 46 infilter::doclose(); 47 } 48 49 50 void intee::dofilter() 51 { 52 int count = stm->read(savebuf, savecount); 53 if (count > 0) 54 { 55 file.write(savebuf, count); 56 savebuf += count; 57 savecount -= count; 58 } 59 } 60 61 62 string intee::get_streamname() 63 { 64 return "tee: " + file.get_filename(); 65 } 66 67 68 }