00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "TOutputHtmlFileStream.hh"
00020 #include "TSystemClock.hh"
00021
00022 static const Tstring _title = "UNTITLED DOCUMENT";
00023
00024 TOutputHtmlFileStream::TOutputHtmlFileStream()
00025 : Tofstream(), theStatus( 0 ), theTitle( _title ), theFileName( "" )
00026 {;}
00027
00028 TOutputHtmlFileStream::TOutputHtmlFileStream( const Tstring& filename )
00029 : Tofstream( filename.c_str() ), theStatus( 0 ), theTitle( _title ), theFileName( filename )
00030 {
00031 setStatusBit( TOutputHtmlFileStream::fopen );
00032 clearStatusBit( TOutputHtmlFileStream::fclose );
00033 }
00034
00035 TOutputHtmlFileStream::TOutputHtmlFileStream( const Tstring& filename, const Tstring& title )
00036 : Tofstream( filename.c_str() ), theStatus( 0 ), theTitle( title ), theFileName( filename )
00037 {
00038 setStatusBit( TOutputHtmlFileStream::fopen );
00039 clearStatusBit( TOutputHtmlFileStream::fclose );
00040 setStatusBit( TOutputHtmlFileStream::title );
00041 }
00042
00043 TOutputHtmlFileStream::~TOutputHtmlFileStream()
00044 {
00045 Close();
00046 }
00047
00048 TOutputHtmlFileStream& TOutputHtmlFileStream::WriteHeader()
00049 {
00050 if ( IsOpen() && !IsWrittenHeader() ) {
00051 *this << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" << Tendl;
00052 *this << "<html>" << Tendl;
00053 *this << "<head>" << Tendl;
00054 *this << "<meta http-equiv=\"content-type\" content=\"text/html; charset=euc-jp\">" << Tendl;
00055 *this << "<title>" << theTitle << "</title>" << Tendl;
00056 *this << "</head>" << Tendl;
00057 *this << "<body>" << Tendl;
00058 *this << "<h1>" << theTitle << "</h1>" << Tendl;
00059 *this << "<hr>" << Tendl;
00060 setStatusBit( TOutputHtmlFileStream::wheader );
00061 }
00062 return *this;
00063 }
00064
00065 TOutputHtmlFileStream& TOutputHtmlFileStream::WriteFooter()
00066 {
00067 if ( IsOpen() && !IsWrittenFooter() ) {
00068 TSystemClock clock;
00069 *this << "<hr>" << Tendl;
00070 *this << clock.WhatTimeIsItNow() << "<br>" << Tendl;
00071 *this << "$Id: TOutputHtmlFileStream.cc,v 1.7 2004/03/07 10:30:34 goiwai Exp $" << "<br>" << Tendl;
00072 *this << "$Name: CLDAQ-1-14-03 $" << "<br>" << Tendl;
00073 *this << "<hr>" << Tendl;
00074 *this << "<div align=right>" << Tendl;
00075 *this << "<address>" << Tendl;
00076 *this << "<a href=\"http://cldaq.sourceforge.jp/\">CLDAQ</a>, <a href=\"http://www.hep.sc.niigata-u.ac.jp/~iwai/\">Go IWAI</a>, <a href=\"mailto:iwai@hep.sc.niigata-u.ac.jp\">iwai@hep.sc.niigata-u.ac.jp</a>" << Tendl;
00077 *this << "</address>" << Tendl;
00078 *this << "</div>" << Tendl;
00079 *this << "</body>" << Tendl;
00080 *this << "</html>" << Tendl;
00081 setStatusBit( TOutputHtmlFileStream::wfooter );
00082 }
00083 return *this;
00084 }
00085
00086 TOutputHtmlFileStream& TOutputHtmlFileStream::OpenTable()
00087 {
00088 if ( IsOpen() ) {
00089 if ( IsWrittenHeader() ) {
00090 if ( IsCloseTable() ) {
00091 *this << "<table border=1 cellpadding=4 width=\"100%\">" << Tendl;
00092 } else {
00093 CloseTable();
00094 *this << "<table border=1 cellpadding=4 width=\"100%\">" << Tendl;
00095 }
00096 setStatusBit( TOutputHtmlFileStream::otable );
00097 clearStatusBit( TOutputHtmlFileStream::ctable );
00098 } else {
00099 WriteHeader();
00100 OpenTable();
00101 }
00102 }
00103 return *this;
00104 }
00105
00106 TOutputHtmlFileStream& TOutputHtmlFileStream::CloseTable()
00107 {
00108 if ( IsOpen() ) {
00109 if ( IsWrittenHeader() ) {
00110 if ( IsOpenTable() && !IsCloseTable() ) {
00111 *this << "</table>" << Tendl;
00112 *this << "<p>" << Tendl;
00113 clearStatusBit( TOutputHtmlFileStream::otable );
00114 setStatusBit( TOutputHtmlFileStream::ctable );
00115 }
00116 } else {
00117 WriteHeader();
00118 }
00119 }
00120 return *this;
00121 }
00122
00123 Tvoid TOutputHtmlFileStream::Open( const Tstring& filename )
00124 {
00125 theFileName = filename;
00126 clearStatusBit( TOutputHtmlFileStream::wheader );
00127 clearStatusBit( TOutputHtmlFileStream::wfooter );
00128 clearStatusBit( TOutputHtmlFileStream::otable );
00129 setStatusBit( TOutputHtmlFileStream::ctable );
00130 if ( !IsOpen() ) {
00131 open( filename.c_str() );
00132 setStatusBit( TOutputHtmlFileStream::fopen );
00133 clearStatusBit( TOutputHtmlFileStream::fclose );
00134 }
00135 return;
00136 }
00137
00138 Tvoid TOutputHtmlFileStream::Open( const Tstring& filename, const Tstring& title )
00139 {
00140 SetTitle( title );
00141 Open( filename );
00142 return;
00143 }
00144
00145 Tvoid TOutputHtmlFileStream::Close()
00146 {
00147 if ( IsOpen() ) {
00148 if ( IsWrittenHeader() ) {
00149 if ( IsOpenTable() && !IsCloseTable() ) {
00150 CloseTable();
00151 }
00152 if ( !IsWrittenFooter() ) {
00153 WriteFooter();
00154 }
00155 }
00156 close();
00157 clearStatusBit( TOutputHtmlFileStream::fopen );
00158 setStatusBit( TOutputHtmlFileStream::fclose );
00159
00160 clearStatusBit( TOutputHtmlFileStream::otable );
00161 setStatusBit( TOutputHtmlFileStream::ctable );
00162 clearStatusBit( TOutputHtmlFileStream::wheader );
00163 clearStatusBit( TOutputHtmlFileStream::wfooter );
00164 }
00165 return;
00166 }
00167
00168 #ifdef __CLDAQ_ROOT_DLL
00169 ClassImp(TOutputHtmlFileStream)
00170 #endif