Public Member Functions | Private Attributes

TAO_PSDL_Stream Class Reference

#include <PSDL_Stream.h>

List of all members.

Public Member Functions

 TAO_PSDL_Stream (void)
 ~TAO_PSDL_Stream (void)
int open (const char *fname)
 Open the file name to be able to write to it.
FILE * file (void)
 Return the underlying lowlevel file pointer.
int incr_indent (unsigned short flag=1)
int decr_indent (unsigned short flag=1)
int reset (void)
 reset indentation level to 0
int indent (void)
 indent starting next line
int nl (void)
 put a newline and indent on the next line
int print (const char *format,...)
 "printf" style variable argument print
TAO_PSDL_Streamoperator<< (const char *str)
TAO_PSDL_Streamoperator<< (ACE_CString str)
TAO_PSDL_Streamoperator<< (const unsigned long num)
TAO_PSDL_Streamoperator<< (const long num)

Private Attributes

FILE * fp_
int indent_level_

Detailed Description

Definition at line 31 of file PSDL_Stream.h.


Constructor & Destructor Documentation

TAO_PSDL_Stream::TAO_PSDL_Stream ( void   ) 

Definition at line 8 of file PSDL_Stream.cpp.

{
}

TAO_PSDL_Stream::~TAO_PSDL_Stream ( void   ) 

Definition at line 12 of file PSDL_Stream.cpp.

{
}


Member Function Documentation

int TAO_PSDL_Stream::decr_indent ( unsigned short  flag = 1  ) 

decrease the indentation level and by default actually indent the output accordingly

Definition at line 65 of file PSDL_Stream.cpp.

{
  this->indent_level_--;
  // Just in case somebody gets "unindent happy".
  if (this->indent_level_ < 0)
    {
      // ACE_DEBUG ((LM_DEBUG, "negative indentation?\n"));
      this->indent_level_ = 0;
    }

  if (flag != 0)
    {
      return this->indent ();
    }
  else
    {
      // Do not indent output.
      return 0;
    }
}

FILE * TAO_PSDL_Stream::file ( void   ) 

Return the underlying lowlevel file pointer.

Definition at line 42 of file PSDL_Stream.cpp.

{
  return this->fp_;
}

int TAO_PSDL_Stream::incr_indent ( unsigned short  flag = 1  ) 

increment the indentation level and by default actually indent the output accordingly

Definition at line 48 of file PSDL_Stream.cpp.

{
  indent_level_++;

  if (flag != 0)
    {
      return this->indent ();
    }
  else
    {
      // Do not indent output.
      return 0;
    }
}

int TAO_PSDL_Stream::indent ( void   ) 

indent starting next line

Definition at line 95 of file PSDL_Stream.cpp.

{
  // Based on the current indentation level, leave appropriate number of blank
  // spaces in the output.
  if (this->indent_level_ > 0)
    {
      for (int i = 0; i < this->indent_level_; i++)
        {
          ACE_OS::fprintf (this->fp_, "  ");
          ACE_OS::fflush (this->fp_);
        }
    }

  return 0;
}

int TAO_PSDL_Stream::nl ( void   ) 

put a newline and indent on the next line

Definition at line 112 of file PSDL_Stream.cpp.

{
  ACE_OS::fprintf (this->fp_, "\n");
  this->indent ();
  return 0;
}

int TAO_PSDL_Stream::open ( const char *  fname  ) 

Open the file name to be able to write to it.

Definition at line 17 of file PSDL_Stream.cpp.

{
  if (fname != 0)
    {
      // File name exists, open an I/O file handle.
      this->fp_ = ACE_OS::fopen (fname, "w");

      if (this->fp_ != 0)
        {
          return 0;
        }
      else
        {
          return -1;
        }
    }
  else
    {
      return -1;
    }
}

TAO_PSDL_Stream & TAO_PSDL_Stream::operator<< ( const long  num  ) 

Definition at line 150 of file PSDL_Stream.cpp.

{
  ACE_OS::fprintf (this->fp_,
                   "%ld",
                   num);

  ACE_OS::fflush (this->fp_);
  return *this;
}

TAO_PSDL_Stream & TAO_PSDL_Stream::operator<< ( const unsigned long  num  ) 

Definition at line 138 of file PSDL_Stream.cpp.

{
  ACE_OS::fprintf (this->fp_,
                   "%lu",
                   num);

  ACE_OS::fflush (this->fp_);
  
  return *this;
}

TAO_PSDL_Stream & TAO_PSDL_Stream::operator<< ( ACE_CString  str  ) 

Definition at line 129 of file PSDL_Stream.cpp.

{
  ACE_OS::fprintf (this->fp_, "%s", str.c_str ());
  ACE_OS::fflush (this->fp_);
  
  return *this;
}

TAO_PSDL_Stream & TAO_PSDL_Stream::operator<< ( const char *  str  ) 

Definition at line 120 of file PSDL_Stream.cpp.

{
  ACE_OS::fprintf (this->fp_, "%s", str);
  ACE_OS::fflush (this->fp_);
  
  return *this;
}

int TAO_PSDL_Stream::print ( const char *  format,
  ... 
)

"printf" style variable argument print

int TAO_PSDL_Stream::reset ( void   ) 

reset indentation level to 0

Definition at line 87 of file PSDL_Stream.cpp.

{
  this->indent_level_ = 0;
  return 0;
}


Member Data Documentation

FILE* TAO_PSDL_Stream::fp_ [private]

Definition at line 81 of file PSDL_Stream.h.

Definition at line 84 of file PSDL_Stream.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines