nis-util  1.0.D108
Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes
space Class Reference

#include <space.h>

Inheritance diagram for space:
space_auto_master space_automap space_ethers space_hosts space_netgroup space_netid space_netmasks space_networks space_protocols space_services

Public Member Functions

virtual ~space ()
void error (const source_location &locn, const char *fmt,...) ATTRIBUTE_PRINTF(3
void const source_locationyak_location (void) const

Protected Types

enum  token_ty { token_eof, token_eoln, token_string }
typedef std::vector< rcstringline_t

Protected Member Functions

void discard_blank_lines (void)
void discard_comments (void)
void discard_backslash_newline (void)
rcstring get_file_name (void) const
void verror (const source_location &locn, const char *fmt, va_list) ATTRIBUTE_PRINTF(3
void space (const rcstring &filename)
void open (void)
void close (void)
bool read_one_line (line_t &result)
bool read_one_line (source_location &locn, line_t &result)
void warning (const source_location &locn, const char *fmt,...) ATTRIBUTE_PRINTF(3
void void vwarning (const source_location &locn, const char *fmt, va_list ap) ATTRIBUTE_PRINTF(3
void lex (void)
token_ty get_token (void) const
rcstring get_value (void) const
const source_locationget_location (void) const
void explain_sequence_errors (void)

Private Member Functions

int getch (void)
 space ()
 space (const space &)
spaceoperator= (const space &)

Private Attributes

rcstring filename
input::pointer ip
bool non_printing_whine
token_ty token
rcstring token_value
int error_count
bool discard_comments_flag
bool discard_blank_lines_flag
bool discard_backslash_newline_flag
source_location locn
bool current_line_is_blank
bool explained_sequence_errors

Detailed Description

The space class is used to represent the parse state when reading files who's rows contains space separared columns of values (/etc/hosts and the like).

Definition at line 34 of file space.h.


Member Typedef Documentation

typedef std::vector<rcstring> space::line_t [protected]

This is the type of lines returned by the get_one_line method.

Definition at line 133 of file space.h.


Member Enumeration Documentation

enum space::token_ty [protected]
Enumerator:
token_eof 
token_eoln 
token_string 

Definition at line 197 of file space.h.


Constructor & Destructor Documentation

space::~space ( ) [virtual]

The destructor.

Definition at line 36 of file space.cc.

space::space ( const rcstring filename) [protected]

The constructor. For use by derived classes only.

Definition at line 42 of file space.cc.

space::space ( ) [private]

The default constructor. Do not use.

space::space ( const space ) [private]

The copy constructor. Do not use.


Member Function Documentation

void space::close ( void  ) [protected]

The close method is used to close the input file, if it isn't closed already. If there were any errors, they are reported and the program will exitr.

Definition at line 70 of file space.cc.

void space::discard_backslash_newline ( void  ) [protected]

The discard_backslash_newline method is used to request that lines glued together by removing a backslash followed by a newline from the input sequence be presented as single logical lines.

Definition at line 326 of file space.cc.

void space::discard_blank_lines ( void  ) [protected]

The discard_blank_lines method is used to prevent blank lines being returned by the read_one_line method.

Definition at line 312 of file space.cc.

void space::discard_comments ( void  ) [protected]

The discard_comments method is used to prevent comments (starting with a '#' and lasting until the end of the line) being returned by the read_one_line method.

Definition at line 319 of file space.cc.

void space::error ( const source_location locn,
const char *  fmt,
  ... 
)

The error method is used to report fatal errors. The message is printed on the standard error, along with the file name and line number, and the error count incremented.

Parameters:
locnWhere the error occurred in the source file.
fmtThe text to be printed, also contains the number and types of the remaining arguments.

Definition at line 208 of file space.cc.

void space::explain_sequence_errors ( void  ) [protected]

The explain_sequence_errors method is used to explain why the file should be sorted, when an out-of-order error is issued. It is only ever issued once for each file.

Definition at line 333 of file space.cc.

rcstring space::get_file_name ( void  ) const [inline, protected]

The get_file_name method is used to obrtain the name of the file containing the map source.

Definition at line 94 of file space.h.

const source_location& space::get_location ( void  ) const [inline, protected]

The get_location method is used to obtain the source location of the most recent token returned by the lex method. This is used for error messages.

Note:
The value is undefined if the lex method has not yet been called.

Definition at line 229 of file space.h.

token_ty space::get_token ( void  ) const [inline, protected]

The get_token method is used to obtain the next input token from the input file. The file will be opened, if necessary.

Definition at line 208 of file space.h.

rcstring space::get_value ( void  ) const [inline, protected]

The get_value method is used to to obtain the value of the most recent token returned by the lex method.

Note:
The value is undefined if the token is not a token_string, or the lex method has not yet been called.

Definition at line 218 of file space.h.

int space::getch ( void  ) [private]

The getch method is used by lex to fetch the next character. If discard_commants has been called, it will discard all comments before returning.

Definition at line 90 of file space.cc.

void space::lex ( void  ) [protected]

Fetch the next input token. Sets the token instance variable, and also the token_value instance variable for strings.

Definition at line 110 of file space.cc.

void space::open ( void  ) [protected]

The open method is used to open the input file, if it isn't open already.

Definition at line 56 of file space.cc.

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

The assignment operator. Do not use.

bool space::read_one_line ( line_t result) [protected]

The get_one_line method is used to read one line from the file, splitting it into space-separated fields.

Parameters:
resultwhere to put the lien obce it is read in
Returns:
false at end-of-file.

Definition at line 246 of file space.cc.

bool space::read_one_line ( source_location locn,
line_t result 
) [protected]

The get_one_line method is used to read one line from the file, splitting it into space-separated fields.

Parameters:
resultwhere to put the lien obce it is read in
locnreturned as rthe source location of the first word on the first line.
Returns:
false at end-of-file.

Definition at line 254 of file space.cc.

void space::verror ( const source_location locn,
const char *  fmt,
va_list  ap 
) [protected]

The verror method is used to report fatal errors. The message is printed on the standard error, along with the file name and line number, and the error count incremented.

Parameters:
locnWhere the error occurred in the source file.
fmtThe text to be printed, and the number and types of the arguments
apthe remaining arguments.

Definition at line 184 of file space.cc.

void space::vwarning ( const source_location locn,
const char *  fmt,
va_list  ap 
) [protected]

The vwarning method is used to report non-fatal errors. The message is printed on the standard error, along with the file name and line number. The error count is NOT incremented.

Parameters:
locnWhere the error occurred in the source file.
fmtThe text to be printed
apthe values of the arguments

Definition at line 228 of file space.cc.

void space::warning ( const source_location locn,
const char *  fmt,
  ... 
) [protected]

The warning method is used to report non-fatal errors. The message is printed on the standard error, along with the file name and line number. The error count is NOT incremented.

Parameters:
locnWhere the error occurred in the source file.
fmtThe text to be printed, and the number and types of the arguments

Definition at line 218 of file space.cc.

void const source_location& space::yak_location ( void  ) const [inline]

The yak_location method is used to obtain the source file location of the most recent token returned by the yak_lex method. It would not be public except for the need for yacc (bison) to call it.

Reimplemented in space_auto_master.

Definition at line 63 of file space.h.


Field Documentation

The current_line_is_blank instance variable is used to remember whether or not the current line being parsed is blank or not. This is used by the lex method in combination with the discard_blank_lines_flag to determine the existence of blank source input lines.

Definition at line 324 of file space.h.

The discard_backslash_newline_flag instance variable is used to remember whether or not logival lines are to be lines glued together by removing a backslash followed by a newline from the input sequence.

Definition at line 308 of file space.h.

The discard_blank_lines_flag instance variable is used to remember whether or not to discard blank lines when they are seen in the source file. By default, blank lines are retained, and passed back to the caller of the get_token method.

Definition at line 300 of file space.h.

The discard_comments_flag instance variable is used to remember whether or not to discard comments (regex /#.*$/) when seen in the input file. By default, comments are not recognised.

Definition at line 292 of file space.h.

int space::error_count [private]

The error_count instance variable is used to remember how many fatal errors have been seen to date, when parsing the file. If this is non-zero, the close method will issue a fatal error message and exit failure.

Definition at line 285 of file space.h.

The explained_sequence_errors instance variable is used to remember whether or not we have explain what the sequence errors are for. This is used by the explain_sequence_errors method.

Definition at line 332 of file space.h.

The filename instance variable is used to remember the name of the file to be read.

Definition at line 250 of file space.h.

The ip instance variable is used to remember the input source, and its current read position. It is NULL if the file has yet to be opened.

Definition at line 257 of file space.h.

The locn instance variable is used to remember the source file location of the most recent token returned by the lex method.

Definition at line 315 of file space.h.

bool space::non_printing_whine [private]

The non_printing_whine instance variable is used to remember whether or not we have already complained about non-printing characters on the current input line.

Definition at line 264 of file space.h.

The token instance variable is used to remember the most recent token number of the most recent token, as determined by the lex method.

Definition at line 271 of file space.h.

The token_value instance variable is used to remember the value of most recent token, as determined by the lex method.

Definition at line 277 of file space.h.


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