cons.hpp File Reference

#include <iostream>
#include "Cell.hpp"

Go to the source code of this file.

Namespaces

namespace  std

Functions

Cell * make_int (const int i)
 Make an int cell.
Cell * make_double (const double d)
 Make a double cell.
Cell * make_string (const char *const s)
 Make a string cell.
Cell * make_symbol (const char *const s)
 Make a symbol cell.
Cell * cons (Cell *const my_car, Cell *const my_cdr)
 Make a conspair cell.
bool intp (Cell *const c)
 Check if c is an int cell.
bool doublep (Cell *const c)
 Check if c is a double cell.
bool stringp (Cell *const c)
 Check if c is a string cell.
bool symbolp (Cell *const c)
 Check if c is a symbol cell.
bool listp (Cell *const c)
 Check if c is a cons cell.
int get_int (Cell *const c)
 Accessor (error if c is not an int cell).
double get_double (Cell *const c)
 Accessor (error if c is not a double cell).
string get_string (Cell *const c)
 Accessor (error if c is not a string cell).
string symbol_to_string (Cell *const c)
 Retrieve the symbol name as a string (error if c is not a symbol cell).
Cell * car (Cell *const c)
 Accessor (error if c is not a cons cell).
Cell * cdr (Cell *const c)
 Accessor (error if c is not a string cell).
ostream & operator<< (ostream &os, const Cell &c)
 Print the subtree rooted at c, in s-expression notation.


Detailed Description

Encapsulates an abstract interface layer for a cons list ADT, without using member functions. Makes no assumptions about what kind of concrete type Cell will be defined to be.

Function Documentation

Cell* car Cell *const   c  )  [inline]
 

Accessor (error if c is not a cons cell).

Returns:
The car pointer in the cons cell pointed to by c.

Cell* cdr Cell *const   c  )  [inline]
 

Accessor (error if c is not a string cell).

Returns:
The cdr pointer in the cons cell pointed to by c.

Cell* cons Cell *const   my_car,
Cell *const   my_cdr
[inline]
 

Make a conspair cell.

Parameters:
my_car The initial car pointer to be stored in the new cell.
my_cdr The initial cdr pointer to be stored in the new cell.

bool doublep Cell *const   c  )  [inline]
 

Check if c is a double cell.

Returns:
True iff c is a double cell.

double get_double Cell *const   c  )  [inline]
 

Accessor (error if c is not a double cell).

Returns:
The value in the double cell pointed to by c.

int get_int Cell *const   c  )  [inline]
 

Accessor (error if c is not an int cell).

Returns:
The value in the int cell pointed to by c.

string get_string Cell *const   c  )  [inline]
 

Accessor (error if c is not a string cell).

Returns:
The value in the string cell pointed to by c.

bool intp Cell *const   c  )  [inline]
 

Check if c is an int cell.

Returns:
True iff c is an int cell.

bool listp Cell *const   c  )  [inline]
 

Check if c is a cons cell.

Returns:
True iff c is a cons cell.

Cell* make_double const double  d  )  [inline]
 

Make a double cell.

Parameters:
d The initial double value to be stored in the new cell.

Cell* make_int const int  i  )  [inline]
 

Make an int cell.

Parameters:
i The initial int value to be stored in the new cell.

Cell* make_string const char *const   s  )  [inline]
 

Make a string cell.

Parameters:
s The initial symbol value to be stored in the new cell.

Cell* make_symbol const char *const   s  )  [inline]
 

Make a symbol cell.

Parameters:
s The initial symbol name to be stored in the new cell.

ostream& operator<< ostream &  os,
const Cell &  c
[inline]
 

Print the subtree rooted at c, in s-expression notation.

Parameters:
os The output stream to print to.
c The root cell of the subtree to be printed.

bool stringp Cell *const   c  )  [inline]
 

Check if c is a string cell.

Returns:
True iff c is a string cell.

string symbol_to_string Cell *const   c  )  [inline]
 

Retrieve the symbol name as a string (error if c is not a symbol cell).

Returns:
The symbol name in the symbol cell pointed to by c.

bool symbolp Cell *const   c  )  [inline]
 

Check if c is a symbol cell.

Returns:
True iff c is a symbol cell.


Generated on Mon May 1 09:56:47 2006 for a2 by  doxygen 1.4.6