nis-util
1.0.D108
|
#include <input.h>
Public Types | |
typedef boost::shared_ptr< input > | pointer |
Public Member Functions | |
virtual | ~input () |
int | get (void) |
void | unget (int c) |
source_location | get_source_location (void) |
bool | read_one_line (source_location &line_locn, rcstring &line) |
Static Public Attributes | |
static const int | eof = -1 |
Protected Member Functions | |
input () | |
Static Protected Member Functions | |
static int | count_newlines (const void *data, size_t data_size) |
Private Member Functions | |
int | underflow (void) |
virtual size_t | read_inner (source_location &data_locn, void *data, size_t data_size)=0 |
void | refill (void) |
input (const input &rhs) | |
input & | operator= (const input &rhs) |
Private Attributes | |
unsigned char * | buf |
size_t | buf_allocated |
size_t | pos |
size_t | avail |
long | relative_line_number |
source_location | buf_locn |
The input abstratc base class is used to represent any kind of input. It could be a file, or a string, or anything else.
typedef boost::shared_ptr<input> input::pointer |
input::~input | ( | ) | [virtual] |
input::input | ( | ) | [protected] |
input::input | ( | const input & | rhs | ) | [private] |
The copy constructor. Do not use.
rhs | The right hand side of the initialization. |
int input::count_newlines | ( | const void * | data, |
size_t | data_size | ||
) | [static, protected] |
int input::get | ( | void | ) | [inline] |
The get method is used to obtain a single byte from the input source.
The assignment operator. Do not use.
rhs | The right hand side of the assignment. |
virtual size_t input::read_inner | ( | source_location & | data_locn, |
void * | data, | ||
size_t | data_size | ||
) | [private, pure virtual] |
The read_inner method is called byu the underflow method to fill the buffer buf with more data.
data_locn | The location of the beginning of the returned data. It is the first argument because it's position is immediately before the returned data. |
data | pointer to the base of an array to receive the data |
data_size | the maximum number of bytes of data than can be received into the data array. |
Implemented in input_remove_hash_comments, input_string, input_file, input_stdin, input_null, and input_remove_escaped_newlines.
bool input::read_one_line | ( | source_location & | line_locn, |
rcstring & | line | ||
) |
void input::refill | ( | void | ) | [private] |
int input::underflow | ( | void | ) | [private] |
The underflow method is used by the get method to fill the buffer when it runs out. It uses the read_inner method for this.
void input::unget | ( | int | c | ) |
The unget method is sued to return a byte to the input, taking precedence over the data in the buf array. May be called more than once.
c | The byte to be returned. The input::eof value will be ignored (meaning, returning end-of-file.) |
size_t input::avail [private] |
unsigned char* input::buf [private] |
size_t input::buf_allocated [private] |
source_location input::buf_locn [private] |
The buf_locn instance variable is used to remember the source file location of the beginning of the most recently read data from the read_inner method. The relative_line_number is added to it to form the value returned by the get_source_location method.
const int input::eof = -1 [static] |
The input::eof constant is used to represent the eof of input, or end of file, when reading byte-at-a-time through the get method.
size_t input::pos [private] |
long input::relative_line_number [private] |
The relative_line_number instance variable is used to remember the line number of the next byte to be returned by the get method, relative to the buf_locn instance variable, populated by the most recent call to the read_inner method.