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

CTBprintfBase.cxx

Go to the documentation of this file.
00001 
00006 /*----------------------------------------------------------------------------*/
00007 /* C Tool Box: Designed and implemented by:                                   */
00008 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00009 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00010 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00011 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00012 /*------------------------------------------+---------------------------------*/
00013 
00014 #include "CTB.hxx"
00015 #include "CTBprintfBase.hxx"
00016 
00017 #ifdef DEV_DOCS
00018 
00022 //------------------------------------------+-----------------------------------
00027 //------------------------------------------+-----------------------------------
00032 #endif
00033 
00034 //------------------------------------------+-----------------------------------
00035 #ifdef DEV_DOCS
00036 
00045 #endif
00046 
00047 CTBprintfBase1d::CTBprintfBase1d(const char* c_format, int i_width, 
00048                                  int i_precision, CTBint i_pcol, CTBint i_wind)
00049   : CTBprintfBaseNd(c_format, i_width, i_precision, i_pcol, i_wind)
00050 {}
00051 
00052 //------------------------------------------+-----------------------------------
00053 #ifdef DEV_DOCS
00054 
00055 #endif
00056 
00057 void CTBprintfBase1d::ToStream(ostream& os) const
00058 {
00059   CTBint      np   = 0;
00060   CTBint      n1   = Dimension1();
00061   const char* c_nl = "";
00062   bool        b_nl = true;
00063 
00064   for (CTBint i = 0; i < n1; i++) {
00065 
00066     if (b_nl) {                             // new line
00067       b_nl = false;
00068       os << c_nl;
00069       c_nl = "\n";
00070       np   = 0;
00071       if (mi_wind >= 0) {                   // index prefix
00072         os << "(" << setw(mi_wind) << i << ") ";
00073       }
00074     }    
00075 
00076     ToStreamElement(os,i);                  // print element
00077 
00078     if (i != n1-1) {
00079       os << ",";
00080       np += 1;
00081       if (mi_pcol > 0 && np >= mi_pcol) b_nl = true;
00082     }
00083   }
00084   return;
00085 }
00086 
00087 //##############################################################################
00088 
00089 #ifdef DEV_DOCS
00090 
00094 //------------------------------------------+-----------------------------------
00099 //------------------------------------------+-----------------------------------
00104 //------------------------------------------+-----------------------------------
00109 #endif
00110 
00111 //------------------------------------------+-----------------------------------
00112 #ifdef DEV_DOCS
00113 
00123 #endif
00124 
00125 CTBprintfBase2d::CTBprintfBase2d(const char* c_format, int i_width, 
00126                                  int i_precision, CTBint i_pcol, CTBint i_wind,
00127                                  bool b_sep12)
00128   : CTBprintfBaseNd(c_format, i_width, i_precision, i_pcol, i_wind),
00129     mb_sep12(b_sep12)
00130 {}
00131 
00132 //------------------------------------------+-----------------------------------
00133 #ifdef DEV_DOCS
00134 
00135 #endif
00136 
00137 void CTBprintfBase2d::ToStream(ostream& os) const
00138 {
00139   CTBint      np      = -1;
00140   CTBint      n1      = Dimension1();
00141   const char* c_sep12 = mb_sep12 ? ")(" : ",";
00142   const char* c_nl    = "";
00143   bool        b_nl    = true;
00144 
00145   for (CTBint i1 = 0; i1 < n1; i1++) {
00146     CTBint n2 = Dimension2(i1);
00147 
00148     for (CTBint i2 = 0; i2 < n2; i2++) {
00149 
00150       if (b_nl) {                           // new line
00151         b_nl = false;
00152         os << c_nl;
00153         c_nl = "\n";
00154         np   = 0;
00155         if (mi_wind >= 0) {                 // index prefix
00156           os << "(" << setw(mi_wind) << i1 
00157              << c_sep12 << setw(mi_wind) << i2 << ") ";
00158         }
00159         if (i2 != 0) os << " ";
00160       }
00161       
00162       if (i2 == 0) os << "{";
00163 
00164       ToStreamElement(os,i1,i2);
00165 
00166       if (i2 != n2-1) {
00167         os << ",";
00168         np += 1;
00169         if (mi_pcol > 0 && np >= mi_pcol) b_nl = true;
00170       }
00171 
00172       if (i2 == n2-1) {
00173         os << "}";
00174         if (mi_pcol >= 0) b_nl = true;
00175       }
00176 
00177     }
00178     if (i1 != n1-1) os << ",";
00179   }
00180   
00181   return;
00182 }
00183 
00184 //##############################################################################
00185 
00186 #ifdef DEV_DOCS
00187 
00191 //------------------------------------------+-----------------------------------
00196 //------------------------------------------+-----------------------------------
00201 //------------------------------------------+-----------------------------------
00206 //------------------------------------------+-----------------------------------
00211 #endif
00212 
00213 //------------------------------------------+-----------------------------------
00214 #ifdef DEV_DOCS
00215 
00226 #endif
00227 
00228 CTBprintfBase3d::CTBprintfBase3d(const char* c_format, int i_width, 
00229                                  int i_precision, CTBint i_pcol, CTBint i_wind,
00230                                  bool b_sep12,bool b_sep23)
00231   : CTBprintfBaseNd(c_format, i_width, i_precision, i_pcol, i_wind),
00232     mb_sep12(b_sep12),
00233     mb_sep23(b_sep23)
00234 {}
00235 
00236 //------------------------------------------+-----------------------------------
00237 #ifdef DEV_DOCS
00238 
00239 #endif
00240 
00241 void CTBprintfBase3d::ToStream(ostream& os) const
00242 {
00243   CTBint      np      = -1;
00244   CTBint      n1      = Dimension1();
00245   const char* c_sep12 = mb_sep12 ? ")(" : ",";
00246   const char* c_sep23 = mb_sep23 ? ")(" : ",";
00247   const char* c_nl    = "";
00248   bool        b_nl    = true;
00249 
00250   for (CTBint i1 = 0; i1 < n1; i1++) {
00251     CTBint n2 = Dimension2(i1);
00252 
00253     for (CTBint i2 = 0; i2 < n2; i2++) {
00254       CTBint n3 = Dimension3(i1,i2);
00255 
00256       for (CTBint i3 = 0; i3 < n3; i3++) {
00257 
00258         if (b_nl) {                         // new line
00259           b_nl = false;
00260           os << c_nl;
00261           c_nl = "\n";
00262           np   = 0;
00263           if (mi_wind >= 0) {               // index prefix
00264             os << "(" << setw(mi_wind) << i1 
00265                << c_sep12 << setw(mi_wind) << i2 
00266                << c_sep23 << setw(mi_wind) << i3 << ") ";
00267           }
00268           if (i2 != 0 || i3 != 0) os << " ";
00269           if (i3 != 0) os << " ";
00270         }
00271         
00272         if (i2 == 0 && i3 == 0) os << "{";
00273         if (i3 == 0) os << "{";
00274         
00275         ToStreamElement(os,i1,i2,i3);
00276 
00277         if (i3 != n3-1) {
00278           os << ",";
00279           np += 1;
00280           if (mi_pcol > 0 && np >= mi_pcol) b_nl = true;
00281         }
00282         
00283         if (i3 == n3-1) {
00284           os << "}";
00285           if (mi_pcol >= 0) b_nl = true;
00286         }
00287 
00288       }
00289       os << ((i2 != n2-1) ? "," : "}" );
00290     }
00291     if (i1 != n1-1) os << ",";
00292   }
00293   
00294   return;
00295 }
00296 

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