Aegis  4.25.D505
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes
rfc822 Class Reference

#include <rfc822.h>

Public Member Functions

virtual ~rfc822 ()
 rfc822 ()
 rfc822 (const rfc822 &arg)
rfc822operator= (const rfc822 &arg)
void set (const nstring &name, const char *value)
void set (const nstring &name, const nstring &value)
void set_minimalist (const nstring &name, const nstring &value)
void set (const nstring &name, long value)
void set (const nstring &name, unsigned long value)
void set_off_t (const nstring &name, off_t value)
void set (const nstring &name, bool value)
bool is_set (const nstring &name) const
const nstringget (const nstring &name)
nstring get (const nstring &name) const
long get_long (const nstring &name)
unsigned long get_ulong (const nstring &name)
off_t get_off_t (const nstring &name)
void load (input &src, bool maybe_not=false)
void load_from_file (const nstring &filename)
void store (output::pointer dst)
void store_to_file (const nstring &filename)
bool empty () const
void keys (nstring_list &result)
void clear ()

Static Public Member Functions

static nstring date ()

Static Private Member Functions

static nstring sanitize_name (const nstring &name)

Private Attributes

symtab< nstringdatabase

Detailed Description

The rfc822 class is used to represent a database of name and values in RFC822 format. It ispossible to populate the database by reading the RFC822 header from a file, and the values can be stored by writing an RFC822 header to a file.

Definition at line 36 of file rfc822.h.


Constructor & Destructor Documentation

virtual rfc822::~rfc822 ( ) [virtual]

The destructor.

The default constructor.

rfc822::rfc822 ( const rfc822 arg)

The copy constructor.


Member Function Documentation

void rfc822::clear ( )

The clear method is used to discard all settings from the database.

static nstring rfc822::date ( ) [static]

The date class method is used to obtain the current date and time, conforming to RFC 822 format.

bool rfc822::empty ( void  ) const [inline]

The empty method is used to determine whether or not the database currently had no data.

Definition at line 261 of file rfc822.h.

const nstring& rfc822::get ( const nstring name)

The get method is used to get the named header value.

Parameters:
nameThe name of the record to get.
Returns:
A reference to the record's value. You are not allowed to change it. If the named record does not exist, the empty string will be returned.
nstring rfc822::get ( const nstring name) const

The get method is used to get the named header value.

Parameters:
nameThe name of the record to get.
Returns:
The record's value. If the named record does not exist, the empty string will be returned.
long rfc822::get_long ( const nstring name)

The get_long method is used to get the named header value, as an integer.

Parameters:
nameThe name of the record to get.
Returns:
The record's value.
Note:
Values which are not numbers will be silently converted to zero.
off_t rfc822::get_off_t ( const nstring name)

The get_off_t method is used to get the named header value, as an off_t.

Parameters:
nameThe name of the record to get.
Returns:
The record's value.
Note:
Values which are not numbers will be silently converted to zero.
unsigned long rfc822::get_ulong ( const nstring name)

The get_ulong method is used to get the named header value, as an unsigned long integer.

Parameters:
nameThe name of the record to get.
Returns:
The record's value.
Note:
Values which are not numbers will be silently converted to zero.
bool rfc822::is_set ( const nstring name) const

The is_set method is used to determine if a given header record has been set. (Note that even if the value is the empty string, it is still considered to have been set.)

Parameters:
nameThe name of the header record to test for.
void rfc822::keys ( nstring_list result) [inline]

The keys method is used to obtain the keys to the database.

Definition at line 272 of file rfc822.h.

void rfc822::load ( input src,
bool  maybe_not = false 
)

The load method is used to load the database contents by reading the given input for and RFC 822 formatted header. It stops after reading a blank line.

Parameters:
srcThe input to read the data from.
maybe_notfalse if a header must be present, true if it is acceptable for the header to be absent.
void rfc822::load_from_file ( const nstring filename)

The load_from_file method is used to load the database contents by reading from a file. Blank lines and # comments are ignored.

Parameters:
filenameThe input to read the data from.
rfc822& rfc822::operator= ( const rfc822 arg)

The assignment operator.

static nstring rfc822::sanitize_name ( const nstring name) [static, private]

The sanitize_name class method is used to normalize the name into lower case, with non-alpha-numberics turned into minus symbols. This is because RFC 822 header names are case-insensitive.

Parameters:
nameThe name to be sanitized.
void rfc822::set ( const nstring name,
const char *  value 
)

The set method is used to insert a record into the database.

Parameters:
nameThe name of the record to set.
valueThe value of the record being set.
void rfc822::set ( const nstring name,
const nstring value 
)

The set method is used to insert a record into the database.

Parameters:
nameThe name of the record to set.
valueThe value of the record being set.
void rfc822::set ( const nstring name,
long  value 
)

The set method is a convenience function which reformats the long value as a string, and then sets that value.

Parameters:
nameThe name of the record to set.
valueThe value of the record being set.
void rfc822::set ( const nstring name,
unsigned long  value 
)

The set method is a convenience function which reformats the unsigned long value as a string, and then sets that value.

Parameters:
nameThe name of the record to set.
valueThe value of the record being set.
void rfc822::set ( const nstring name,
bool  value 
)

The set method is a convenience function which reformats the bool value as a string, and then sets that value.

Parameters:
nameThe name of the record to set.
valueThe value of the record being set.
void rfc822::set_minimalist ( const nstring name,
const nstring value 
)

The set_minimalist method is used to insert a record into the database, but only is the value supplied is not empty. If the value is empty, and existing record will be removed.

Parameters:
nameThe name of the record to set.
valueThe value of the record being set.
void rfc822::set_off_t ( const nstring name,
off_t  value 
)

The set_off_t method is a convenience function which reformats the off_t value as a string, and then sets that value.

The name needs to be mention the type to avoid portability and compilation problems:

  • on 32 bit systems without LFS off_t is probably a long;
  • on 32 bit systems with LFS off_t is probably a long long;
  • on 64 bit systems off_t is probably a long again.
Parameters:
nameThe name of the record to set.
valueThe value of the record being set.

The store method is used to dump the database out as an RFC 822 compliant header, followed by a single blank line.

Parameters:
dstThe output stream on which to write the data.
void rfc822::store_to_file ( const nstring filename)

The store_to_file method is used to dump the database to a file. It calls the strore method to do all the work.

Parameters:
filenameThe filename into which to write the data.

Field Documentation

The database instance variable is used to remeber the name-value pairs for each header item.

Definition at line 284 of file rfc822.h.


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