TOC PREV NEXT INDEX

Put your logo here!


4 INCLUDE FILES

4.1 fndABST_ARRAY.h

#ifndef fndABST_ARRAY_H
#define fndABST_ARRAY_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndABST_ARRAY.h,v 1.28 1998/08/28 08:53:58 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 14/11/95 At line 89 added cast to unsigned
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef _LIMITS_INCLUDED
#include <limits.h>
#endif
#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif
#ifndef fndCOLLECTION_H
#include <fndCOLLECTION.h>
#endif

#define fndABST_ARRAY_CLASS (classType)fndABST_ARRAY::CreateNew


class fndABST_ARRAY: public fndCOLLECTION
{
public:
fndABST_ARRAY( int upper, int lower = 0, sizeType aDelta = 0 );
fndABST_ARRAY();
virtual ~fndABST_ARRAY();

int LowerBound() const { return lowerbound; }
int UpperBound() const { return upperbound; }
sizeType ArraySize() const;

virtual fndCONTAINER_ITERATOR& InitIterator() const;

virtual void Add( fndOBJECT& ) = 0;
virtual void Destroy( const fndOBJECT& o ) { Detach( o, 1 ); }
virtual void Destroy( int pos ) { Detach( pos, 1 ); }
virtual void Detach( int pos, int deleteToo = 0 );

virtual void Detach( const fndOBJECT&obj, int deleteToo = 0 );
virtual void Empty( int destroy = FALSE );

virtual int IsEqual( const fndOBJECT& ) const;

virtual void PrintContentsOn( ostream& ) const;

fndOBJECT& operator []( int atIndex ) const { return ObjectAt( atIndex ); };

protected:
fndOBJECT &ObjectAt( int i ) const
{ return *theArray[ i - lowerbound ]; }
fndOBJECT *PtrAt( int i ) const
{ return theArray[ ZeroBase(i) ]; }
void SetData( int, fndOBJECT * );

void InsertEntry( int );
void RemoveEntry( int );
void SqueezeEntry( int );
int Find( const fndOBJECT & );

void Reallocate( sizeType );

sizeType delta;
int lowerbound;
int upperbound;
int whereToAdd;

fndOBJECT **theArray;

friend class fndARRAY_ITERATOR;

private:
int ZeroBase( int loc ) const {
if( loc >= lowerbound && loc <= upperbound )
return loc - lowerbound;
else
return -1;
};

int BoundBase( unsigned loc ) const {
if( loc == UINT_MAX || loc <= (unsigned)(upperbound - lowerbound) )
return loc == UINT_MAX ? INT_MAX : loc + lowerbound;
else
return -1;
};

fndStdObjectDef(fndABST_ARRAY, fndCOLLECTION)
};


class fndARRAY_ITERATOR: public fndCONTAINER_ITERATOR
{
public:
fndARRAY_ITERATOR( const fndABST_ARRAY& );
virtual ~fndARRAY_ITERATOR();

virtual operator int();
virtual operator fndOBJECT&();
virtual fndOBJECT &GetCurrent();

virtual fndOBJECT& operator ++(int);
virtual fndOBJECT& operator ++();
virtual void Restart();

private:
int currentIndex;
const fndABST_ARRAY &beingIterated;
};



/* Inline methods */

inline sizeType fndABST_ARRAY::ArraySize() const
{
return sizeType( upperbound - lowerbound + 1 );
}



inline fndARRAY_ITERATOR::fndARRAY_ITERATOR( const fndABST_ARRAY& toIterate ):
currentIndex( toIterate.lowerbound ),beingIterated( toIterate )
{
}

inline fndOBJECT &fndARRAY_ITERATOR::GetCurrent()
{
if ( currentIndex <= beingIterated.upperbound )
return ( (fndOBJECT&)( beingIterated.ObjectAt( currentIndex ) ) );
else // no more elements in the array.
return NOOBJECT;
}

#endif

/* __o0o__ */

4.2 fndARRAY.h

#ifndef fndARRAY_H
#define fndARRAY_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndARRAY.h,v 1.28 1998/08/28 08:53:59 vltsccm Exp $"
*
*
* who when what
* -------- -------- ----------------------------------------------
* vltsw 02/07/96 AddAt(): added deleteToo parameter
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif
#ifndef fndABST_ARRAY_H
#include <fndABST_ARRAY.h>
#endif

#define fndARRAY_CLASS (classType)fndARRAY::CreateNew

class fndARRAY: public fndABST_ARRAY
{
public:
fndARRAY( int upper, int lower = 0, sizeType aDelta = 0 ) :
fndABST_ARRAY( upper, lower, aDelta ) {}
fndARRAY() : fndABST_ARRAY() {}
virtual ~fndARRAY();

virtual void Add( fndOBJECT& );
virtual void AddAt( fndOBJECT&, int index, int deleteToo = FALSE);

fndStdObjectDef(fndARRAY,fndABST_ARRAY)
};

#endif

/* __o0o__ */

4.3 fndASSOCIATION.h

#ifndef fndASSOCIATION_H
#define fndASSOCIATION_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndASSOCIATION.h,v 1.28 1998/08/28 08:53:59 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* vltsw 02/07/96 Added DelItemsOnDelete()
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif

#define fndASSOCIATION_CLASS (classType)fndASSOCIATION::CreateNew

class fndASSOCIATION : public fndOBJECT
{
public:

fndASSOCIATION( ) { aKey=NULL; aValue=NULL; }
fndASSOCIATION( fndOBJECT &k, fndOBJECT &v )
{ aKey = &k; aValue = &v; delItemsOnDelete=FALSE;}
fndASSOCIATION( const fndASSOCIATION &a )
{ aKey=a.aKey; aValue=a.aValue; delItemsOnDelete=a.delItemsOnDelete; }
virtual ~fndASSOCIATION();

fndOBJECT &Key() const { return *aKey; }
fndOBJECT &Value() const { return *aValue; }
virtual void SetKey( fndOBJECT &k ) { aKey = &k; }
virtual void SetValue( fndOBJECT &v ) { aValue = &v; }
virtual hashValueType HashValue() const { return aKey->HashValue(); }
virtual int IsEqual( const fndOBJECT &toTest) const;
virtual int IsAssociation() const { return 1; }

virtual void PrintOn( ostream& outputStream)const;

virtual void DelItemsOnDelete(int destroy = TRUE)
{ delItemsOnDelete=destroy; };

protected:
int delItemsOnDelete;

private:

fndOBJECT *aKey;
fndOBJECT *aValue;

fndStdObjectDef(fndASSOCIATION, fndOBJECT)

};

#endif

/* __o0o__ */

4.4 fndAUTO_PTR.h

#ifndef fndAUTO_PTR_H
#define fndAUTO_PTR_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndAUTO_PTR.h,v 1.28 1998/08/28 08:54:09 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 21/08/97 created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

template<class T> class fndAUTO_PTR
{
public:
typedef T element_type;

fndAUTO_PTR(T *p = NULL) : owns(p != 0), el(p) {} ;
fndAUTO_PTR(fndAUTO_PTR& rhs) :
owns(rhs.owns), el(rhs.Release()){}

fndAUTO_PTR &operator=(fndAUTO_PTR& rhs) {
if( (void*)this != (void*)&rhs)
{
if(owns) delete el;
owns = rhs.owns;
el = rhs.Release();
}
return *this; }

~fndAUTO_PTR() { if(owns) delete el;};

T& operator*() const { return (*Get()); };
T *operator->() const { return (Get()); };
T *Get() const { return el; };
T *Release() { owns = FALSE; return(el); };

T *Take(T *p=0) {
if(owns) delete el;
owns = (p != 0);
el = p;
return el; };

private:
bool owns;
T *el;
};


#endif

/* __o0o__ */

4.5 fndBAG.h

#ifndef fndBAG_H
#define fndBAG_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndBAG.h,v 1.28 1998/08/28 08:53:59 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* vltsw 02/07/96 Added destructor
* gchiozzi 14/11/95 Deleted virtual outside class declaration
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndResource_H
#include <fndResource.h>
#endif
#ifndef fndHASH_TABLE_H
#include <fndHASH_TABLE.h>
#endif

#define fndBAG_CLASS (classType)fndBAG::CreateNew

class fndBAG : public fndCOLLECTION
{
public:

fndBAG( sizeType bagSize = fndDEFAULT_BAG_SIZE );
~fndBAG();

virtual void Add( fndOBJECT &o );
virtual void Detach( const fndOBJECT &o, int dt=0) ;
virtual int IsEmpty() const;
virtual countType GetItemsInContainer() const;
void ForEach( iterFuncType f, void *args ) const;

const fndOBJECT &FirstThat( condFuncType f, void *args) const;
const fndOBJECT &LastThat( condFuncType f, void *args) const;

virtual int HasMember( const fndOBJECT &o ) const;
virtual fndOBJECT &FindMember( const fndOBJECT &o ) const;
virtual void Empty( int deleteToo=FALSE );
virtual void PrintOn( ostream& ) const;

virtual fndCONTAINER_ITERATOR &InitIterator() const;

private:
fndHASH_TABLE table;
fndStdObjectDef(fndBAG, fndCOLLECTION)
};


/* Inline methods */

inline fndBAG::fndBAG( sizeType bagSize) : table( bagSize )
{
}

inline void fndBAG::Empty( int deleteToo)
{
table.Empty( deleteToo );
}

inline fndBAG::~fndBAG()
{
Empty(delItemsOnDelete);
}

inline void fndBAG::Add( fndOBJECT &o )
{
table.Add( o );
}

inline void fndBAG::Detach( const fndOBJECT &o, int dt)
{
table.Detach( o, dt );
}

inline int fndBAG::IsEmpty() const
{
return table.IsEmpty();
}

inline countType fndBAG::GetItemsInContainer() const
{
return table.GetItemsInContainer();
}

inline void fndBAG::ForEach( iterFuncType f, void *args ) const
{
table.ForEach( f, args );
}

inline const fndOBJECT &fndBAG::FirstThat( condFuncType f, void *args) const
{
return table.FirstThat( f, args );
}

inline const fndOBJECT &fndBAG::LastThat( condFuncType f, void *args) const
{
return table.LastThat( f, args );
}

inline int fndBAG::HasMember( const fndOBJECT &o ) const
{
return table.HasMember( o );
}

inline fndOBJECT &fndBAG::FindMember( const fndOBJECT &o ) const
{
return table.FindMember(o);
}

inline fndCONTAINER_ITERATOR &fndBAG::InitIterator() const
{
return table.InitIterator();
}


#endif

/* __o0o__ */

4.6 fndCOLLECTION.h

#ifndef fndCOLLECTION_H
#define fndCOLLECTION_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndCOLLECTION.h,v 1.28 1998/08/28 08:54:00 vltsccm Exp $"
*
* fndCOLLECTION.h
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#include <iostream.h>
#ifndef fndCONTAINER_H
#include <fndCONTAINER.h>
#endif



/***********/
/* Defines */
/***********/

#define fndCOLLECTION_CLASS (classType)fndCOLLECTION::CreateNew


/***********************/
/* Function prototypes */
/***********************/


/********************/
/* Class definition */
/********************/

class fndCOLLECTION: public fndCONTAINER {

/*********************/
/* Public section */
/*********************/

public:

virtual ~fndCOLLECTION();

virtual void Add( fndOBJECT& ) = 0;
virtual void Detach( const fndOBJECT&, int = 0 ) = 0;
virtual void Empty( int destroy = FALSE);
virtual int HasMember( const fndOBJECT& ) const;
virtual fndOBJECT &FindMember( const fndOBJECT& ) const;
virtual fndCONTAINER_ITERATOR& InitIterator() const = 0;
virtual void Destroy( const fndOBJECT& o );

fndStdObjectDef(fndCOLLECTION,fndCONTAINER)

}; /* end class fndCOLLECTION() */


inline void fndCOLLECTION::Destroy( const fndOBJECT& o )
{
Detach( o, 1 );
}

#endif

/* __o0o__ */

4.7 fndCONTAINER.h

#ifndef fndCONTAINER_H
#define fndCONTAINER_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndCONTAINER.h,v 1.28 1998/08/28 08:54:00 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* vltsw 02/07/96 Added deletion of items on delete.
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#include <iostream.h>

#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif


/***********/
/* Defines */
/***********/

#define fndCONTAINER_CLASS (classType)fndCONTAINER::CreateNew

class fndCONTAINER: public fndOBJECT
{
friend class fndCONTAINER_ITERATOR;
public:

fndCONTAINER() { itemsInContainer = 0; delItemsOnDelete = FALSE;}
fndCONTAINER( const fndCONTAINER& );

virtual ~fndCONTAINER();

virtual hashValueType HashValue() const;
virtual int IsEqual( const fndOBJECT& ) const;
virtual void ForEach( iterFuncType, void* ) const;
virtual void PrintOn( ostream& ) const;
virtual void PrintHeader( ostream& ) const;
virtual void PrintSeparator( ostream& ) const;
virtual void PrintTrailer( ostream& ) const;

virtual const fndOBJECT& FirstThat( condFuncType, void* ) const;
virtual const fndOBJECT& LastThat( condFuncType, void* ) const;

virtual fndCONTAINER_ITERATOR& InitIterator() const = 0;

int IsEmpty() const { return (itemsInContainer == 0); }
/* Returns a 1 if the container has no member. */

virtual void Empty( int destroy = FALSE ) {destroy=TRUE; /* VOID code */ };
virtual void DelItemsOnDelete(int destroy = TRUE)
{ delItemsOnDelete=destroy; };

countType GetItemsInContainer() const { return itemsInContainer; }
/* Returns the current number of objects in any container. */

fndStdObjectDef(fndCONTAINER,fndOBJECT)

protected:

countType itemsInContainer;
int delItemsOnDelete;

};



class fndCONTAINER_ITERATOR
{
public:

virtual ~fndCONTAINER_ITERATOR();
virtual fndOBJECT &GetCurrent() = 0;
virtual operator int() = 0;
virtual operator fndOBJECT&() = 0;

virtual fndOBJECT &operator ++(int) = 0;
virtual fndOBJECT &operator ++() = 0;

virtual void Restart() = 0;
};



#endif /*!fndCONTAINER_H*/

/* __o0o__ */

4.8 fndDEQUE.h

#ifndef fndDEQUE_H
#define fndDEQUE_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndDEQUE.h,v 1.28 1998/08/28 08:54:01 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* vltsw 02/07/96 Added call to correct empty in destructor
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndCONTAINER_H
#include <fndCONTAINER.h>
#endif
#ifndef fndLIST_H
#include <fndLIST.h>
#endif

#define fndDEQUE_CLASS (classType)fndDEQUE::CreateNew

class fndDEQUE : public fndCONTAINER
{
public:

~fndDEQUE() { Empty(delItemsOnDelete); }

fndOBJECT &PeekLeft() const { return list.PeekAtHead(); }
fndOBJECT &PeekRight() const { return list.PeekAtTail(); }
fndOBJECT &GetLeft();
fndOBJECT &GetRight();
void PutLeft( fndOBJECT &o ) {
list.AddAtHead( o );
itemsInContainer++;
}
void PutRight( fndOBJECT &o ) {
list.AddAtTail( o );
itemsInContainer++;
}
virtual void Empty( int deleteToo = FALSE ) {
list.Empty( deleteToo );
}
virtual int IsEmpty() const { return list.IsEmpty(); }
virtual countType GetItemsInContainer() const {
return list.GetItemsInContainer();
}
virtual void ForEach( iterFuncType f, void *arg ) const {
list.ForEach( f, arg );
}
virtual const fndOBJECT &FirstThat( condFuncType f, void *arg ) const {
return list.FirstThat( f, arg );
}
virtual const fndOBJECT &LastThat( condFuncType f, void *arg ) const {
return list.LastThat( f, arg );
}

virtual hashValueType HashValue() const { return list.HashValue(); }
virtual int IsEqual( const fndOBJECT &obj ) const {
return list.IsEqual( obj );
}
virtual int IsSortable() const { return list.IsSortable(); }
virtual int IsAssociation() const { return list.IsAssociation(); }
virtual void PrintOn( ostream& os ) const {
os << NameOf() << " {\n" << list << "} end " << NameOf() << '\n'; }

virtual fndCONTAINER_ITERATOR &InitIterator() const;

private:

fndLIST list;

fndStdObjectDef(fndDEQUE, fndCONTAINER)
};

#endif

/* __o0o__ */

4.9 fndDICTIONARY.h

#ifndef fndDICTIONARY_H
#define fndDICTIONARY_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndDICTIONARY.h,v 1.28 1998/08/28 08:54:01 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef _STDLIB_INCLUDED
#include <stdlib.h>
#endif

#ifndef fndSET_H
#include <fndSET.h>
#endif

#define fndDICTIONARY_CLASS (classType)fndDICTIONARY::CreateNew

class fndASSOCIATION;

class fndDICTIONARY : public fndSET
{
public:

fndDICTIONARY( unsigned sz = fndDEFAULT_DICT_SIZE ) : fndSET(sz) { }
~fndDICTIONARY();

virtual void Add( fndOBJECT &toAdd );
fndASSOCIATION &Lookup( const fndOBJECT &toLookup ) const;

fndStdObjectDef(fndDICTIONARY, fndSET)

}; /* end class fndDICTIONARY */

#endif

/* __o0o__ */

4.10 fndFLOAT.h

#ifndef fndFLOAT_H
#define fndFLOAT_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndFLOAT.h,v 1.28 1998/08/28 08:54:01 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndSORTABLE_H
#include <fndSORTABLE.h>
#endif

#define fndFLOAT_CLASS (classType)fndFLOAT::CreateNew

class fndFLOAT: public fndSORTABLE {

public:

fndFLOAT( const float aFloat=0 );
fndFLOAT( const fndFLOAT& sourceFloat );

virtual int IsEqual( const fndOBJECT& ) const;
virtual int IsLessThan( const fndOBJECT& ) const;
virtual void PrintOn( ostream& ) const;

fndFLOAT &operator =( const fndFLOAT& );
operator const float() const;

fndStdObjectDef(fndFLOAT, fndSORTABLE)

protected:
float theFloat;
};

/* inline methods */

inline fndFLOAT::fndFLOAT(const float aFloat): theFloat(aFloat) {}

inline fndFLOAT::fndFLOAT(const fndFLOAT& sourceFloat) :
theFloat( sourceFloat.theFloat) {}

inline fndFLOAT::operator const float() const { return theFloat; }

#endif

/* __o0o__ */

4.11 fndHASH_TABLE.h

#ifndef fndHASH_TABLE_H
#define fndHASH_TABLE_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndHASH_TABLE.h,v 1.28 1998/08/28 08:54:02 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndResource_H
#include <fndResource.h>
#endif
#ifndef fndCOLLECTION_H
#include <fndCOLLECTION.h>
#endif
#ifndef fndLIST_H
#include <fndLIST.h>
#endif
#ifndef fndARRAY_H
#include <fndARRAY.h>
#endif

class fndCONTAINER_ITERATOR;
class fndHASH_TABLE;
class fndHASH_TABLE_ITERATOR;

#define fndHASH_TABLE_CLASS (classType)fndHASH_TABLE::CreateNew

class fndHASH_TABLE : public fndCOLLECTION
{
public:

friend class fndHASH_TABLE_ITERATOR;

fndHASH_TABLE( sizeType = fndDEFAULT_HASH_TABLE_SIZE );
virtual ~fndHASH_TABLE();

virtual void Add( fndOBJECT &toAdd );
virtual void Detach( const fndOBJECT &toDetach, int deleteToo= 0 );
virtual void Empty( int deleteToo = FALSE );

virtual void PrintOn( ostream& ) const;

virtual int IsEmpty() const {
return itemsInContainer == 0;
}
virtual countType GetItemsInContainer() const {
return itemsInContainer;
}
virtual fndOBJECT &FindMember(const fndOBJECT &toFind ) const;
virtual fndCONTAINER_ITERATOR &InitIterator() const;

private:

hashValueType GetHashValue( const fndOBJECT & ) const;
sizeType size;
fndARRAY table;

fndStdObjectDef(fndHASH_TABLE, fndCOLLECTION)
};


class fndHASH_TABLE_ITERATOR : public fndCONTAINER_ITERATOR
{
public:

fndHASH_TABLE_ITERATOR( const fndHASH_TABLE & );
~fndHASH_TABLE_ITERATOR();

virtual operator int();
virtual operator fndOBJECT&();

virtual fndOBJECT &GetCurrent();
virtual fndOBJECT &operator ++ ( int );
virtual fndOBJECT &operator ++ ();
virtual void Restart();

private:

fndCONTAINER_ITERATOR *arrayIterator;
fndCONTAINER_ITERATOR *listIterator;
const fndHASH_TABLE &beingIterated;

void Scan();
};


/* Inline methods */

inline hashValueType fndHASH_TABLE::GetHashValue(
const fndOBJECT &ofObject ) const
{
return ofObject.HashValue() % size;
}


#endif

/* __o0o__ */

4.12 fndINT.h

#ifndef fndINT_H
#define fndINT_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndINT.h,v 1.28 1998/08/28 08:54:02 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 09/05/95 Corrected bug: inline function had no "inline" keyword
* gchiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndSORTABLE_H
#include <fndSORTABLE.h>
#endif

#define fndINT_CLASS (classType)fndINT::CreateNew

class fndINT: public fndSORTABLE {

public:
fndINT( const int anInt=0 );
fndINT( const fndINT& sourceInteger );

virtual hashValueType HashValue() const;

virtual int IsEqual( const fndOBJECT& ) const;
virtual int IsLessThan( const fndOBJECT& ) const;
virtual void PrintOn( ostream& ) const;

fndINT &operator =( const fndINT& );
operator const int() const;

fndStdObjectDef(fndINT, fndSORTABLE)

private:
int theInteger;
};

inline fndINT::fndINT( const int anInt)
{
theInteger = anInt;
}

inline fndINT::fndINT( const fndINT& sourceInteger )
{
theInteger = sourceInteger.theInteger;
}

inline hashValueType fndINT::HashValue() const
{
return (hashValueType)theInteger;
}

inline fndINT::operator const int() const
{
return theInteger;
}

#endif

/* __o0o__ */

4.13 fndLIST.h

#ifndef fndLIST_H
#define fndLIST_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndLIST.h,v 1.28 1998/08/28 08:54:03 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#include <iostream.h>

#ifndef fndCOLLECTION_H
#include <fndCOLLECTION.h>
#endif
#ifndef fndLIST_ELEMENT_H
#include <fndLIST_ELEMENT.h>
#endif

#define fndLIST_CLASS (classType)fndLIST::CreateNew

class fndLIST:public fndCOLLECTION {

public:

fndLIST();
fndLIST( fndLIST &fromList);
virtual ~fndLIST();

virtual void Add( fndOBJECT& item);
virtual void AddAtHead( fndOBJECT& item);
virtual void AddAtTail( fndOBJECT& item);

virtual void DestroyFromHead( const fndOBJECT& item);
virtual void DestroyFromTail( const fndOBJECT& item);
virtual void Detach( const fndOBJECT& item, int deleteToo = 0 );
virtual void Detach( int pos, int deleteToo = 0 );
virtual void DetachFromHead( const fndOBJECT&, int deleteToo = 0 );
virtual void DetachFromTail( const fndOBJECT&, int deleteToo = 0 );

virtual void Empty( int deleteToo = FALSE );


virtual fndCONTAINER_ITERATOR& InitIterator() const;
virtual fndCONTAINER_ITERATOR& InitReverseIterator() const;

virtual fndOBJECT &PeekAtHead() const;
virtual fndOBJECT &PeekAtTail() const;

private:
fndLIST_ELEMENT* head;
fndLIST_ELEMENT* tail;
friend class fndLIST_ITERATOR;

fndStdObjectDef(fndLIST, fndCOLLECTION)

}; /* end class fndLIST */



class fndLIST_ITERATOR: public fndCONTAINER_ITERATOR {

public:

fndLIST_ITERATOR() {};
fndLIST_ITERATOR( const fndLIST&, int atHead = 1 );

virtual ~fndLIST_ITERATOR();

virtual fndOBJECT &GetCurrent();
virtual operator int();
virtual operator fndOBJECT&();

virtual fndOBJECT& operator ++(int);
virtual fndOBJECT& operator --(int);
virtual fndOBJECT& operator ++();
virtual fndOBJECT& operator --();

virtual void Restart();

private:
fndLIST_ELEMENT* currentElement;
fndLIST_ELEMENT* startingElement;
};



/* Inline methods */

/*
Destroys an object from the head of a double list. We remove
the object from the list and call that object's destructor.
The parameter:
toDestroy
is the object we are to search for and Destroy from the fndLIST.

Warnings:
No error condition is generated if the object which was specified
isn't on the double list.
*/
inline void fndLIST::DestroyFromHead( const fndOBJECT& toDestroy )
{
DetachFromHead( toDestroy, 1 );
}


/*
Destroys an object from the tail of a double list. We remove
the object from the list and call that object's destructor.
The parameter:
toDestroy
is the object we are to search for and destroy from the fndLIST.

Warnings:
No error condition is generated if the object which was specified
isn't on the double list.
*/
inline void fndLIST::DestroyFromTail( const fndOBJECT& toDestroy )
{
DetachFromTail( toDestroy, 1 );
}


/*
Constructor for a list iterator object.
The parameters:
toIterate
is the double list we are to iterat;.
atHead
indicates whether we are to start at the head of the list. If this
is not 1, we will start at the tail.
*/
inline fndLIST_ITERATOR::fndLIST_ITERATOR( const fndLIST& toIterate,
int atHead )


{
if ( atHead == 1 )
{
startingElement = currentElement = toIterate.head;
}
else
{
startingElement = currentElement = toIterate.tail;
}
}


#endif

/* __o0o__ */

4.14 fndLIST_ELEMENT.h

#ifndef fndLIST_ELEMENT_H
#define fndLIST_ELEMENT_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndLIST_ELEMENT.h,v 1.28 1998/08/28 08:54:03 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndCONTAINER_H
#include <fndCONTAINER.h>
#endif

class fndLIST_ELEMENT {

friend class fndLIST;
friend class fndLIST_ITERATOR;

public:

fndLIST_ELEMENT() { data = NULL; next = NULL; previous = NULL; }
fndLIST_ELEMENT( fndOBJECT* o ) { data = o; next = previous = NULL; }
~fndLIST_ELEMENT() { delete data; }

private:

fndLIST_ELEMENT* next;
fndLIST_ELEMENT* previous;

fndOBJECT* data;

};

#endif

/* __o0o__ */

4.15 fndNAME_MAP.h

#ifndef fndNAME_MAP_H
#define fndNAME_MAP_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndNAME_MAP.h,v 1.28 1998/08/28 08:54:08 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 03/05/95 created
*/

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif


#define fndNELEM(array) (sizeof(array)/sizeof((array)[0]))
struct fndNAME_AND_INDEX {
const char *name;
unsigned int index;
};

class fndNAME_MAP {
public:
fndNAME_MAP(fndNAME_AND_INDEX *array, unsigned int nelem);
const char *String(unsigned int index) const;
int Index(const char *string) const;

protected:
static int compString(const void *, const void *);
static int compIndex(const void *, const void *);

private:
fndNAME_AND_INDEX *data;
unsigned int nelem;

};

#endif /*!fndNAME_MAP_H*/

/* __o0o__ */

4.16 fndOBJECT.h

#ifndef fndOBJECT_H
#define fndOBJECT_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndOBJECT.h,v 1.28 1998/08/28 08:54:03 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 29/03/96 Relational operators now return bool instead of int
* G.Chiozzi 18/01/95 Created
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#include <iostream.h>
#ifndef _STDDEF_INCLUDED
#include <stddef.h>
#endif
#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif

/***********/
/* Defines */
/***********/

class fndOBJECT;

typedef char *caddr_t;

typedef unsigned int hashValueType; /* Defines a returned hash value. */
typedef unsigned int sizeType; /* Defines the size of a storage area. */
typedef int countType; /* Defines a container for counting */
/* things in the class librery. */
typedef void(*iterFuncType )( fndOBJECT&, void* );
/* Defines a pointer to an iteration */
/* function.The iteration function takes */
/* an fndOBJECT reference and a point */
/* to a list of parameters to the */
/* function. The parameter list pointer */
/* may be NULL. */
typedef int(*condFuncType )( const fndOBJECT&, void* );
/* Defines a pointer to a function which */
/* implements a conditional test and */
/* returns 0 if the condition was met, */
/* non-zero otherwise. The non-zero */
/* values are defined by the individual */
/* function. */
typedef char Boolean;

typedef fndOBJECT *(*creator )( );

typedef fndOBJECT* func_type();

enum ObjectInit { objectInit };

#define NOOBJECT *(fndOBJECT::ZERO)

/* Defines the type of a class */
#define classType caddr_t

#define fndOBJECT_CLASS (classType)fndOBJECT::CreateNew

class fndOBJECT {

/*********************/
/* Public section */
/*********************/

public:

static fndOBJECT *ZERO;

fndOBJECT();
fndOBJECT( fndOBJECT& );

virtual ~fndOBJECT();

virtual void ForEach( iterFuncType, void* ) const;
virtual hashValueType HashValue() const;

virtual int IsSortable()const;
virtual int IsAssociation()const;

virtual int IsEqual( const fndOBJECT& )const;

virtual const fndOBJECT &FirstThat( condFuncType, void* )const;
virtual const fndOBJECT &LastThat( condFuncType, void* )const;

void *operator new( size_t s );
void operator delete( void* );

/*******************************************************/
/* These methods MUST be overloaded for each sub-class */
/*******************************************************/
static fndOBJECT *CreateNew();

virtual classType IsA() const;
virtual int IsSubclassOf(classType toTest) const;
virtual char *NameOf() const;

/*******************************************************/
/* These methods MUST be overloaded for each sub-class */
/* only if they are used for the subclass itself */
/*******************************************************/
virtual void PrintOn( ostream& outputStream)const;

/*********************/
/* Protected section */
/*********************/

protected:

friend inline ostream& operator <<( ostream&, const fndOBJECT& );

private:

fndOBJECT( ObjectInit flag);

}; /* end class fndOBJECT */


/* Macro user in fndOBJECT sublasses header files (at end of */
/* class definition in order to automatically build standard */
/* methods: CreateNew(), IsA(), IfSubclassOf(), NameOf() */
#define fndStdObjectDef(Class, ParentClass) \
public: \
static Class *CreateNew(); \
virtual classType IsA() const \
{return ((classType)(Class::CreateNew));}; \
virtual int IsSubclassOf(classType toTest) const \
{ \
if( Class::IsA() == toTest ) return TRUE; \
return (ParentClass::IsSubclassOf(toTest)); \
}; \
virtual char *NameOf() const { return #Class; };

/* Macro user in fndOBJECT sublasses source files in order */
/* to build the standard form of CreateNew() method body */
#define fndStdObjectSource(Class, ParentClass) \
Class *Class::CreateNew() { return(new Class); }


/******************/
/* Inline methods */
/******************/

inline hashValueType fndOBJECT::HashValue() const
{
return (hashValueType)this;
}

inline int fndOBJECT::IsSubclassOf(classType toTest) const
{
if( fndOBJECT::IsA() == toTest ) return TRUE;
return FALSE;
}

inline void fndOBJECT::PrintOn( ostream& outputStream)const
{
outputStream << NameOf();
}

inline ostream& operator <<( ostream& outputStream,
const fndOBJECT& anfndOBJECT )
{
anfndOBJECT.PrintOn( outputStream );
return outputStream;
}

bool operator ==( const fndOBJECT& test1, const fndOBJECT& test2 );

inline bool operator !=( const fndOBJECT& test1, const fndOBJECT& test2 )

/* Determines whether the given object is not equal to this. We just
reverse the condition returned from operator ==.

Parameters: test1 - the first object we are testing;
test2 - the second object we are testing. */

{
return( !(test1 == test2 ) );
}


#endif

/* __o0o__ */

4.17 fndPOINTER.h

#ifndef fndPOINTER_H
#define fndPOINTER_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndPOINTER.h,v 1.28 1998/08/28 08:54:04 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif

#define fndPOINTER_CLASS (classType)fndPOINTER::CreateNew

class fndPOINTER: public fndOBJECT {

public:

fndPOINTER(caddr_t newValue = NULL);
fndPOINTER(const fndPOINTER &newPointer);

virtual caddr_t GetValue();
virtual int IsEqual(const fndOBJECT&) const;
virtual void PrintOn(ostream&) const;

fndPOINTER &operator =(const fndPOINTER&);
operator const caddr_t () const;

fndStdObjectDef(fndPOINTER,fndOBJECT)

protected:
caddr_t thePointer;
};


inline fndPOINTER::fndPOINTER( caddr_t newValue )
{
thePointer = newValue;
}

inline fndPOINTER::fndPOINTER( const fndPOINTER& sourcePointer )
{
thePointer = sourcePointer.thePointer;
}

inline caddr_t fndPOINTER::GetValue()
{
return thePointer;
}

inline fndPOINTER::operator const caddr_t () const
{
return thePointer;
}


#endif

/* __o0o__ */

4.18 fndPORT.h

#ifndef fndPORT_H
#define fndPORT_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndPort.h,v 1.28 1998/08/28 08:54:04 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 created
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#define _POSIX_SOURCE 1

#ifndef vltPort_H
#include <vltPort.h>
#endif

#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif


#endif

/* __o0o__ */

4.19 fndPOS_ARRAY.h

#ifndef fndPOS_ARRAY_H
#define fndPOS_ARRAY_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndPOS_ARRAY.h,v 1.28 1998/08/28 08:54:04 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndSORT_ARRAY_H
#include <fndSORT_ARRAY.h>
#endif

#define fndPOS_ARRAY_CLASS (classType)fndPOS_ARRAY::CreateNew


class fndPOS_ARRAY : public fndSORT_ARRAY
{
public:
fndPOS_ARRAY( int upper, int lower = 0, sizeType aDelta = 0 ) :
fndSORT_ARRAY(upper, lower,aDelta) {};
fndPOS_ARRAY() : fndSORT_ARRAY() {};
virtual ~fndPOS_ARRAY() {};

virtual void Add( fndOBJECT &obj) { fndSORT_ARRAY::Add(obj); };
virtual void Add( fndOBJECT &obj, int pos);

fndStdObjectDef(fndPOS_ARRAY, fndSORT_ARRAY)

}; /* end Class fndPOS_ARRAY() */

#endif

/* __o0o__ */

4.20 fndQUEUE.h

#ifndef fndQUEUE_H
#define fndQUEUE_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndQUEUE.h,v 1.28 1998/08/28 08:54:05 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndDEQUE_H
#include <fndDEQUE.h>
#endif

#define fndQUEUE_CLASS (classType)fndQUEUE::CreateNew

class fndQUEUE : public fndDEQUE
{
public:

fndOBJECT &Get() { return fndDEQUE::GetRight(); }
void Put(fndOBJECT &o) { fndDEQUE::PutLeft( o ); }

private:

fndOBJECT &GetLeft();
fndOBJECT &GetRight();

void PutLeft( fndOBJECT & );
void PutRight( fndOBJECT & );

fndStdObjectDef(fndQUEUE, fndDEQUE)

};

#endif

/* __o0o__ */

4.21 fndResource.h

#ifndef fndResource_H
#define fndResource_H
/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: fndResource.h,v 1.28 1998/08/28 08:54:05 vltsccm Exp $"
*
* fndResource.h
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
* This file includes basic defines used by other fnd classes
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

const fndDEFAULT_HASH_TABLE_SIZE = 111;
const fndDEFAULT_BAG_SIZE = 29;
const fndDEFAULT_SET_SIZE = 29;
const fndDEFAULT_DEQUE_SIZE = 20;
const fndDEFAULT_QUEUE_SIZE = 20;
const fndDEFAULT_STACK_SIZE = 20;
const fndDEFAULT_ARRAY_SIZE = 20;
const fndDEFAULT_DICT_SIZE = 111;

#endif

/* __o0o__ */

4.22 fndSET.h

#ifndef fndSET_H
#define fndSET_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndSET.h,v 1.28 1998/08/28 08:54:06 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef fndResource_H
#include <fndResource.h>
#endif
#ifndef fndBAG_H
#include <fndBAG.h>
#endif

#define fndSET_CLASS (classType)fndSET::CreateNew

class fndSET : public fndBAG
{
public:

fndSET( sizeType setSize = fndDEFAULT_SET_SIZE );
virtual void Add( fndOBJECT &toAdd );

fndStdObjectDef(fndSET,fndBAG)

}; /* end class fndSET */


/* Inline methods */

inline fndSET::fndSET( sizeType setSize) : fndBAG( setSize )
{
}

inline void fndSET::Add( fndOBJECT &toAdd )
{
if( !(fndBAG::HasMember( toAdd )) ) { fndBAG::Add( toAdd ); }
}

#endif

/* __o0o__ */

4.23 fndSORT_ARRAY.h

#ifndef fndSORT_ARRAY_H
#define fndSORT_ARRAY_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndSORT_ARRAY.h,v 1.28 1998/08/28 08:54:06 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#include <iostream.h>

#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif
#ifndef fndSORTABLE_H
#include <fndSORTABLE.h>
#endif
#ifndef fndABST_ARRAY_H
#include <fndABST_ARRAY.h>
#endif

#define fndSORT_ARRAY_CLASS (classType)fndSORT_ARRAY::CreateNew


class fndSORT_ARRAY : public fndABST_ARRAY
{
public:
fndSORT_ARRAY( int upper, int lower = 0, sizeType aDelta = 0 ) :
fndABST_ARRAY(upper, lower,aDelta) {};
fndSORT_ARRAY() : fndABST_ARRAY() {};
virtual ~fndSORT_ARRAY() {};

virtual void Add( fndOBJECT &);

/* It is necessary to redefine both form of detach */
virtual void Detach(int pos, int deleteToo = FALSE );
virtual void Detach(const fndOBJECT &obj, int deleteToo = FALSE );

fndStdObjectDef(fndSORT_ARRAY,fndABST_ARRAY)

}; /* end Class fndSORT_ARRAY() */

#endif

/* __o0o__ */

4.24 fndSORTABLE.h

#ifndef fndSORTABLE_H
#define fndSORTABLE_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndSORTABLE.h,v 1.28 1998/08/28 08:54:06 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 29/03/96 Relational operators now return bool instead of int
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/


#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndOBJECT_H
#include <fndOBJECT.h>
#endif

#define fndSORTABLE_CLASS (classType)fndSORTABLE::CreateNew

class fndSORTABLE: public fndOBJECT {

protected:

public:

virtual ~fndSORTABLE();

virtual int IsLessThan( const fndOBJECT& ) const;
virtual int IsSortable() const;

fndStdObjectDef(fndSORTABLE,fndOBJECT)
};


inline int fndSORTABLE::IsLessThan( const fndOBJECT& ) const
{
return FALSE;
}


inline bool operator < ( const fndSORTABLE& test1, const fndSORTABLE& test2 )

/* Determines whether the first object is less than the second. We
do type checking on the two objects (objects of different
classes can't be compared, even if they're derived from each other).

Parameters: test1 - The first object we are testing.
test2 - The second object we are testing.

Return value: Returns 1 if this is less than a test object. */

{
return ( (test1.IsA() == test2.IsA()) && test1.IsLessThan(test2) );
}


inline bool operator > ( const fndSORTABLE& test1, const fndSORTABLE& test2 )

/* Determines whether the first object is greater than the second. We
just reverse the condition returned from operator < and test for
inequality.

Parameters: test1 - The first object we are testing.
test2 - The second object we are testing.

Return value: Returns 1 if this is greater than a test object. */


{
return !( test1 < test2 ) && test1 != test2;
}


inline bool operator >=( const fndSORTABLE& test1, const fndSORTABLE& test2 )

/* Determines whether the first object is greater than or equal to
the second. We just reverse the condition returned from operator <.

Parameters: test1 - The first object we are testing.
test2 - The second object we are testing.

Return value: Returns 1 if this is greater than or equal to a
test object. */

{
return ( !( test1 <( test2 ) ) );
}


inline bool operator <=( const fndSORTABLE& test1, const fndSORTABLE& test2 )

/* Determines whether test1 is less than or equal to test2.
We just combine the less than and equal to operators.

Parameters: test1 - The first object we are testing.
test2 - The second object we are testing.

Return value: Returns 1 if this is less than or equal to a test. */

{
return ( test1 < test2 || test1 == test2 );
}

#endif

/* __o0o__ */

4.25 fndSTACK.h

#ifndef fndSTACK_H
#define fndSTACK_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndSTACK.h,v 1.28 1998/08/28 08:54:07 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* vltsw 02/07/96 Added destructor to call correct Empty()
* G.Chiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndCONTAINER_H
#include <fndCONTAINER.h>
#endif
#ifndef fndLIST_H
#include <fndLIST.h>
#endif

#define fndSTACK_CLASS (classType)fndSTACK::CreateNew

class fndSTACK : public fndCONTAINER
{
public:

~fndSTACK();

void Push( fndOBJECT & );
fndOBJECT &Pop();
fndOBJECT &Top() const;

virtual countType GetItemsInContainer() const;
virtual void ForEach(iterFuncType f, void *arg ) const;
virtual const fndOBJECT &FirstThat(condFuncType f, void *arg ) const;
virtual const fndOBJECT &LastThat(condFuncType f, void *arg ) const;
virtual hashValueType HashValue() const;
virtual void Empty(int deleteToo = FALSE );
virtual int IsAssociation() const;
virtual int IsEmpty() const;
virtual int IsEqual(const fndOBJECT& obj ) const;
virtual int IsSortable() const;
virtual void PrintOn(ostream& os ) const;

virtual fndCONTAINER_ITERATOR &InitIterator() const;

private:

fndLIST list;

fndStdObjectDef(fndSTACK, fndCONTAINER)
};


/* Inline methods */

inline fndOBJECT &fndSTACK::Top() const
{
return list.PeekAtHead();
}

inline int fndSTACK::IsEmpty() const
{
return list.IsEmpty();
}

inline countType fndSTACK::GetItemsInContainer() const
{
return list.GetItemsInContainer();
}

inline void fndSTACK::ForEach( iterFuncType f, void *arg ) const
{
list.ForEach( f, arg );
}

inline const fndOBJECT &fndSTACK::FirstThat(condFuncType f, void *arg ) const
{
return list.FirstThat( f, arg );
}

inline const fndOBJECT &fndSTACK::LastThat(condFuncType f, void *arg ) const
{
return list.LastThat( f, arg );
}

inline hashValueType fndSTACK::HashValue() const
{
return list.HashValue();
}

inline void fndSTACK::Empty(int deleteToo)
{
list.Empty( deleteToo );
}

inline int fndSTACK::IsEqual( const fndOBJECT& obj ) const
{
return list.IsEqual( obj );
}

inline int fndSTACK::IsSortable() const
{
return list.IsSortable();
}

inline int fndSTACK::IsAssociation() const
{
return list.IsAssociation();
}

inline void fndSTACK::PrintOn( ostream& os ) const
{
os << NameOf() << " {\n" << list << "} end " << NameOf() << '\n';
}

#endif

/* __o0o__ */

4.26 fndSTRING.h

#ifndef fndSTRING_H
#define fndSTRING_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndSTRING.h,v 1.28 1998/08/28 08:54:07 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 29/03/96 Relational operators now return bool instead of int
* gchiozzi 09/08/95 Added new methods
* gchiozzi 18/01/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef fndString_H
#include <fndString.h>
#endif
#ifndef fndSORTABLE_H
#include <fndSORTABLE.h>
#endif

#define fndSTRING_CLASS (classType)fndSTRING::CreateNew

class fndSTRING: public fndSORTABLE {

public:
fndSTRING( const char* = NULL );
fndSTRING( const fndSTRING& );
fndSTRING(char fillCh, unsigned int count);

virtual ~fndSTRING();

virtual hashValueType HashValue() const;
virtual int IsEqual( const fndOBJECT& ) const;
virtual int IsLessThan( const fndOBJECT& ) const;
virtual void PrintOn( ostream& ) const;

// Number of allocated bytes (including '\0')
sizeType GetLen() const;

fndSTRING& operator =( const fndSTRING& );
operator const char*() const;

// concatenation methods
friend fndSTRING operator + (const fndSTRING & str1, const fndSTRING & str2);
void operator += (const fndSTRING& str);

// comparison methods
bool operator < (const fndSTRING & str);
bool operator > (const fndSTRING & str);
bool operator <= (const fndSTRING & str);
bool operator >= (const fndSTRING & str);
bool operator == (const fndSTRING & str);
bool operator != (const fndSTRING & str);

int Compare(const fndSTRING & str, fndSTR_CMP_MODE caseChk= fndSTR_IGNORE);

// substring search methods
int Find(const fndSTRING & str, unsigned int *pos,
fndSTR_CMP_MODE caseChk = fndSTR_IGNORE);

// substring deletion method
void Delete(unsigned int pos, unsigned int count);

// substring insertion methods
void Insert(unsigned int pos, char ch);
void Insert(unsigned int pos, const fndSTRING & str);

// substring retrieval method
fndSTRING SubStr(unsigned int start, unsigned int count);

// character retrieval method
char operator [] (unsigned int pos);

// case-modification methods
fndSTRING ToUpper();
fndSTRING ToLower();

fndStdObjectDef(fndSTRING,fndSORTABLE)

private:
sizeType len;
char *theString;

};

/***********************************************************************/
/* Constructs a fndSTRING object from a given character string. */
/* */
/* We assign the string's length to len, then allocate space into */
/* which we will store the string's characters. You may construct */
/* fndSTRING objects out of local character strings. */
/* */
/* Parameters: aPtr - Pointer to the characters out of which we are to */
/* construct a fndSTRING object. */
/***********************************************************************/

inline fndSTRING::fndSTRING( const char* aPtr )
{
/* if ( aPtr && *aPtr ) */
/* 02/11/93: the previous was the original */
if ( aPtr )
{
len = (unsigned int)strlen( aPtr ) + 1;
theString = new char[ len ];
(void)strcpy( theString, aPtr );
}
else /* make a null string fndSTRING object.*/
{
len = 0;
theString = 0;
}
}


/******************/
/* Inline methods */
/******************/
inline sizeType fndSTRING::GetLen() const { return len; }

inline fndSTRING::operator const char*() const { return theString; }

// comparison methods
inline bool fndSTRING::operator < (const fndSTRING & str)
{
return (Compare(str) == fndSTR_LESS);
}

inline bool fndSTRING::operator > (const fndSTRING & str)
{
return (Compare(str) == fndSTR_GREATER);
}

inline bool fndSTRING::operator <= (const fndSTRING & str)
{
return (Compare(str) != fndSTR_GREATER);
}

inline bool fndSTRING::operator >= (const fndSTRING & str)
{
return (Compare(str) != fndSTR_LESS);
}

inline bool fndSTRING::operator == (const fndSTRING & str)
{
return (Compare(str) == fndSTR_EQUAL);
}

inline bool fndSTRING::operator != (const fndSTRING & str)
{
return (Compare(str) != fndSTR_EQUAL);
}

// character retrieval method
inline char fndSTRING::operator [] (unsigned int pos)
{
if (pos >= len)
return '\x00';
else
return theString[pos];
}

/********************/
/* Inline operators */
/********************/

inline bool operator ==( const fndSTRING& str, const fndSTRING& str2 )
{
return( (const fndOBJECT &)str == (const fndOBJECT &)str2 );
}

inline bool operator ==( const fndSTRING& str, const char *ch )
{
return( strcmp( ch, str )==0 ? TRUE : FALSE );
}

inline bool operator ==( const char *ch , const fndSTRING& str)
{
return( strcmp( ch, str )==0 ? TRUE : FALSE );
}

inline bool operator !=( const fndSTRING& str, const fndSTRING& str2 )
{
return( (const fndOBJECT &)str != (const fndOBJECT &)str2 );
}

inline bool operator !=( const fndSTRING& str, const char *ch )
{
return( strcmp( ch, str )!=0 ? TRUE : FALSE );
}

inline bool operator !=( const char *ch , const fndSTRING& str)
{
return( strcmp( ch, str )!=0 ? TRUE : FALSE );
}





#endif

/* __o0o__ */

4.27 fndString.h

#ifndef fndString_H
#define fndString_H
/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: fndString.h,v 1.28 1998/08/28 08:54:08 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 09/08/95 Created
*
*/

/************************************************************************
*
*----------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef _STRING_INCLUDED
#include <string.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

enum fndSTR_CMP_MODE {fndSTR_SENSITIVE, fndSTR_IGNORE};
enum fndSTR_CMP_VAL {fndSTR_LESS = -1, fndSTR_EQUAL = 0, fndSTR_GREATER = 1};

char *fndStrlower(char *str);
char *fndStrupper(char *str);

int fndStrcmp(const char *s1, const char *s2, enum fndSTR_CMP_MODE caseChk);

#ifdef __cplusplus
}
#endif

#endif

/* __o0o__ */


5 EXAMPLE PROGRAMS

5.1 DYNAMIC ARRAYS

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testArray.C,v 1.28 1998/08/28 08:54:11 vltsccm Exp $"
*
* testArray.C
*
* who when what
* -------- -------- ----------------------------------------------
* G.Chiozzi 18/01/95 Created
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/


#ifndef fndPort_H
#include <fndPort.h>
#endif


#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif
#ifndef fndARRAY_H
#include <fndARRAY.h>
#endif
#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif



main( unsigned int, char *[] )

{
int i;
fndARRAY *myArray= new fndARRAY();

fndSTRING* element0= new fndSTRING( "ELEMENT0" );
myArray->Add( *element0 );
fndSTRING* element1= new fndSTRING( "ELEMENT1" );
myArray->Add( *element1 );
fndSTRING* element2= new fndSTRING( "ELEMENT2" );
myArray->Add( *element2 );
fndSTRING* element3= new fndSTRING( "ELEMENT3" );
myArray->Add( *element3 );

int asize;
asize=myArray->GetItemsInContainer();
cout << "The array contains " << asize << " elements\n";

cout << "The elements (accessed by index) are:\n";

/* test NameOf */
cout << "class name : " << myArray->NameOf() << "\n";

for(i=0; i< asize; i++)
{
(*myArray)[i].PrintOn(cout);
cout << '\n';
cout.flush();
}


/* Element 3 is substituted via AddAt index */
fndSTRING* element= new fndSTRING( "NEWELEMENT" );
cout << "\nChanging element 3 with AddAt\n",

myArray->AddAt( *element,3,TRUE );

for(i=0; i< asize; i++)
{
(*myArray)[i].PrintOn(cout);
cout << '\n';
cout.flush();
}

cout << "Detaching by index (element 1)\n";
myArray->Detach(1);
cout << "Detaching by reference (element2)\n";
myArray->Detach(*element2);
delete element1; // Deleting removed elements
delete element2; // Deleting removed elements


cout << "Print elements with PrintContentsOn():\n";
myArray->PrintContentsOn( cout );
cout << "\n";

cout << "Calling Empty(TRUE) method for the array\n";
myArray->Empty(TRUE);

cout << "Adding 4 new elements\n";
element0= new fndSTRING( "ELEMENT0" );
myArray->Add( *element0 );
element1= new fndSTRING( "ELEMENT1" );
myArray->Add( *element1 );
element2= new fndSTRING( "ELEMENT2" );
myArray->Add( *element2 );
element3= new fndSTRING( "ELEMENT3" );
myArray->Add( *element3 );

asize=myArray->GetItemsInContainer();
cout << "The array contains " << asize << " elements\n";

cout << "The elements (accessed by index) are:\n";

for(i=0; i< asize; i++)
{
(*myArray)[i].PrintOn(cout);
cout << '\n';
cout.flush();
}


cout << "Print elements with PrintContentsOn():\n";
myArray->PrintContentsOn( cout );
cout << "\n";

cout << "Deleting the array\n";
myArray->Empty(TRUE);
delete myArray;

cout << "\nTEST COMPLETED !!\n";
cout << "\n";
cout.flush();

}

/* __o0o__ */

5.2 AUTOMATIC POINTERS

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testAutoPtr.C,v 1.28 1998/08/28 08:54:33 vltsccm Exp $"
*
* testBag.C
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#include <fndPort.h>

#include <stdio.h>
#include <stream.h>
#include <fndAUTO_PTR.h>
#include <fndSTRING.h>

class TEST_OBJECT
{
public:
TEST_OBJECT(char *objName)
{
name = objName;
printf(" - Creating %s\n",(const char*)name);
}
~TEST_OBJECT() { printf(" - Deleting %s\n",(const char*)name);}
void Do() { printf(" - Doing %s\n",(const char*)name);}

fndSTRING name;
};

/* Defining a type name for the template */
typedef fndAUTO_PTR<TEST_OBJECT> TEST_APTR;

/* Create a global auto pointer */
/* It will be utomatically deleted */
/* on application temrmination */
TEST_APTR testGlob;

main( unsigned int, char *[] )

{
printf("Create the auto pointer and assign an object\n");
TEST_APTR test1(new TEST_OBJECT("Obj1"));

printf("Create a new object, assign it to the global \n");
printf("auto pointer and forget about it. \n");
printf("It will be deleted at application termination\n");
testGlob.Take(new TEST_OBJECT("Global"));

printf("The auto pointer behaves just like a pointer\n");
test1->Do();

printf("Create a local scope\n");
{
printf("Entering the scope I create a new object on the heap\n");
printf("and I assign it to the auto pointer on the stack \n");
TEST_APTR test2(new TEST_OBJECT("Obj2"));

printf("When the object exit of scope, the handled auto pointer\n");
printf("is deleted automatically \n");
}

printf("Create a local scope\n");
{
printf("Entering the scope I create a new object on the heap\n");
printf("and I assign it to the auto pointer on the stack \n");
TEST_APTR test3(new TEST_OBJECT("Obj3"));

printf("Then I create another object and I give it to the\n");
printf("auto pointer. Since it owns the original one, it \n");
printf("is immediately deleted \n");
test3.Take(new TEST_OBJECT("Obj4"));

printf("I create another auto ptr and I transfer to it\n");
printf("by constructor the ownership of the object \n");
printf("handled by test3 \n");
TEST_APTR test4(test3);

printf("Now they both behave as valid pointers to the same object\n");
test3->Do();
test4->Do();

printf("I create a third auto ptr and I transfer to it\n");
printf("by assignemend the ownership of the object \n");
printf("handled by test4 (test 3 not owner any more) \n");
TEST_APTR test5;

test5 = test4;

printf("Now they all behave as valid pointers to the same object\n");
test3->Do();
test4->Do();
test5->Do();

printf("When the objects exit of scope, the handled auto pointer\n");
printf("is deleted automatically, but only by the real owner \n");
}

printf("Create a local scope\n");
{
printf("Entering the scope I create a new object on the heap\n");
printf("and I assign it to the auto pointer on the stack \n");
TEST_APTR test6(new TEST_OBJECT("Obj5"));

printf("The operator* allow to get a reference to the object\n");
TEST_OBJECT &ref = *test6;

ref.Do();

printf("While the get method is a convenient way to get a pointer\n");
TEST_OBJECT *ptr = test6.Get();

ptr->Do();

printf("But the object is still owned by the auto pointer\n");
test6->Do();
printf("And is deleted on exit from scope with the auto pointer\n");
}

printf("Create normal pointer\n");
TEST_OBJECT *ptr = NULL;

printf("Create a local scope\n");
{
printf("Entering the scope I create a new object on the heap\n");
printf("and I assign it to the auto pointer on the stack \n");
TEST_APTR test7(new TEST_OBJECT("Obj6"));

printf("If I explicitly release the object, then I \n");
printf("have to take care of deleting it asplicitly\n");
ptr = test7.Release();

printf("Since when I exit from scope it is not deleted\n");
printf("because the auto pointer is not any more owner\n");
}
printf("So I call explicitly delete\n");
delete ptr;

printf("Finally I exit and variable in the main\n");
printf("and global scope are deleted\n");
return 0;
}

/* __o0o__ */

5.3 THE fndBAG

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testBag.C,v 1.28 1998/08/28 08:54:11 vltsccm Exp $"
*
* testBag.C
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif
#ifndef fndBAG_H
#include <fndBAG.h>
#endif
#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif


char *status[] = { "Empty", "Not Empty" };
char *found[] = { "not been found", "been found" };


main( unsigned int, char *[] )

{
fndBAG *myTable = new fndBAG();

cout << "I have created an object of class: " << myTable->NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable->IsEmpty() ] << "\n";
cout.flush();

fndSTRING* element0= new fndSTRING( "ELEMENT0" );
myTable->Add( *element0 );
fndSTRING* element1= new fndSTRING( "ELEMENT1" );
myTable->Add( *element1 );
fndSTRING* element2= new fndSTRING( "ELEMENT2" );
myTable->Add( *element2 );
fndSTRING* element3= new fndSTRING( "ELEMENT3" );
myTable->Add( *element3 );
cout << "Added 4 elements\n"; cout.flush();

/*******************************************/
/* Ask how many items are in the container */
/*******************************************/
int asize;
asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();


myTable->Detach(*element2);
cout << "Detached ELEMENT2\n"; cout.flush();

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();

cout << "Element ";
element2->PrintOn( cout);
cout << " has " << found[ myTable->FindMember(*element2) != NOOBJECT] <<
" in the table\n";
cout.flush();

cout << "Element ";
element3->PrintOn( cout);
cout << " has " << found[ myTable->FindMember(*element3) != NOOBJECT] <<
" in the table\n";
cout.flush();

/*************************/
/* Delete the hash table */
/*************************/
delete myTable;
cout << "Bag deleted.\n";
cout.flush();

/*************************/
/* Creates a new one */
/*************************/
myTable = new fndBAG();

cout << "I have created an object of class: " << myTable->NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable->IsEmpty() ] << "\n";
cout.flush();

myTable->Add( *element0 );
myTable->Add( *element1 );
myTable->Add( *element2 );
myTable->Add( *element3 );
cout << "Added 4 elements\n"; cout.flush();

asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();

cout << "Calling Empty(TRUE) method for the table\n";
myTable->Empty(TRUE);

cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();

cout << "Deleting the table\n";
delete myTable;

cout << "\nTEST COMPLETED !!\n";
cout << "\n";
cout.flush();


}

/* __o0o__ */

5.4 THE fndDEQUE

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testDeque.C,v 1.28 1998/08/28 08:54:14 vltsccm Exp $"
*
* testDeque.C
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif
#ifndef fndDEQUE_H
#include <fndDEQUE.h>
#endif
#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif


char *status[] = { "Empty", "Not Empty" };
char *found[] = { "not been found", "been found" };


int main( unsigned int, char *[] )

{
fndDEQUE *myTable = new fndDEQUE();

cout << "I have created an object of class: " << myTable->NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable->IsEmpty() ] << "\n";
cout.flush();

fndSTRING* element0= new fndSTRING( "ELEMENT0" );
myTable->PutLeft( *element0 );
fndSTRING* element1= new fndSTRING( "ELEMENT1" );
myTable->PutLeft( *element1 );
fndSTRING* element2= new fndSTRING( "ELEMENT2" );
myTable->PutLeft( *element2 );
fndSTRING* element3= new fndSTRING( "ELEMENT3" );
myTable->PutLeft( *element3 );
cout << "Put 4 elements to left\n"; cout.flush();

int asize;
asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

myTable->PutRight( *element0 );
myTable->PutRight( *element1 );
myTable->PutRight( *element2 );
myTable->PutRight( *element3 );
cout << "Put 4 elements to right\n"; cout.flush();

asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();

myTable->GetLeft();
myTable->GetRight();
cout << "Get 2 elements (one left and one right)\n"; cout.flush();

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();


/********************/
/* Delete the table */
/********************/
delete myTable;
cout << "Table deleted.\n";
cout.flush();

/*************************/
/* Creates a new one */
/*************************/
myTable = new fndDEQUE();

cout << "I have created an object of class: " << myTable->NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable->IsEmpty() ] << "\n";
cout.flush();

myTable->PutLeft( *element0 );
myTable->PutLeft( *element1 );
myTable->PutLeft( *element2 );
myTable->PutLeft( *element3 );
cout << "Put 4 elements to left\n"; cout.flush();

asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

delete myTable;
delete element0;
delete element1;
delete element2;
delete element3;

}

/* __o0o__ */

5.5 THE fndDICTIONARY

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testDictionary.C,v 1.28 1998/08/28 08:54:16 vltsccm Exp $"
*
* testDictionary.C
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif

#ifndef fndASSOCIATION_H
#include <fndASSOCIATION.h>
#endif
#ifndef fndDICTIONARY_H
#include <fndDICTIONARY.h>
#endif
#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif

/* Sample dictionary description file */
#if 0
012345678_01 Prova 1
012345678_02 Prova 2
012345678_03 Prova 3
012345678_04 Prova 4
012345678_05 Prova 5
012345678_06 Prova 6
012345678_07 Prova 7
012345678_08 Prova 8
012345678_09 Prova 9
012345678_10 Prova 10
012345678_11 Prova 11
012345678_12 Prova 12
#endif

char *array[] = {
"012345678_01",
"012345678_02",
"012345678_09",
"012345678_07",
"012345678_54",
"012345678_03",
"012345678_04",
"012345678_06",
"012345678_08",
"012345678_99",
"012345678_10",
"012345678_05",
"012345678_11",
"012345678_12",
""
};

char *status[] = { "Empty", "Not Empty" };
char *found[] = { "not been found", "been found" };


main( unsigned int argc, char *[] )

{
int i;
fndASSOCIATION *asso;
fndDICTIONARY myTable;

myTable.DelItemsOnDelete(TRUE);

FILE *fileAperto;
char readBuff[100];

cout <<"I have created an object of class: " << myTable.NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable.IsEmpty() ] << "\n";
cout << "\nLoading data ..... Please wait !!!\n\n";
cout.flush();

/******************************/
/* Load dictionary from file */
/******************************/
fileAperto = fopen("testDictionary.dat" , "r");
if(fileAperto == NULL)
{
printf("Cannot open file %s\n", "testDictionary.dat" );
exit(-1);
}

for (i=0; i<12; i++)
{
fgets(readBuff,100,fileAperto);
readBuff[12] = '\0';
fndSTRING *key = new fndSTRING(readBuff);
fndSTRING *value = new fndSTRING(readBuff+13);
asso = new fndASSOCIATION( *key, *value);
myTable.Add(*asso);
}

int asize;
asize=myTable.GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";



/******************************/
/* Search for definition loop */
/******************************/

char buffer[100];
fndSTRING temp;
fndASSOCIATION *found ;


int flag = TRUE;
int count = 0;
while(flag)
{
if(argc > 1)
{
cout << "\nEnter a definition (CTRL-C to end):\n";
cout.flush();
gets(buffer);
temp = buffer;
}
else
{
if(array[count][0] == '\0') break;
temp = array[count++];
}

found = &(myTable.Lookup(temp));
if( *found == NOOBJECT)
{
cout << "This definition is not in the dictionary !!!\n";
cout.flush();
}
else
{
cout << "The definition is:\n";
found->PrintOn(cout);
cout.flush();
}
}

}

/* __o0o__ */

5.6 THE fndLIST

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testList.C,v 1.28 1998/08/28 08:54:16 vltsccm Exp $"
*
* testList.C
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif
#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif
#ifndef fndLIST_H
#include <fndLIST.h>
#endif
#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif




int main( unsigned int, char *[] )

{
int size;

/**************************************/
/* Create a dynamic EMPTY double list */
/**************************************/
fndLIST *myDoubleList= new fndLIST();

/************************************************/
/* Now add 3 static fndSTRING() objects to it */
/************************************************/
/* Note that elements are added at head of list */

fndSTRING element0( "ELEMENT0" );
myDoubleList->Add( element0 );

fndSTRING element1( "ELEMENT1" );
myDoubleList->Add( element1 );

fndSTRING element2( "ELEMENT2" );
myDoubleList->Add( element2 );

/************************/
/* Gets some statistics */
/************************/
printf ( "Container subclass statistics:\n");

/* Class name */
printf ( " class name : %s\n", myDoubleList->NameOf());

/* Number of elements in the list */
size=myDoubleList->GetItemsInContainer();
printf ( " number of items : %d\n", size );

/* Head and tail of the list */
cout << " head element : ";
myDoubleList->PeekAtHead().PrintOn(cout);
cout << "\n";
cout << " tail element : ";
myDoubleList->PeekAtTail().PrintOn(cout);
cout << "\n";
cout.flush();

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "\nPrinting list contents:\n";
myDoubleList->PrintOn( cout );
cout << '\n';
cout.flush();

/****************************************************/
/* Add dynamic elements at head and at tail of list */
/****************************************************/
fndSTRING* element3= new fndSTRING( "ELEMENT3" );
myDoubleList->AddAtHead( *element3 );

fndSTRING* element4= new fndSTRING( "ELEMENT-1" );
myDoubleList->AddAtTail( *element4 );

/***********************************/
/* Print again whole list contents */
/***********************************/
cout << "\nPrinting list contents:\n";
myDoubleList->PrintOn( cout );
cout << '\n';
cout.flush();

/***********************/
/* Test iterator usage */
/***********************/

/********************************************/
/* Create a new iterator and initializes it */
fndLIST_ITERATOR &myIterator =
(fndLIST_ITERATOR &)myDoubleList->InitIterator();

/****************************************************/
/* Run forward over all elements using the iterator */
cout << "\nElements found by running forward the iterator are:\n";
while( (int)myIterator)
{
// fndOBJECT &obj = myIterator; /* this works */
// fndOBJECT &obj = (fndOBJECT &obj)myIterator; /* this DOES NOT WORK */

fndSTRING &obj = (fndSTRING &)myIterator.GetCurrent();
obj.PrintOn(cout);
myIterator++;
cout << "\n";
cout.flush();
}

/****************************************************/
/* Reset the iterator */
cout << "\nElements found by running again the iterator are:\n";
myIterator.Restart();
while( (int)myIterator)
{
((fndSTRING &)myIterator++).PrintOn(cout);
cout << "\n";
cout.flush();
}

/*****************************************************/
/* Run backward over all elements using the iterator */
size=myDoubleList->GetItemsInContainer();
cout << "\nElements found by running backward the iterator are:\n";
myIterator.Restart();
while(--size) myIterator++;

while( (int)myIterator )
{
((fndSTRING &)myIterator--).PrintOn(cout);
cout << "\n";
cout.flush();
}

delete &myIterator;

/*****************************************************/
/* Run using a reverse iterator */
fndLIST_ITERATOR &myIterator2 =
(fndLIST_ITERATOR &)myDoubleList->InitReverseIterator();
cout << "\nElements found by a reverse iterator are:\n";
while( (int)myIterator2 )
{
((fndSTRING &)myIterator2--).PrintOn(cout);
cout << "\n";
cout.flush();
}

delete &myIterator2;

/**************************/
/* Test detach and insert */
/**************************/

/*****************************************************/
/* Detach an element searching from.... */
/* head of list */
myDoubleList->DetachFromHead(element0); // non volatile element
/* tail of list (elements is dynamic, so we can destroy it */
myDoubleList->DetachFromTail(*element4, TRUE); // dynamic element
cout << "\nDetached element ELEMENT0 searching from head\n";
cout << "and element ELEMENT-1 searching from tail:\n";
myDoubleList->PrintOn(cout);
cout.flush();

/*****************************************************/
/* Reinsert elements */
myDoubleList->AddAtTail(element0); // non volatile element
cout << "\nReinserted elements at tail\n";
myDoubleList->PrintOn(cout);
cout.flush();

/*****************************************************/
/* Detach an elements by pos */
myDoubleList->Detach(100);
cout << "\nDetached element at position 100 (does not exist)\n";
myDoubleList->Detach(2);
cout << "\nDetached element at position 2\n";
myDoubleList->Detach(0);
cout << "\nDetached element at position 0\n";
myDoubleList->PrintOn(cout);
cout.flush();

/*****************************************************/
/* Add and destroy elements */
fndSTRING* elementAA= new fndSTRING( "ELEMENT-AA" );
myDoubleList->AddAtHead( *elementAA );
fndSTRING* elementAB= new fndSTRING( "ELEMENT-AB" );
myDoubleList->AddAtHead( *elementAB );
cout << "\nAdded elements at head\n";
myDoubleList->PrintOn(cout);
cout.flush();

myDoubleList->DetachFromTail( *elementAA );
myDoubleList->DetachFromTail( *elementAB );
cout << "\nDetached elements from tail\n";
myDoubleList->PrintOn(cout);
cout.flush();

/**************************/
/* Test Empty() method */
/**************************/

myDoubleList->Empty();
cout << "\nNow list is Empty (elements not destroyed)\n";
myDoubleList->PrintOn(cout);
cout.flush();


fndSTRING *testEl1 = new fndSTRING( "TEST" );
myDoubleList->Add( *testEl1 );
fndSTRING *testEl2 = new fndSTRING( "TEST1" );
myDoubleList->Add( *testEl2 );
fndSTRING *testEl3 = new fndSTRING( "TEST2" );
myDoubleList->Add( *testEl3 );
cout << "\nNow list is filled with dynamic elements\n";
myDoubleList->PrintOn(cout);
cout.flush();

/**************************/
/* Test copy constructor */
/**************************/
fndLIST *myDoubleList2 = new fndLIST(*myDoubleList);
cout << "\nCreated a new list with copy constructor:\n";
myDoubleList->PrintOn(cout);
myDoubleList2->Empty();

myDoubleList->Empty();
cout << "\nNow list is Empty (elements destroyed)\n";
myDoubleList->PrintOn(cout);
cout.flush();

delete myDoubleList;
delete myDoubleList2;
delete element3;
delete elementAA;
delete elementAB;
delete testEl1;
delete testEl2;
delete testEl3;

return 0;
}

/* __o0o__ */

5.7 THE fndNAME_MAP

/*******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: testNameMap.C,v 1.28 1998/08/28 08:54:28 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 01/06/95 created
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#define _POSIX_SOURCE 1
#ifndef vltPort_H
#include "vltPort.h"
#endif

static char *rcsId="@(#) $Id: testNameMap.C,v 1.28 1998/08/28 08:54:28 vltsccm Exp $";
static void *use_rcsId = ((void)&use_rcsId,(void *) &rcsId);


/*
* System Headers
*/
#ifndef _STDLIB_INCLUDED
#include "stdlib.h"
#endif
#ifndef _STDIO_INCLUDED
#include "stdio.h"
#endif

/*
* Local Headers
*/

/*
* Signal catching functions
*/
#ifndef fndNAME_MAP_H
#include "fndNAME_MAP.h"
#endif

/*
* Main function
*/

fndNAME_AND_INDEX testMap[] = { {"CTR1",2},
{"CTR2",4},
{"AAABBB",0},
{"ABABBB",10},
{"G",3} };


fndNAME_MAP testClass(testMap, fndNELEM(testMap));

void PrintTable()
{
printf("Table contents:\n");
int size = fndNELEM(testMap);
for(int i=0; i<size;i++)
printf(" Index: %2.2d, String: \"%10.10s\"\n",
testMap[i].index, testMap[i].name);
}

void PrintIndex(const char *string)
{
int index = testClass.Index(string);
printf("String \"%10.10s\" has index %d (-1 means not found)\n", string,index);
}

void PrintString(unsigned int index)
{
const char *string = testClass.String(index);
if(string == NULL)
printf("Index %d does not exist\n",index);
else
printf("Index %d correspond to string \"%10.10s\"\n",index,string);
}

int main (int, char *[])
{
PrintTable();

PrintIndex("CTR2");
PrintIndex("");
PrintIndex("CTR1");
PrintIndex("G");
PrintIndex("AAA");

PrintString(4);
PrintString(0);
PrintString(1);
PrintString(2);

return(EXIT_SUCCESS);
}

/* __o0o__ */

5.8 THE fndSTACK

/*******************************************************************************
* E.S.O. - VLT project
#
# "@(#) $Id: testStack.C,v 1.28 1998/08/28 08:54:26 vltsccm Exp $"
*
* testStack.C
*
* who when what
* -------- -------- ----------------------------------------------
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif
#ifndef fndSTACK_H
#include <fndSTACK.h>
#endif
#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif


char *status[] = { "Empty", "Not Empty" };
char *found[] = { "not been found", "been found" };


int main( unsigned int, char *[] )

{
fndSTACK *myTable = new fndSTACK();

cout << "I have created an object of class: " << myTable->NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable->IsEmpty() ] << "\n";
cout.flush();

fndSTRING* element0= new fndSTRING( "ELEMENT0" );
myTable->Push( *element0 );
fndSTRING* element1= new fndSTRING( "ELEMENT1" );
myTable->Push( *element1 );
fndSTRING* element2= new fndSTRING( "ELEMENT2" );
myTable->Push( *element2 );
fndSTRING* element3= new fndSTRING( "ELEMENT3" );
myTable->Push( *element3 );
cout << "Pushed 4 elements\n"; cout.flush();

int asize;
asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();

fndSTRING* popped;
popped = (fndSTRING*)&myTable->Pop();
cout << "Popped " << (const char*)*popped << "\n"; cout.flush();
popped = (fndSTRING*)&myTable->Pop();
cout << "Popped " << (const char*)*popped << "\n"; cout.flush();
cout << "Popped 2 elements\n"; cout.flush();

/*****************************/
/* Print whole list contents */
/*****************************/
cout << "The elements are:\n";
cout.flush();
myTable->PrintOn( cout );
cout << '\n';
cout.flush();


/********************/
/* Delete the table */
/********************/
delete myTable;
cout << "Stack deleted.\n";
cout.flush();

/*************************/
/* Creates a new one */
/*************************/
myTable = new fndSTACK();

cout << "I have created an object of class: " << myTable->NameOf() << "\n";
cout << " Its status is now: " << status[ !myTable->IsEmpty() ] << "\n";
cout.flush();

myTable->Push( *element0 );
myTable->Push( *element1 );
myTable->Push( *element2 );
myTable->Push( *element3 );
cout << "Pushed 4 elements\n"; cout.flush();

asize=myTable->GetItemsInContainer();
cout << "The table contains " << asize << " elements\n";

/********************/
/* Delete the table */
/********************/
myTable->Empty(TRUE);
delete myTable;
cout << "Stack deleted.\n";
cout.flush();

return 0;
}

/* __o0o__ */

5.9 THE fndSTRING

/******************************************************************************
* E.S.O. - VLT project
*
* "@(#) $Id: testString.C,v 1.28 1998/08/28 08:54:28 vltsccm Exp $"
*
* who when what
* -------- -------- ----------------------------------------------
* gchiozzi 09/08/95 Added many new methods
*
*/

/************************************************************************
* NAME
*
*
* SYNOPSIS
*
*
* DESCRIPTION
*
* FILES
*
* ENVIRONMENT
*
* COMMANDS
*
* RETURN VALUES
*
* CAUTIONS
*
* EXAMPLES
*
* SEE ALSO
*
* BUGS
*
*------------------------------------------------------------------------
*/

#ifndef fndPort_H
#include <fndPort.h>
#endif

#ifndef _STDIO_INCLUDED
#include <stdio.h>
#endif
#ifndef _STREAM_INCLUDED
#include <stream.h>
#endif


#ifndef fndSTRING_H
#include <fndSTRING.h>
#endif




int main( unsigned int, char *[] )

{
cout << "\nTest for string class\n"; cout.flush();


/*
* Constructors
*/

// Create strings
cout << "String constructor\n"; cout.flush();
fndSTRING str1 = "Str1";
fndSTRING str2 = "Str2";
cout << "String is: " << str1 << "\n"; cout.flush();
cout << "String is: " << str2 << "\n"; cout.flush();

// Assign from STRING to char *
cout << "Assign from STRING to char *\n"; cout.flush();
const char *ch1 = str1;
const char *ch2 = str1;
const char *ch3 = str1;
cout << "const char * is " << ch1 << "\n"; cout.flush();
cout << "const char * is " << ch2 << "\n"; cout.flush();

cout << "Copy constructor\n"; cout.flush();
fndSTRING copy(str1);
cout << "Copy of " << str1 << " is " << copy << "\n"; cout.flush();

cout << "Fill constructor (10 a)\n"; cout.flush();
fndSTRING fill('a',10);
cout << "String is: " << fill << "\n"; cout.flush();


/*
* Basic methods
*/

cout << "Full len (including null terminator) is: " << fill.GetLen()
<< "\n"; cout.flush();

cout << "Assign operator\n"; cout.flush();
fill = str1;
cout << "String is: " << fill << "\n"; cout.flush();

/*
* Concatenation
*/
cout << "\nConcatenation methods\n"; cout.flush();
fndSTRING conc = str1 + str2;
cout << "str1 + str2: " << conc << "\n"; cout.flush();

conc = str2 + str1;
cout << "str2 + str1: " << conc << "\n"; cout.flush();

conc += str1;
cout << "conc += str1: " << conc << "\n"; cout.flush();

fndSTRING conc2 = (fndSTRING)"AAA" + "BBB" + conc;
cout << "AAA + BBB + conc: " << conc2 << "\n"; cout.flush();
conc2 += "CCC";
cout << "conc2 + CCC: " << conc2 << "\n"; cout.flush();

/*
* Compare methods
*/

ch1 = "Str1";
ch2 = "STR1";
ch3 = "Char";

cout << "\nCompare methods\n";
cout << "operator ==\n";
cout << "Is " << str1 << " == " << str2 << " ? : "
<< (str1 == str2) << "\n"; cout.flush();
cout << "Is " << str1 << " == " << ch1 << " ? : "
<< (str1 == ch1) << "\n"; cout.flush();
cout << "Is " << str1 << " == " << ch3 << " ? : "
<< (str1 == ch3) << "\n"; cout.flush();
cout << "Is " << ch1 << " == " << str1 << " ? : "
<< (ch1 == str1) << "\n"; cout.flush();
cout << "Is " << ch3 << " == " << str2 << " ? : "
<< (ch3 == str2) << "\n"; cout.flush();

cout << "\nCompare method (fndSTRING)\n";
cout << "Compare " << str1 << " and " << str2 << " IGNORE : "
<< str1.Compare(str2) << "\n"; cout.flush();
cout << "Compare " << str1 << " and " << str2 << " IGNORE : "
<< str1.Compare(str2,fndSTR_IGNORE) << "\n"; cout.flush();
cout << "Compare " << str1 << " and " << str2 << " SENSIT : "
<< str1.Compare(str2,fndSTR_SENSITIVE) << "\n"; cout.flush();

cout << "Compare " << str1 << " and " << str1 << " IGNORE : "
<< str1.Compare(str1,fndSTR_IGNORE) << "\n"; cout.flush();
cout << "Compare " << str1 << " and " << str1 << " SENSIT : "
<< str1.Compare(str1,fndSTR_SENSITIVE) << "\n"; cout.flush();

cout << "Compare method (char *)\n";
cout << "Compare " << str1 << " and " << ch2 << " IGNORE : "
<< str1.Compare(ch2,fndSTR_IGNORE) << "\n"; cout.flush();
cout << "Compare " << str1 << " and " << ch2 << " SENSIT : "
<< str1.Compare(ch2,fndSTR_SENSITIVE) << "\n"; cout.flush();

cout << "\nFind method\n";
str1 = "This is a long string";
ch1 = "str";
unsigned int pos;
cout << "Search \"" << ch1 << "\" in \"" << str1 << "\" (IGNORE):"
<< str1.Find(ch1,&pos,fndSTR_IGNORE) << " at " << pos
<< "\n"; cout.flush();
cout << "Search \"" << ch1 << "\" in \"" << str1 << "\" (SENSITIVE):"
<< str1.Find(ch1,&pos,fndSTR_SENSITIVE) << " at " << pos
<< "\n"; cout.flush();
ch1 = "STR";
cout << "Search \"" << ch1 << "\" in \"" << str1 << "\" (IGNORE):"
<< str1.Find(ch1,&pos,fndSTR_IGNORE) << " at " << pos
<< "\n"; cout.flush();
cout << "Search \"" << ch1 << "\" in \"" << str1 << "\" (SENSITIVE):"
<< str1.Find(ch1,&pos,fndSTR_SENSITIVE) << " at " << pos
<< "\n"; cout.flush();
cout << "Search \"" << "ing" << "\" in \"" << str1 << "\" (SENSITIVE):"
<< str1.Find("ing",&pos,fndSTR_SENSITIVE) << " at " << pos
<< "\n"; cout.flush();
cout << "Search \"" << "T" << "\" in \"" << str1 << "\" (SENSITIVE):"
<< str1.Find("T",&pos,fndSTR_SENSITIVE) << " at " << pos
<< "\n"; cout.flush();

cout << "\nDelete method\n";
str1 = "0123456789";
str1.Delete(0,3);
cout << "Delete from 0 for 3: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Delete(1,1);
cout << "Delete from 1 for 1: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Delete(3,7);
cout << "Delete from 3 for 7: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Delete(4,15);
cout << "Delete from 4 for 15: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Delete(9,1);
cout << "Delete from 9 for 1: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Delete(10,5);
cout << "Delete from 10 for 5: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Delete(4,0);
cout << "Delete from 4 for 0: " << str1 << "\n"; cout.flush();


cout << "\nInsert methods\n";
str1 = "0123456789";
str1.Insert(0,'x');
cout << "Insert x at pos 0: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(4,'x');
cout << "Insert x at pos 4: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(9,'x');
cout << "Insert x at pos 9: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(10,'x');
cout << "Insert x at pos 10: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(15,'x');
cout << "Insert x at pos 15: " << str1 << "\n"; cout.flush();

str1 = "0123456789";
str1.Insert(0,"xxx");
cout << "Insert xxx at pos 0: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(4,"xxx");
cout << "Insert xxx at pos 4: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(9,"xxx");
cout << "Insert xxx at pos 9: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(10,"xxx");
cout << "Insert xxx at pos 10: " << str1 << "\n"; cout.flush();
str1 = "0123456789";
str1.Insert(15,"xxx");
cout << "Insert xxx at pos 15: " << str1 << "\n"; cout.flush();

cout << "\nSubstring method\n";
str1 = "0123456789";
str2 = str1.SubStr(0,3);
cout << "Substr from 0 for 3: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(4,2);
cout << "Substr from 4 for 2: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(0,0);
cout << "Substr from 0 for 0: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(0,1);
cout << "Substr from 0 for 1: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(1,15);
cout << "Substr from 1 for 15: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(15,1);
cout << "Substr from 15 for 1: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(9,2);
cout << "Substr from 9 for 2: " << str2 << "\n"; cout.flush();
str1 = "0123456789";
str2 = str1.SubStr(10,2);
cout << "Substr from 10 for 2: " << str2 << "\n"; cout.flush();

cout << "\nOperator []\n";
str1 = "0123456789";
int i,max;
for(i = 0, max = str1.GetLen() -1; i < max; i++)
cout << "[" << i << "] :" << str1[i] << ",";
cout << "\n"; cout.flush();

cout << "\nToUpper() and ToLower()\n"; cout.flush();
str1 = "abcDEF;',.<>/?";
cout << "Uppercase of: " << str1 << " is: " << str1.ToUpper() << "\n";
str1 = "abcDEF;',.<>/?";
cout << "Lowercase of: " << str1 << " is: " << str1.ToLower() << "\n";

cout << "\nTest for string class completed\n\n"; cout.flush();

return 0;

} /* end main() */

/* __o0o__ */




Quadralay Corporation
http://www.webworks.com
Voice: (512) 719-3399
Fax: (512) 719-3606
sales@webworks.com
TOC PREV NEXT INDEX