Classes of GRP Parser defined in pobj.h

Class index

TObject
TCollection
TSortedCollection
TStringCollection
TUnsortedStrings

TObject

TObject

Method index of TObject

TObject
~TObject
Init

Methods

TObject(void)

Constructor of the base class.

virtual ~TObject(void)

Destructor of the base class.

virtual int Init(void)

Initialization of the base class. It must be called after constructor immediately when a new object is instantiated. When no error occured during this function it returns 0.

TCollection

TObject
   |
   +------TCollection

Method index of TCollection

TCollection
~TCollection
*At
IndexOf
index_of
GetCount
Pack
SetLimit
AtFree
AtDelete
Delete
DeleteAll
AtInsert
AtPut
Insert
*FirstThat
*LastThat
ForEach
Error

Methods

TCollection(TIndex ALimit, TIndex ADelta)

Constructor of the collection class. It prepares room for ALimit items. If more items insterted into the collection it will extend the collection with allocating room for more ADelta items.

virtual ~TCollection(void)

Destructor of the collection class. It disposes every items stored in the collection.

void *At(TIndex index)

This function returns address of item stored in the collection at position specified by index parameter.

virtual TIndex IndexOf(void *Item)

This method returns index of Item item. If this item is not stored in the collection then Error method is called.

virtual TIndex index_of(void *Item)

This method returns index of Item item. If this item is not stored in the collection then -1 returned.

int GetCount(void)

This function can be used to find out how many items are stored in the collection.

void Pack(void)

???

virtual void SetLimit(TIndex ALimit)

This method changes the size of the collection. [???]

void AtFree(TIndex Index)

This method deletes the item from location Index and then disposes it.

void AtDelete(TIndex Index)

This method delets item from location Index but it does not dispose it.

void Delete(void *Item)

This function delets item Item from the collection but it does not dispose it.

void DeleteAll(void)

This function deletes all items from the collection but it does not dispoe them.

void AtInsert(TIndex Index, void *Item)

This method inserts a new item Item to the collection at position Index.

void AtPut(TIndex Index, void *Item)

This method replaces item at location Index with item Item.

virtual TIndex Insert(void *Item)

This function inserts item Item to the collection. The new item will be appended to the and of the collection.

void *FirstThat(TTestFunc Test, void *Arg)

This method can be used to search for a specified item of the collection. It calls Test function until it returns true. It passes actual item as first parameter and Arg as second. It tries first item of the collection first.

void *LastThat(TTestFunc Test, void *Arg)

This method can be used to search for a specified item of the collection. It calls Test function until it returns true. It passes actual item as first parameter and Arg as second. It tries last item of the collection first.

void ForEach(TAppFunc Action, void *Arg)

This method calls Action function as many times as items exists on the collection. It passes actual item as first parameter and Arg as second.

void Error(TIndex Code, TIndex Info)

This method is called if an error occures for example index is out of range. It exits the program by default with Code exit code, so if you are going to use your own error recovery mechanism you must override this method.

TSortedCollection

TObject
   |
   +------TCollection
               |
               +-------TSortedCollection

Field index of TSortedCollection

Duplicates

Method index of TSortedCollection

TSortedCollection
~TSortedCollection
Search
IndexOf
Insert
*KeyOf

Fields

bool Duplicates

This field specifies any item can be inserted to the collection more than onece.

Methods

TSortedCollection(TIndex ALimit, TIndex ADelta)

Constructor of the sorted collection object calls inherited constructor with parameters ALimit and ADelta and then initializes Duplicates field to false.

virtual ~TSortedCollection(void)

Destructor of the class.

virtual bool Search(void *Key, TIndex &Index)

This method uses binary search to find an item which has Key field. Index of the item found will be returned in Index parameter and the function returns true. If nothing found then return value of this funcion will be false and Index contains location where the item should be placed.

virtual TIndex IndexOf(void *Item)

This function returns the index of specified Item or ccNotFound if item is not found.

virtual TIndex Insert(void *Item)

This method inserts Item to the collection.

virtual void *KeyOf(void *Item)

This method should return the address of the key field of the specifiied Item.

TStringCollection

TObject
   |
   +------TCollection
               |
               +-------TSortedCollection
                               |
                               +----------TStringCollection

Method index of TStringCollection

TStringCollection
~TStringCollection
Compare
FreeItem

Methods

TStringCollection(TIndex ALimit, TIndex ADelta)

Constructor od the string collection calls inherited constructor first with parameters ALimit and ADelta and then initializes Duplicates field to true.

virtual ~TStringCollection(void)

Destructor of the object. It disposes all string belongs to this collection.

virtual int Comapre(void *Key1, void *Key2)

This method overrides inherited comparison and compares items as strings.

virtual void FreeItem(void *Item)

This function disposes Item and assumes that it is a string.

TUnsortedStrings

TObject
   |
   +----TCollection
               |
               +-----TSortedCollection
                               |
                               +-------TStringCollection
                                               |
                                               +-------TUnsortedStrings

Method index of TUnsortedStrings

TUnsortedStrings
~TUnsortedStrings
Compare
Search

Methods

TUnsortedStrings(TIndex ALimit, TIndex ADelta)

Constructor of the unsorted string collection.

virtual ~TUnsortedStrings(void)

Destructor of the class.

virtual int Comapre(void *Key1, void *Key2)

This method overrides inherited comparison to make items unsorted.

virtual bool Search(void *Key, TIndex &Index)

Because collection is unsorted it is required to use linear search instead of inherited binary search method.

Back to Grapnel Compiler.