RecordFieldId.h

Classes

RecordFieldId -- The identification of a record field. (full description)

class RecordFieldId

Interface

Public Members
RecordFieldId (Int fieldNumber)
RecordFieldId (const String& name)
RecordFieldId (const std::string& name)
RecordFieldId (const Char* name)
Int fieldNumber() const
const String& fieldName() const
Bool byName() const

Description

Review Status

Reviewed By:
Mark Wieringa
Date Reviewed:
1996/04/15
Programs:
Tests:

Prerequisite

Etymology

RecordFieldId gives the identification of a field in a record.

Synopsis

This class provides the user to identify a field in a record. Identification can be done by means of the field name or by means of its field number.
For the programmer the most convenient way is probably the name, because that is the natural identification. However, identification by means of field number is much faster and could be used when it is known.

Example

    void someFunc (const Record& record)
    {
        float value1 = record.asfloat ("name");     // identify by name
        float value2 = record.asfloat (0);          // identify by number
    }
    

Motivation

This class makes it possible that many functions in Record classes have to be defined only once. The constructors of RecordFieldId make it possible that a number and a string are automatically converted, so the user does not have to instantiate a RecordFieldId object explicitly.

Member Description

RecordFieldId (Int fieldNumber)

Construct it from a field number.

RecordFieldId (const String& name)
RecordFieldId (const std::string& name)
RecordFieldId (const Char* name)

Construct it from a field name.

Int fieldNumber() const

Get the field number.

const String& fieldName() const

Get the field name.

Bool byName() const

Is the id given by name?