Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

HeaderPrinter.cxx

Go to the documentation of this file.
00001 #include "AtlfastUtils/HeaderPrinter.h"
00002 #include <string>
00003 #include <iostream>
00004 #include <strstream>
00005 
00006 namespace Atlfast {
00007   using std::string;
00008   using std::ends;
00009   using std::endl;
00010   using std::cout;
00011   using std::ostrstream;
00012 
00013   unsigned int HeaderPrinter::width(80);
00014 
00015   string HeaderPrinter::m_fullLine(width, '=');
00016   HeaderPrinter::HeaderPrinter(string title, MsgStream& log): 
00017     m_title(title), m_log(log){
00018 
00019     //    const unsigned int width = 80;
00020     //    string fullLine(width, '=');
00021     m_hollowLine+=string(1u,'|');
00022     m_hollowLine+=string(width-2,' ');
00023     m_hollowLine+=string(1u,'|');
00024     int nBlanks =width-m_title.size()-2;
00025     if(nBlanks>0){
00026       unsigned int lBlanks = (nBlanks%2==0)? nBlanks/2:1+nBlanks/2;
00027       unsigned int rBlanks = nBlanks/2;
00028       m_title=
00029         string(1u,'|')
00030         +string(lBlanks,' ')
00031         +m_title
00032         +string(rBlanks,' ')
00033         +string(1u,'|');
00034     }
00035   }
00036   
00037   void HeaderPrinter::add(const string& s, 
00038                           std::vector<int>::const_iterator it,
00039                           std::vector<int>::const_iterator en){
00040     ostrstream sout;
00041     sout<<s;
00042     for(; it !=en; ++it){
00043       sout<<" "<<*it;
00044     }
00045     sout<<ends;
00046     m_strings.push_back(sout.str());
00047   }
00048 
00049   void HeaderPrinter::add(const string&s , int i){
00050     ostrstream sout;
00051     sout<<s<<" "<<i<<ends;
00052     m_strings.push_back(sout.str());
00053   }
00054   
00055   void HeaderPrinter::add(const string& s, double i){
00056     ostrstream sout;
00057     sout<<s<<" "<<i<<ends;
00058     m_strings.push_back(sout.str());
00059   }
00060   
00061   void HeaderPrinter::add(const string& s1, const string& s2){
00062     string temp = s1+" "+s2;
00063     m_strings.push_back(temp);
00064   }
00065   void HeaderPrinter::add(const string& s, bool b){
00066     string temp = s+" ";
00067     temp +=  b? "true":"false";
00068     m_strings.push_back(temp);
00069   }
00070   void HeaderPrinter::add(const string& s){
00071     m_strings.push_back(s);
00072   }
00073   void HeaderPrinter::print()const{
00074     
00075     cout<<m_fullLine<<endl;
00076     cout<<m_hollowLine<<endl;
00077     cout<<m_title<<endl;
00078     cout<<m_hollowLine<<endl;
00079     std::vector<string>::const_iterator it = m_strings.begin();
00080     std::vector<string>::const_iterator en = m_strings.end();
00081 
00082     for(;it!=en; ++it){
00083       string temp = *it;
00084       if(temp.size()<width-2){
00085         temp = string(1u,'|')+string(1u,' ')+temp;
00086       }
00087       while(temp.size()<width-1){
00088         temp += string(1u,' ');
00089       }
00090       temp += string(1u,'|');
00091       cout<<temp<<endl;
00092     }   
00093     cout<<m_hollowLine<<endl;
00094     cout<<m_fullLine<<endl;
00095     cout<<endl<<endl;
00096     return;
00097   }
00098 }
00099 
00100 
00101 
00102 
00103 
00104 
00105 

Generated on Wed Jan 15 11:00:29 2003 for AtlfastUtils by doxygen1.3-rc1