Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBprintfS.cxx

Go to the documentation of this file.
00001 //
00007 /*----------------------------------------------------------------------------*/
00008 /* C Tool Box: Designed and implemented by:                                   */
00009 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00010 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00011 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00012 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00013 /*------------------------------------------+---------------------------------*/
00014 
00015 #include    "CTB.hxx"
00016 #include    "CTBioState.hxx"
00017 #include    "CTBprintfS.hxx"
00018 
00019 #ifdef DEV_DOCS
00020 
00024 #endif
00025 
00026 //------------------------------------------+-----------------------------------
00027 #ifdef DEV_DOCS
00028 
00036 #endif
00037 
00038 template <class T>
00039 CTBprintfS<T>::CTBprintfS(T value, const char* c_format, int i_width, 
00040                           int i_precision)
00041   : CTBprintfBase(c_format, i_width, i_precision),
00042     m_value(value)
00043 {}
00044 
00045 //------------------------------------------+-----------------------------------
00046 template <class T>
00047 void CTBprintfS<T>::ToStream(ostream& os) const
00048 {
00049   CTBioState iostate(os, mc_format, mi_precision);
00050   os << setw(mi_width) << m_value;
00051 }
00052 
00053 //------------------------------------------+-----------------------------------
00054 template <>
00055 void CTBprintfS<char>::ToStream(ostream& os) const
00056 {
00057   CTBioState  iostate(os, mc_format, mi_precision);
00058   char        c_ctype = iostate.GetCtype();
00059   
00060   os.width(mi_width);
00061   if (c_ctype == 0 || c_ctype == 'c') {
00062     os << m_value;
00063   } else {
00064     os << (int) m_value;
00065   }
00066 }
00067 
00068 //------------------------------------------+-----------------------------------
00069 template <>
00070 void CTBprintfS<int>::ToStream(ostream& os) const
00071 {
00072   CTBioState  iostate(os, mc_format, mi_precision);
00073   char        c_ctype = iostate.GetCtype();
00074   
00075   os.width(mi_width);
00076   if (c_ctype == 'c') {
00077     os << (char) m_value;
00078   } else {
00079     os << m_value;
00080   }
00081 }
00082 
00083 //------------------------------------------+-----------------------------------
00084 template <>
00085 void CTBprintfS<const char *>::ToStream(ostream& os) const
00086 {
00087   CTBioState  iostate(os, mc_format, mi_precision);
00088   char        c_ctype = iostate.GetCtype();
00089   
00090   os.width(mi_width);
00091   if (c_ctype == 'p') {
00092     os << (const void*) m_value;
00093   } else {
00094     os << m_value;
00095   }
00096 }
00097 
00098 //------------------------------------------+-----------------------------------
00099 template <>
00100 void CTBprintfS<const void *>::ToStream(ostream& os) const
00101 {
00102   CTBioState  iostate(os, mc_format, mi_precision);
00103   char        c_ctype = iostate.GetCtype();
00104   
00105   os.width(mi_width);
00106   if (c_ctype == 0 || c_ctype == 'p') {
00107     os << m_value;
00108   } else {
00109     os << (unsigned long) m_value;
00110   }
00111 }
00112 

Generated at Fri Oct 24 18:11:29 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001