input_ty Class Reference

#include <input.h>

Inheritance diagram for input_ty:

input_822wrap input_base64 input_bunzip2 input_catenate input_cpio input_crlf input_crop input_curl input_env input_file input_gunzip input_null input_quoted_printable input_stdin input_string input_svt_checkout input_uudecode input_verify_checksum

Public Member Functions

virtual ~input_ty ()
 input_ty ()
long read (void *data, size_t nbytes)
void read_strictest (void *data, size_t size)
bool read_strict (void *data, size_t size)
void skip (size_t size)
void fatal_error (const char *msg)
bool one_line (nstring &result)
long ftell ()
virtual nstring name ()=0
virtual long length ()=0
int getch ()
void ungetc (int c)
int peek ()
virtual void keepalive ()
void pushback_transfer (input &from)
void pullback_transfer (input_ty *to)
void pullback_transfer (input &to)
void unread (const void *data, size_t nbytes)
bool at_end ()
virtual bool is_remote () const
void reference_count_up ()
void reference_count_down ()
bool reference_count_valid () const

Protected Member Functions

virtual long read_inner (void *data, size_t nbytes)=0
virtual long ftell_inner ()=0
int getc_complicated ()
void ungetc_complicated (int c)

Private Attributes

long reference_count
unsigned char * buffer
size_t buffer_size
unsigned char * buffer_position
unsigned char * buffer_end

Detailed Description

The input_ty abstract class represent a generic input source.

Definition at line 31 of file input.h.


Constructor & Destructor Documentation

virtual input_ty::~input_ty (  )  [virtual]

The destructor is used to close the given input, and delete all resources associated with it. Once this returns, the given input is no longer available for *any* use. (Think of this method as "close" if it helps.)

input_ty::input_ty (  ) 

The default constructor.


Member Function Documentation

long input_ty::read ( void *  data,
size_t  nbytes 
)

The read method is used to read buffered data from the given input stream. At most size bytes will be read into buffer. The number of bytes actually read will be returned. At end-of-file, a value <=0 will be returned, and buffer will be unchanged. All file read errors or format errors are fatal, and will cause the method to not return.

Parameters:
data Where to put the results of the read.
nbytes The maximum number of bytes to read.
Returns:
The actual number of bytes read, or zero for end-of-file.

void input_ty::read_strictest ( void *  data,
size_t  size 
)

The read_strictest method is used to read data from the given input stream. Exactly size bytes will be read into buffer. If there are less than size bytes available, a fatal error will result.

Parameters:
data Where to put the results of the read.
size The number of bytes to read.

bool input_ty::read_strict ( void *  data,
size_t  size 
)

The read_strict method is used to read data from the given input stream. Exactly size bytes will be read into buffer, or zero bytes at end-of-file. If there are less than size bytes available, a fatal error will result.

Parameters:
data Where to put the results of the read.
size The number of bytes to read.
Returns:
bool; true if data was read, false if end-of-file

void input_ty::skip ( size_t  size  ) 

The skip method is used to read data from the given input stream and discard it. Exactly size bytes will be read. If there are less than size bytes available, a fatal error will result.

Parameters:
size The number of bytes to discard.

void input_ty::fatal_error ( const char *  msg  ) 

The fatal_error method is used to report a fatal error on an input stream. This method does not return.

bool input_ty::one_line ( nstring result  ) 

The one_line method is used to read one line from the input (up to the next newline character or end of input).

Parameters:
result Where the text is stored. The newline is not included in the returned string.
Returns:
bool; true if any text was read, false if end-of-file is reached.

long input_ty::ftell (  ) 

The ftell method is used to determine the current buffered data position within the input.

virtual nstring input_ty::name (  )  [pure virtual]

virtual long input_ty::length (  )  [pure virtual]

int input_ty::getch (  )  [inline]

The getch method is used to get the next character from the input. Returns a value<=0 at end-of-file.

Definition at line 143 of file input.h.

void input_ty::ungetc ( int  c  )  [inline]

The ungetc method is used to push back a character of input. Think of it as undoing the effects of the getch method.

Definition at line 155 of file input.h.

int input_ty::peek (  )  [inline]

The peek method is used to obtain the value of the next input character, without advancing the read position.

Returns:
the next character, or -1 if the end of file has been reached.

Definition at line 174 of file input.h.

virtual void input_ty::keepalive (  )  [virtual]

The keepalive method is used to set the SO_KEEPALIVE socket option, if the file is a socket. Does nothing otherwise.

Reimplemented in input_822wrap, input_base64, input_bunzip2, input_catenate, input_crlf, input_crop, input_file, input_gunzip, input_quoted_printable, input_stdin, and input_uudecode.

void input_ty::pushback_transfer ( input from  ) 

The pushback_transfer method is used by input filter classes' destructors to return unused buffeered input.

void input_ty::pullback_transfer ( input_ty to  ) 

The pullback_transfer method is used by input filter classes' destructors to return unused buffeered input.

void input_ty::pullback_transfer ( input to  ) 

The pullback_transfer method is used by input filter classes' destructors to return unused buffeered input.

void input_ty::unread ( const void *  data,
size_t  nbytes 
)

The unread method may be used to reverse the effects of the read method. The data is pushed into the buffer. Think of it as a whole bunhs of ungetc calls (backwards).

Parameters:
data The base of the array of bytes to be returned.
nbytes The number of bytes to be returned.

bool input_ty::at_end (  ) 

The at_end method is used to determine whether or not this input stream is at the end of input.

virtual bool input_ty::is_remote (  )  const [virtual]

The is_remote method is used to determine whether or not an input stream is from a local file or a remote source. This is only intended to be a generally informative thing, to provide information to the user, it isn't (and can't be) utterly precise.

Reimplemented in input_822wrap, input_base64, input_bunzip2, input_catenate, input_cpio, input_crlf, input_crop, input_curl, input_gunzip, input_quoted_printable, input_uudecode, and input_verify_checksum.

void input_ty::reference_count_up (  ) 

void input_ty::reference_count_down (  ) 

bool input_ty::reference_count_valid (  )  const [inline]

Definition at line 234 of file input.h.

virtual long input_ty::read_inner ( void *  data,
size_t  nbytes 
) [protected, pure virtual]

The read_inner method is used to read unbuffered data from the given input stream. At most nbytes bytes will be read into data. The number of bytes actually read will be returned. At end-of-file, a value <= 0 will be returned, and data will be unchanged. All file read errors or format errors are fatal, and will cause the method to not return.

Parameters:
data Where to put the results of the read.
nbytes The maximum number of bytes to read.
Returns:
The actual number of bytes read, or zero for end-of-file.

Implemented in input_822wrap, input_base64, input_bunzip2, input_catenate, input_cpio, input_crlf, input_crop, input_curl, input_env, input_file, input_gunzip, input_null, input_quoted_printable, input_stdin, input_string, input_svt_checkout, input_uudecode, and input_verify_checksum.

virtual long input_ty::ftell_inner (  )  [protected, pure virtual]

int input_ty::getc_complicated (  )  [protected]

The getc_complicated method is used to get a character from the input. Usually users do not call this method directly, but use the getch method instead.

void input_ty::ungetc_complicated ( int  c  )  [protected]

The ungetc_complicated method is used to push a character back onto an input. Usually users do not call this method directly, but use the input_ungetc macro instead.


Field Documentation

long input_ty::reference_count [private]

Definition at line 275 of file input.h.

unsigned char* input_ty::buffer [private]

The buffer instance variable is used to remember the base of a dynamically allocated array used to buffer the data for buffered input.

Definition at line 282 of file input.h.

size_t input_ty::buffer_size [private]

The buffer_size instance variable is used to remember the allocation size of the dynamically allocated buffer.

Definition at line 288 of file input.h.

unsigned char* input_ty::buffer_position [private]

The buffer_position instance variable is used to remember the read position of the data within the buffer.

Definition at line 294 of file input.h.

unsigned char* input_ty::buffer_end [private]

The buffer_end instance variable is used to remember the highwater mark of data stored in the buffer.

Definition at line 300 of file input.h.


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

Generated on Wed Mar 12 23:37:40 2008 for Aegis by  doxygen 1.5.5