// // wchiter.h Definitions for the WATCOM Container Hash Iterator Classes // // ========================================================================= // // Open Watcom Project // // Copyright (c) 2002-2010 Open Watcom Contributors. All Rights Reserved. // Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. // // This file is automatically generated. Do not edit directly. // // ========================================================================= // #ifndef _WCHITER_H_INCLUDED #define _WCHITER_H_INCLUDED #ifndef _ENABLE_AUTODEPEND #pragma read_only_file; #endif #ifndef __cplusplus #error This header file requires C++ #endif #ifndef _COMDEF_H_INCLUDED #include <_comdef.h> #endif #ifndef _WCDEFS_H_INCLUDED #include #endif #ifndef _WCEXCEPT_H_INCLUDED #include #endif #ifndef _WCHASH_H_INCLUDED #include #endif // // The WCHashIterBase is the base class for all hash iterator classes // // WCIterExcept is used as a base class to provide exception handling // // class WCHashIterBase : public WCIterExcept { private: typedef WCSLink BaseHashLink; protected: const WCHashBase * curr_hash; WCIsvSListIter bucket_iter; unsigned curr_bucket; int at_end; _WPRTLINK WCbool base_advance(); inline WCbool base_hash_valid() const { return( ( curr_hash != 0 )&&( curr_hash->num_buckets > 0 ) ); }; public: inline WCHashIterBase() : curr_hash( 0 ), bucket_iter() , curr_bucket( 0 ), at_end( 0 ) {}; inline WCHashIterBase( const WCHashBase& hash ) : curr_hash( &hash ), bucket_iter() { reset(); }; inline virtual ~WCHashIterBase() = 0; _WPRTLINK void reset(); }; WCHashIterBase::~WCHashIterBase() {}; // // The WCValHashTableIter is the iterator for the WCValHashTable class // // WCIterExcept is used as a base class to provide exception handling // template class WCValHashTableIter : public WCHashIterBase { protected: typedef WCHashLink HashLink; // get the current hashlink object, or 0 if current undefined WCHashLink *base_curr_hashlink() const; public: inline WCValHashTableIter() {}; inline WCValHashTableIter( const WCValHashTable& hash ) : WCHashIterBase( hash ) {}; inline virtual ~WCValHashTableIter() {}; inline const WCValHashTable *container() const { if( curr_hash == 0 ) { base_throw_undef_iter(); } return( (const WCValHashTable *)curr_hash ); }; Type current() const; inline void reset() { WCHashIterBase::reset(); }; inline void reset( const WCValHashTable &hash ) { curr_hash = &hash; reset(); }; inline WCbool operator++() { return( base_advance() ); } inline WCbool operator()() { return( base_advance() ); } }; template WCHashLink *WCValHashTableIter::base_curr_hashlink() const { HashLink *link = 0; if( base_hash_valid() ) { link = (HashLink *)bucket_iter.current(); } return( link ); }; template Type WCValHashTableIter::current() const { HashLink *link = base_curr_hashlink(); if( link == 0 ) { // bucket_iter is off end or no hash to iterate over base_throw_undef_item(); Type temp; return( temp ); } return( link->data ); }; // // The WCPtrHashTableIter is the iterator for the WCPtrHashTable class. // template class WCPtrHashTableIter : public WCValHashTableIter { public: inline WCPtrHashTableIter() {}; inline WCPtrHashTableIter( const WCPtrHashTable& hash ) : WCValHashTableIter( hash ) {}; inline virtual ~WCPtrHashTableIter() {}; inline const WCPtrHashTable *container() const { return( (const WCPtrHashTable *)WCValHashTableIter::container() ); }; inline Type *current() const { return( (Type *)WCValHashTableIter::current() ); }; inline void reset() { WCValHashTableIter::reset(); }; inline void reset( const WCPtrHashTable &hash ) { WCValHashTableIter::reset( hash ); }; }; // // The WCValHashSetIter is the iterator for the WCValHashSet class. // template class WCValHashSetIter : public WCValHashTableIter { public: inline WCValHashSetIter() {}; inline WCValHashSetIter( const WCValHashSet& hash ) : WCValHashTableIter( hash ) {}; inline virtual ~WCValHashSetIter() {}; inline const WCValHashSet *container() const { return( (const WCValHashSet *)WCValHashTableIter::container() ); }; inline void reset() { WCValHashTableIter::reset(); }; inline void reset( const WCValHashSet &hash ) { WCValHashTableIter::reset( hash ); }; }; // // The WCPtrHashSetIter is the iterator for the WCPtrHashSet class. // template class WCPtrHashSetIter : public WCPtrHashTableIter { public: inline WCPtrHashSetIter() {}; inline WCPtrHashSetIter( const WCPtrHashSet& hash ) : WCPtrHashTableIter( hash ) {}; inline virtual ~WCPtrHashSetIter() {}; inline const WCPtrHashSet *container() const { return( (const WCPtrHashSet *)WCPtrHashTableIter::container() ); }; inline void reset() { WCPtrHashTableIter::reset(); }; inline void reset( const WCPtrHashSet &hash ) { WCPtrHashTableIter::reset( hash ); }; }; // // The WCValHashDictIter is the iterator for the WCValHashDict class. // // This class inherits privately to hide the current member function. // template class WCValHashDictIter : private WCValHashTableIter > { public: inline WCValHashDictIter() {}; inline WCValHashDictIter( const WCValHashDict& hash ) : WCValHashTableIter( hash ) {}; inline virtual ~WCValHashDictIter() {}; inline const WCValHashDict *container() const { return( (const WCValHashDict *)WCValHashTableIter ::container() ); }; inline wciter_state exceptions() const { return( WCValHashTableIter::exceptions() ); }; inline wciter_state exceptions( wciter_state const set_flags ) { return( WCValHashTableIter::exceptions( set_flags ) ); }; Key key() const; inline void reset() { WCValHashTableIter::reset(); }; inline void reset( const WCValHashDict &hash ) { WCValHashTableIter::reset( hash ); }; Value value() const; inline WCbool operator++() { return( WCValHashTableIter::operator++() ); }; inline WCbool operator()() { return( WCValHashTableIter::operator()() ); }; }; template Key WCValHashDictIter::key() const { HashLink *link = base_curr_hashlink(); if( link == 0 ) { // bucket_iter is off end or no hash to iterate over base_throw_undef_item(); Key temp; return( temp ); } return( link->data.key ); }; template Value WCValHashDictIter::value() const { HashLink *link = base_curr_hashlink(); if( link == 0 ) { // bucket_iter is off end or no hash to iterate over base_throw_undef_item(); Value temp; return( temp ); } return( link->data.value ); }; // // The WCPtrHashDictIter is the iterator for the WCPtrHashDict class. // template class WCPtrHashDictIter : public WCValHashDictIter { public: inline WCPtrHashDictIter() {}; inline WCPtrHashDictIter( const WCPtrHashDict& hash ) : WCValHashDictIter( hash ) {}; inline virtual ~WCPtrHashDictIter() {}; inline const WCPtrHashDict *container() const { return( (const WCPtrHashDict *)WCValHashDictIter ::container() ); }; inline Key * key() const { return( (Key *)WCValHashDictIter::key() ); }; inline void reset() { WCValHashDictIter::reset(); }; inline void reset( const WCPtrHashDict &hash ) { WCValHashDictIter::reset( hash ); }; Value *value() const { return( (Value *)WCValHashDictIter::value() ); }; }; #endif