JWS C++ Library
C++ language utility library
jwscxx::base::Readable Class Reference

Abstract class to read this object from an input stream. More...

#include <readable.h>

Inheritance diagram for jwscxx::base::Readable:

List of all members.

Public Member Functions

virtual ~Readable ()
 Deletes this Readable.
virtual void read (std::istream &in)=0 throw (jwscxx::base::IO_error, jwscxx::base::Arg_error)
 Reads this Readable from an input stream.
virtual void read (const char *fname) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error)
 Reads this Readable from a file.

Static Public Member Functions

static const char * read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':') throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)
 Reads a line off in into a buffer and returns a pointer to the field value in the buffer.
static const char * read_field_value (std::istream &in, const char *field_name, char separator=':') throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)
 Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer.

Detailed Description

Abstract class to read this object from an input stream.

Definition at line 66 of file readable.h.


Constructor & Destructor Documentation

virtual jwscxx::base::Readable::~Readable ( ) [inline, virtual]

Deletes this Readable.

Definition at line 71 of file readable.h.


Member Function Documentation

void Readable::read ( const char *  fname) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) [virtual]

Reads this Readable from a file.

Parameters:
fnameInput file to read from.
Exceptions:
jwscxx::base::IO_errorCould not read from fname.
jwscxx::base::Arg_errorInvalid arguments in the file to read from.

Definition at line 71 of file readable.cpp.

const char * Readable::read_field_value ( std::istream &  in,
const char *  field_name,
char *  field_buf,
size_t  buf_len,
char  separator = ':' 
) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) [static]

Reads a line off in into a buffer and returns a pointer to the field value in the buffer.

Reads a line off the input stream as a field with format:

   field name: field value

Where the separator here is a ':'.

Parameters:
inInput stream to read the field line from.
field_nameName of the field to get the value of.
field_bufBuffer to read the line of input into.
buf_lenLength of the buffer.
separatorCharacter separating the field name and value. The default is ':'.
Exceptions:
jwscxx::base::Arg_errorEither the field is not the one named or it is not formatted properly.
jwscxx::base::IO_errorCould not read a line from the input stream.
Returns:
A constant pointer into field_buf where the field value is or 0 if there is no value.
Note:
A terminating character '\0' is always inserted in the buffer, even if it would truncate the line.

Definition at line 130 of file readable.cpp.

const char * Readable::read_field_value ( std::istream &  in,
const char *  field_name,
char  separator = ':' 
) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) [static]

Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer.

Reads a line off the input stream as a field with format:

   field name: field value

Where the separator here is a ':'.

Parameters:
inInput stream to read the field line from.
field_nameName of the field to get the value of.
separatorCharacter separating the field name and value. The default is ':'.
Exceptions:
jwscxx::base::Arg_errorEither the field is not the one named or it is not formatted properly.
jwscxx::base::IO_errorCould not read a line from the input stream.
Returns:
A constant pointer to the field value or 0 if there is no value.
Note:
The buffer for reading a field value is shared, so each time the function is called, it will be overwritten.
The maximum line length to read is 255.

Definition at line 217 of file readable.cpp.


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