TextWriter Class Reference

#include <textwriter.h>

List of all members.

Public Member Functions

 TextWriter (wxBufferedOutputStream *_outputStream)
 ~TextWriter ()
void SetOutputStream (wxBufferedOutputStream *_outputStream)
TextWriterWrite (const char *str)
 Write character string to output stream.
TextWriterWrite (const char *str, size_t size)
 Write character string to output stream.
TextWriterWrite (const float &val)
 Write float to output stream.
TextWriterWrite (const int &val)
 Write integer to output stream.
TextWriterWrite (const unsigned int &val)
 Write unsigned integer to output stream.
TextWriterWrite (const long &val)
 Write long to output stream.
TextWriterWrite (const wxString &str)
 Write wxString to output stream.
TextWriterWrite (const float *values, int num, const char *delimiter)
 Write float array to output stream, put delimiter after every value.

Private Attributes

wxBufferedOutputStream * outputStream


Detailed Description

Definition at line 14 of file textwriter.h.


Constructor & Destructor Documentation

TextWriter::TextWriter ( wxBufferedOutputStream *  _outputStream  )  [inline]

Definition at line 20 of file textwriter.h.

00020 : outputStream(_outputStream) {};

TextWriter::~TextWriter (  )  [inline]

Definition at line 22 of file textwriter.h.

00023        {
00024        };


Member Function Documentation

void TextWriter::SetOutputStream ( wxBufferedOutputStream *  _outputStream  )  [inline]

Definition at line 26 of file textwriter.h.

00027        {
00028               outputStream = _outputStream;
00029        }

TextWriter* TextWriter::Write ( const char *  str  )  [inline]

Write character string to output stream.

Definition at line 32 of file textwriter.h.

00033        {
00034               outputStream->Write(str, strlen(str));
00035               return this;
00036        }

TextWriter* TextWriter::Write ( const char *  str,
size_t  size 
) [inline]

Write character string to output stream.

Definition at line 39 of file textwriter.h.

00040        {
00041               outputStream->Write(str, size);
00042               return this;
00043        }

TextWriter* TextWriter::Write ( const float &  val  )  [inline]

Write float to output stream.

Definition at line 46 of file textwriter.h.

00047        {
00048               if (val == 0)
00049                      return Write("0", 1);
00050               if (_isnan(val))
00051                      return Write("1.#IND000", 9);
00052               char tmp[30];
00053               char *index=tmp+29;
00054               *index=0;
00055               int lg=log10l(fabs(val));
00056               int lgr=lg;
00057               float rpart=val;
00058               if ((lg<-2) || (lg>10))
00059               {
00060                      if (lg<0)
00061                             lg--;
00062                      rpart/=pow(10.0f, lg);
00063                      lgr=1;
00064                      int lgtmp=abs(lg);
00065                      do {
00066                             index--;
00067                             *index = (char)(lgtmp%10) + '0';
00068                      } while(lgtmp /= 10);
00069                      if (lg<0)
00070                      {
00071                             index--;
00072                             *index='-';
00073                      }
00074                      index--;
00075                      *index='e';
00076               }
00077               int ipart = rpart;
00078               rpart=fabs(rpart-ipart);
00079               int count=7-lgr;
00080               if (ipart==0)
00081                      count++;
00082               long ripart = rpart*pow(10.0f, count)+0.5f;
00083               if (ripart!=0)
00084               {
00085                      while (ripart%10==0)
00086                      {
00087                             ripart/=10;
00088                             count--;
00089                      }
00090                      while (count--)
00091                      {
00092                             index--;
00093                             *index = (char)(ripart%10) + '0';
00094                             ripart/=10;
00095                      }
00096                      index--;
00097                      *index='.';
00098               }
00099               ipart=abs(ipart);
00100               do {
00101                      index--;
00102                      *index = (char)(ipart%10) + '0';
00103               } while(ipart /= 10);
00104               if (val<0)
00105               {
00106                      index--;
00107                      *index='-';
00108               }
00109               return Write(index, tmp+29-index);
00110        }

TextWriter* TextWriter::Write ( const int &  val  )  [inline]

Write integer to output stream.

Definition at line 113 of file textwriter.h.

00114        {
00115               if(val == 0)
00116                      return Write("0", 1);
00117               char tmp[30];
00118               char *index=tmp+29;
00119               *index=0;
00120               int numLeft = abs(val);
00121               do {
00122                      index--;
00123                      *index = (char)(numLeft%10) + '0';
00124               } while(numLeft /= 10);
00125               if(val < 0)
00126               {
00127                      index--;
00128                      *index = '-';
00129               }
00130               return Write(index, tmp+29-index);
00131        }

TextWriter* TextWriter::Write ( const unsigned int &  val  )  [inline]

Write unsigned integer to output stream.

Definition at line 134 of file textwriter.h.

00135        {
00136               return Write((int)val);
00137        }

TextWriter* TextWriter::Write ( const long &  val  )  [inline]

Write long to output stream.

Definition at line 140 of file textwriter.h.

00141        {
00142               if(val == 0)
00143                      return Write("0", 1);
00144               char tmp[30];
00145               char *index=tmp+29;
00146               *index=0;
00147               long numLeft = abs(val);
00148               do {
00149                      index--;
00150                      *index = (char)(numLeft%10) + '0';
00151                      
00152               } while(numLeft /= 10);
00153               if(val < 0)
00154               {
00155                      index--;
00156                      *index = '-';
00157               }
00158               return Write(index, tmp+29-index);
00159        }

TextWriter* TextWriter::Write ( const wxString &  str  )  [inline]

Write wxString to output stream.

Definition at line 162 of file textwriter.h.

00163        {
00164               return Write(str.mb_str(wxConvISO8859_1), str.size());
00165        }

TextWriter* TextWriter::Write ( const float *  values,
int  num,
const char *  delimiter 
) [inline]

Write float array to output stream, put delimiter after every value.

Definition at line 168 of file textwriter.h.

00169        {
00170               for (int i=0; i<num; i++)
00171               {
00172                      if (i)
00173                             Write(delimiter);
00174                      Write(values[i]);
00175               }
00176               return this;
00177        }


Member Data Documentation

wxBufferedOutputStream* TextWriter::outputStream [private]

Definition at line 17 of file textwriter.h.


The documentation for this class was generated from the following file:

Generated on Tue Mar 10 14:41:38 2009 for VRUT by  doxygen 1.5.5