output Class Reference

#include <output.h>

Inheritance diagram for output:

output_file output_gzip output_null output_stdout output_string

List of all members.

Public Types

typedef
boost::shared_ptr
< output
pointer

Public Member Functions

virtual ~output ()
void putch (char c)
void putch (signed char c)
void putch (unsigned char c)
void puts (const char *s)
void puts (const rcstring &s)
void write (const void *data, size_t nbytes)
void flush ()
void printf (const char *fmt,...)
virtual bool start_of_line () const
void put (input::pointer from)
virtual rcstring name ()=0
void put_long_le (unsigned long x)
void spaces (int n)

Protected Member Functions

 output ()
virtual void write_inner (const void *data, size_t nbytes)=0
virtual size_t get_block_size ()
virtual bool start_of_line_inner () const =0
virtual void fatal_error (const char *fmt,...)
virtual void fatal_error_v (const char *fmt, va_list args)
virtual void fatal_error_with_errno (const char *fmt,...)
virtual void fatal_error_with_errno_v (const char *fmt, va_list args)

Private Member Functions

void overflow (unsigned char c)
 output (const output &)
outputoperator= (const output &)

Private Attributes

unsigned char * buffer
size_t position
size_t maximum


Detailed Description

The output class is used to represent an abstract output destination. It could be a file, or a string or something more interesting.

Definition at line 34 of file output.h.


Member Typedef Documentation

typedef boost::shared_ptr<output> output::pointer

Definition at line 37 of file output.h.


Constructor & Destructor Documentation

virtual output::~output (  )  [virtual]

The destructor.

output::output (  )  [protected]

The default constructor.

output::output ( const output  )  [private]

The copy constructor. Do not use.


Member Function Documentation

void output::putch ( char  c  )  [inline]

The putch method is used to write a character to the output.

Parameters:
c The character to write.

Definition at line 57 of file output.h.

Referenced by putch().

void output::putch ( signed char  c  )  [inline]

The putch method is ised to write a character to the output.

Parameters:
c The character to write.

Definition at line 65 of file output.h.

References putch().

void output::putch ( unsigned char  c  )  [inline]

The putch method is ised to write a character to the output.

Parameters:
c The character to write.
Note:
All of these output class buffer their output. It lowers the total number of function calls per character quite dramatically.

Definition at line 78 of file output.h.

References buffer, maximum, overflow(), and position.

void output::puts ( const char *  s  ) 

The puts method is used to write a NUL-terminated string to the output.

void output::puts ( const rcstring s  ) 

The puts method is used to write a reference counted string to the output.

void output::write ( const void *  data,
size_t  nbytes 
)

The write method is used to write arbitrary data to the output.

Parameters:
data The data to write.
nbytes The home much data to write.

void output::flush (  ) 

The flush method is used to ensure that all the buffered data has been written to the actual output.

Referenced by output_string::clear(), and output_string::mkstr().

void output::printf ( const char *  fmt,
  ... 
)

The printf method is used to print formatted text to the output strteam. See printf(3) for more information about the arguments.

Parameters:
fmt The format string which describes the following arguments, and how to format them.

virtual bool output::start_of_line (  )  const [virtual]

The start_of_line method may be used to determine whether the output is currently positioned at the start of a line. This can be useful when trying to determine of a Unix text file needs to have its terminating newline appended.

Returns:
boolean; true if currently positionad at the start of a line, false if currentl;y position within an output line.

void output::put ( input::pointer  from  ) 

The put method is used to copy an input to an output.

Parameters:
from Where the input comes from.

virtual rcstring output::name (  )  [pure virtual]

The name method may be used to obtain the name of the output file being written.

Implemented in output_file, output_gzip, output_null, output_stdout, and output_string.

void output::put_long_le ( unsigned long  x  ) 

The put_long_le is used to write a four byte long value to the output stream in little endian format (least significant byte first).

Parameters:
x The value to be written to the output.

void output::spaces ( int  n  ) 

The spaces method is used to emit the given number of space characters into the output.

virtual void output::write_inner ( const void *  data,
size_t  nbytes 
) [protected, pure virtual]

The write inner method is used to write the buffered data out to the underlying implemnattion. This method must be supplied by each derived class.

Parameters:
data The data to write.
nbytes The home much data to write.

Implemented in output_file, output_gzip, output_null, output_stdout, and output_string.

virtual size_t output::get_block_size (  )  [protected, virtual]

The get_buffer_size method is used to obtain the preferred buffer size of output. This is not called from the base class destructor, but is deferred until the first data is written to the output.

This defaults to 1024, which isn't too bad for sockets, but is not ideal for files.

Reimplemented in output_file.

virtual bool output::start_of_line_inner (  )  const [protected, pure virtual]

The start_of_line_inner method is called by the start_of_line method in the rare cases where it cannot determine the output state for itself.

Returns:
boolean; true if currently positionad at the start of a line, false if currentl;y position within an output line.

Implemented in output_file, output_gzip, output_null, output_stdout, and output_string.

virtual void output::fatal_error ( const char *  fmt,
  ... 
) [protected, virtual]

The fatal_error method is used to report fatal errors. The `fmt' string is in the same style a standard C printf function. It calls the fatal_error_v method. This method does not return.

Parameters:
fmt The format string which describes the following arguments, and how to format them.

virtual void output::fatal_error_v ( const char *  fmt,
va_list  args 
) [protected, virtual]

The fatal_error_v method is used to report fatal errors. The `fmt' string is in the same style a standard C vprintf function. It calls the message_v and exit methods. This method does not return.

Parameters:
fmt The format string which describes the following arguments, and how to format them.
args Variable argument lsit, controlled by the fmt argument.

virtual void output::fatal_error_with_errno ( const char *  fmt,
  ... 
) [protected, virtual]

The fatal_error_errno method is used to report fatal errors, and append the string equivalent of errno. The `fmt' string is in the same style a standard C printf function. It calls the fatal_error_errno_v method. This method does not return.

Parameters:
fmt The format string which describes the following arguments, and how to format them.

virtual void output::fatal_error_with_errno_v ( const char *  fmt,
va_list  args 
) [protected, virtual]

The fatal_error_errno_v method is used to report fatal errors. The `fmt' string is in the same style a standard C vprintf function. It calls the message_v and exit methods. This method does not return.

Parameters:
fmt The format string which describes the following arguments, and how to format them.
args Variable argument lsit, controlled by the fmt argument.

void output::overflow ( unsigned char  c  )  [private]

The overflow method is called by the putch method when there is not enough space left in the buffer to store another character.

Parameters:
c The character to be written to the output.

Referenced by putch().

output& output::operator= ( const output  )  [private]

The assignment operator. Do not use.


Member Data Documentation

unsigned char* output::buffer [private]

The buffer instance variable is used to remember the address of a dynamically allocated array of characters to buffer the output.

Definition at line 259 of file output.h.

Referenced by putch().

size_t output::position [private]

The position instance variable is used to remember the current output position (high water) within the buffer.

Definition at line 265 of file output.h.

Referenced by putch().

size_t output::maximum [private]

The maximum instance variable is used to remember how many bytes have been allocated in the buffer.

Definition at line 271 of file output.h.

Referenced by putch().


The documentation for this class was generated from the following file:
Generated on Thu Dec 13 16:26:59 2007 for Icon-Compositor by  doxygen 1.5.3