BIE::RecordType Class Reference

Record Types define a set of (name, type) pairs like a C-struct declaration. More...

#include <RecordType.h>

Inheritance diagram for BIE::RecordType:
Collaboration diagram for BIE::RecordType:

List of all members.

Public Types

typedef struct
BIE::RecordType::field 
fieldstruct
 This structure holds pairs of fieldname and fieldtype pairs.

Public Member Functions

 RecordType ()
 Creates an empty record type.
 RecordType (RecordType *recordtypetocopy)
 Creates an exact copy of an existing record type object.
 RecordType (const fieldstruct *typetable)
 Create a type from a null terminiated array of fieldstructs.
 RecordType (istream *istrm)
 Creates a record type by reading from the stream.
RecordTypedeleteField (string fieldname)
 Delete a single field using field name.
RecordTypedeleteField (int v)
 Delete a single field using field index.
RecordTypedeleteRange (int lowfieldindex, int highfieldindex)
 Deletes a range of fields.
RecordTypeinsertField (int insertpos, string fieldname, BasicType *fieldtype)
 Inserts a new field.
RecordTypeinsertRecord (int position, RecordType *insertRecord)
 Inserts another record type.
RecordTypeunionWithRecord (RecordType *insertrec)
 Constructs a union of the two types by adding fields from the argument not already in the type instance this method is invoked on.
RecordTypeselectFields (vector< int > *selection)
 Constructs a new record type by selecting the fields specified in the vector on field indices.
RecordTypeselectFields (vector< string > *selection)
 Constructs a new record type by selecting the fields specified in the vector of names.
RecordTyperenameField (string oldname, string newname)
 Renames the field specified by the first argument to the name in the second argument.
RecordTyperenameField (int fieldindex, string newname)
 Renames the field specified by the first argument to the name in the second argument.
RecordTypemoveField (string fieldname, int newposition)
 Moves a field (specified by name) to a new position (specified by index) and "slides" the fields in between to fill in the vacated position.
RecordTypemoveField (int oldposition, int newposition)
 Moves a field (specified by index) to a new position (specified by index) and "slides" the fields in between to fill in the vacated position.
int getFieldIndex (string fieldname)
 Get the field number from a field name.
string getFieldName (int fieldindex)
 Get the name of a field from a field number.
bool isValidFieldIndex (int fieldindex)
 Says whether the field index is legal for this type.
bool isValidFieldName (string fieldname)
 Says whether a field with this name exists in the type.
BasicTypegetFieldType (int fieldindex)
 Get the type of a field specified by index.
BasicTypegetFieldType (string fieldindex)
 Get the type of a field specified by name.
int numFields ()
 Returns the total number of fields in the type.
bool equals (RecordType *)
 Type equality -- both types must have the same (name,type) pairs.
bool orderedEquals (RecordType *)
 Ordered equality -- both types must have the same (name, type) pairs, and the fields must be in the same order.
bool isSubset (RecordType *)
 Is the argument a subset of the existing type? No equality of order implied.
bool isPrefix (RecordType *)
 Type inclusion -- prefix.
string createHeaderForStream ()
 Returns a string representation of the type.
string toString ()
 Returns a string representation of the type.

Static Public Member Functions

static int getLength (AsciiLexer *lxr)
 Get the length of the current token.

Friends

class boost::serialization::access

Classes

struct  field
 This structure holds pairs of fieldname and fieldtype pairs. More...


Detailed Description

Record Types define a set of (name, type) pairs like a C-struct declaration.

All names in a record type are distinct, and all pairs are ordered. This means that referring to a field makes sense whether by name or by field index number. Field indices begin at 1, not 0.

All RecordType objects are immutable: methods for creating new record types do not modify the existing object and return completely new record type objects. In CLI, this means you have to use commands in the following manner so that you get the new object:

set rt = new RecordType set rt = rt->insertField(1, "fieldone", int); set rt = rt->insertField(2, "fieldtwo", string);


Member Typedef Documentation

This structure holds pairs of fieldname and fieldtype pairs.

Arrays of these structures can be used to construct record types.


Constructor & Destructor Documentation

BIE::RecordType::RecordType ( RecordType recordtypetocopy  ) 

Creates an exact copy of an existing record type object.

Parameters:
recordtypetocopy The existing record type that this new record type should copy values from.


Member Function Documentation

RecordType* BIE::RecordType::deleteField ( string  fieldname  ) 

Delete a single field using field name.

Parameters:
fieldname Name of the field to delete.

RecordType* BIE::RecordType::deleteField ( int  v  ) 

Delete a single field using field index.

The value

Parameters:
v is the index of the field to delete.

RecordType* BIE::RecordType::deleteRange ( int  lowfieldindex,
int  highfieldindex 
)

Deletes a range of fields.

All fields in this range including those used to specify the boundary are deleted.

Parameters:
lowfieldindex Lower bound of range.
highfieldindex Upper bound of range.

RecordType* BIE::RecordType::insertField ( int  insertpos,
string  fieldname,
BasicType fieldtype 
)

Inserts a new field.

Can be used to append fields by inserting at position (n+1). If a field with the given name already exists then the exception NameClashException is thrown. Where the specified insertion point is not in the range 1 to (n+1) then NoSuchFieldException is thrown.

Parameters:
insertpos Field index where field should be inserted.
fieldname Name of the new field.
fieldtype Type of the new field (all kinds of BasicType are available as constants in CLI.)

RecordType* BIE::RecordType::insertRecord ( int  position,
RecordType insertRecord 
)

Inserts another record type.

Can be used to append by inserting at position (n+1). If any fields in the record being inserted clash names with existing fields then the exception NameClashException is thrown. Where the specified insertion point is not in the range 1 to (n+1) then NoSuchFieldException is thrown.

RecordType* BIE::RecordType::unionWithRecord ( RecordType insertrec  ) 

Constructs a union of the two types by adding fields from the argument not already in the type instance this method is invoked on.

A TypeException is thrown if there is a field in both types with the same name but different type.

RecordType* BIE::RecordType::selectFields ( vector< int > *  selection  ) 

Constructs a new record type by selecting the fields specified in the vector on field indices.

No duplicate fields are allowed, and all fields must be present in the existing object.

RecordType* BIE::RecordType::selectFields ( vector< string > *  selection  ) 

Constructs a new record type by selecting the fields specified in the vector of names.

No duplicate fields are allowed, and all fields must be present in the existing object.

bool BIE::RecordType::equals ( RecordType  ) 

Type equality -- both types must have the same (name,type) pairs.

Fields need not be in the same order.

bool BIE::RecordType::isSubset ( RecordType  ) 

Is the argument a subset of the existing type? No equality of order implied.


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

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:13 2010 by doxygen