PSDL_Stream.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // PSDL_Stream.cpp,v 1.1 2002/07/25 15:25:51 pgontla Exp
00003 
00004 #include "PSDL_Stream.h"
00005 
00006 ACE_RCSID (PSS, PSDL_Scope, "PSDL_Stream.cpp,v 1.1 2002/07/25 15:25:51 pgontla Exp")
00007 
00008 TAO_PSDL_Stream::TAO_PSDL_Stream (void)
00009 {
00010 }
00011 
00012 TAO_PSDL_Stream::~TAO_PSDL_Stream (void)
00013 {
00014 }
00015 
00016 int
00017 TAO_PSDL_Stream::open (const char *fname)
00018 {
00019   if (fname != 0)
00020     {
00021       // File name exists, open an I/O file handle.
00022       this->fp_ = ACE_OS::fopen (fname, "w");
00023 
00024       if (this->fp_ != 0)
00025         {
00026           return 0;
00027         }
00028       else
00029         {
00030           return -1;
00031         }
00032     }
00033   else
00034     {
00035       return -1;
00036     }
00037 }
00038 
00039 // Return the underlying lowlevel file pointer.
00040 // indentation.
00041 FILE *
00042 TAO_PSDL_Stream::file (void)
00043 {
00044   return this->fp_;
00045 }
00046 
00047 int
00048 TAO_PSDL_Stream::incr_indent (unsigned short flag)
00049 {
00050   indent_level_++;
00051 
00052   if (flag != 0)
00053     {
00054       return this->indent ();
00055     }
00056   else
00057     {
00058       // Do not indent output.
00059       return 0;
00060     }
00061 }
00062 
00063 // Indentation
00064 int
00065 TAO_PSDL_Stream::decr_indent (unsigned short flag)
00066 {
00067   this->indent_level_--;
00068   // Just in case somebody gets "unindent happy".
00069   if (this->indent_level_ < 0)
00070     {
00071       // ACE_DEBUG ((LM_DEBUG, "negative indentation?\n"));
00072       this->indent_level_ = 0;
00073     }
00074 
00075   if (flag != 0)
00076     {
00077       return this->indent ();
00078     }
00079   else
00080     {
00081       // Do not indent output.
00082       return 0;
00083     }
00084 }
00085 
00086 int
00087 TAO_PSDL_Stream::reset (void)
00088 {
00089   this->indent_level_ = 0;
00090   return 0;
00091 }
00092 
00093 // Indented print.
00094 int
00095 TAO_PSDL_Stream::indent (void)
00096 {
00097   // Based on the current indentation level, leave appropriate number of blank
00098   // spaces in the output.
00099   if (this->indent_level_ > 0)
00100     {
00101       for (int i = 0; i < this->indent_level_; i++)
00102         {
00103           ACE_OS::fprintf (this->fp_, "  ");
00104           ACE_OS::fflush (this->fp_);
00105         }
00106     }
00107 
00108   return 0;
00109 }
00110 
00111 int
00112 TAO_PSDL_Stream::nl (void)
00113 {
00114   ACE_OS::fprintf (this->fp_, "\n");
00115   this->indent ();
00116   return 0;
00117 }
00118 
00119 TAO_PSDL_Stream &
00120 TAO_PSDL_Stream::operator<< (const char *str)
00121 {
00122   ACE_OS::fprintf (this->fp_, "%s", str);
00123   ACE_OS::fflush (this->fp_);
00124   
00125   return *this;
00126 }
00127 
00128 TAO_PSDL_Stream &
00129 TAO_PSDL_Stream::operator<< (ACE_CString str)
00130 {
00131   ACE_OS::fprintf (this->fp_, "%s", str.c_str ());
00132   ACE_OS::fflush (this->fp_);
00133   
00134   return *this;
00135 }
00136 
00137 TAO_PSDL_Stream &
00138 TAO_PSDL_Stream::operator<< (const unsigned long num)
00139 {
00140   ACE_OS::fprintf (this->fp_,
00141                    "%lu",
00142                    num);
00143 
00144   ACE_OS::fflush (this->fp_);
00145   
00146   return *this;
00147 }
00148 
00149 TAO_PSDL_Stream &
00150 TAO_PSDL_Stream::operator<< (const long num)
00151 {
00152   ACE_OS::fprintf (this->fp_,
00153                    "%ld",
00154                    num);
00155 
00156   ACE_OS::fflush (this->fp_);
00157   return *this;
00158 }

Generated on Thu Nov 9 14:07:05 2006 for TAO_PSS by doxygen 1.3.6