Programming Reference: ODTypeListIterator

# Programming Reference

## ODTypeListIterator

Class Definition File | TypLsItr.idl
Class C++ Binding | TypLsItr.xh

Class Hierarchy

    SOMObject
       ODObject
          ODTypeListIterator

Description

An object of the ODTypeListIterator class provides access to each element of a type list.

You use a type-list iterator to apply an operation to each element of a type list. For example, a part might use a type-list iterator to enumerate the part kinds that the part supports and write to storage a representation for each one.

Methods of the ODTypeListIterator class return copies of the elements in the type list. This design prevents you from accidentally changing the content of the type list. When you use a type-list iterator, be sure to delete each copied string to avoid a memory leak.

Your part creates a type-list iterator object by calling the type list object's CreateTypeListIterator method, which returns a reference to a type-list iterator object.

While you are using a type-list iterator, you should not modify or delete the type list that created it. You must postpone adding elements to or removing elements from the type list until after you have deleted the iterator.

For more information on accessing objects through iterators, see the chapter on OpenDoc runtime features in the OpenDoc Programming Guide.

Methods

The methods defined by the ODTypeListIterator class include:

- First
- IsNotComplete
- Next

Overridden Methods | There are no methods overridden by the ODTypeListIterator class.

### First

This method begins the iteration and returns a copy of the first element in the type list that created this type-list iterator.

Signature

    ODType First ()

Parameters

None.

Returns

rv (ODType) - returns

  A copy of the first element in the type list or kODNULL if the type list is empty.

Remarks

Your part must call this method before calling this type-list iterator's IsNotComplete method for the first time. This method may be called multiple times. Each call resets the iteration.

You must deallocate the returned type value when it is no longer needed.

Exception Handling

kODErrIteratorOutOfSync | The type list was modified while the iteration was in progress.
kODErrOutOfMemory | There is not enough memory to create the type.

### IsNotComplete

This method indicates whether the iteration is incomplete.

Signature

    ODBoolean IsNotComplete ()

Parameters

Returns

None.

rv (ODBoolean) - returns

  A flag indicating whether the iteration is incomplete.

  kODTrue | The iteration is incomplete.
  kODFalse | The iteration is complete.

Remarks

Your part calls this method to test whether more elements remain in the type list. This method returns kODTrue if the preceding call to the First or Next method found an element. This method returns kODFalse when you have examined all the elements (that is, when the previous call to First or Next returned kODNULL). If the type list that created this iterator is empty, this method always returns kODFalse.

Exception Handling

kODErrIteratorNotInitialized | This method was called before calling the First or Next method to begin the iteration.
kODErrIteratorOutOfSync | The type list was modified while the iteration was in progress.

### Next

This method returns a copy of the next element in the type list that created this type-list iterator.

Signature

    ODType Next ()

Parameters

None.

Returns

rv (ODType) - returns

  A copy of the next element in the type list or kODNULL if you have reached the end of the type list.

Remarks

If your part calls this method before calling this type-list iterator's First method to begin the iteration, then this method works the same as calling the First method.

You must deallocate the returned type value when it is no longer needed.

Exception Handling

kODErrIteratorOutOfSync | The type list was modified while the iteration was in progress.
kODErrOutOfMemory | There is not enough memory to create the type.

[ Top | Previous | Next | Contents | Index | Documentation Homepage ]