The ITContainerIter class

Base class: ITObject

Provides a simple, syntactically compact interface for extracting C++ base-type values (such as int, long, or double) from an object. Value objects passed to an ITContainerIter object must expose either an ITContainer or ITContainCvt interface.

This class provides the following methods.
Method Description
ITContainerIter(ITContainer *), ITContainerIter(ITEssential *), ITContainerIter(ITContainCvt *) Binds an ITContainer or ITContainCvt interface into the newly constructed iterator. The values in the object can later be extracted by using the >> operator.
ITContainerIter &operator >> (ITValue *&) Extracts a pointer to the value interface of the next column. If there are no more values left, sets the ITValue pointer to NULL. This method can be used to extract the individual columns into interface pointer variables. The ITValue interface must be released by the application.
ITContainerIter &operator >> (modifiable_ lvalue &) Copies the value into the specified variable. This operation raises an exception if the column and variable type are not compatible or convertible. Valid types for the modifiable_ lvalue parameter are as follows:
  • short
  • int
  • double
  • long
  • float
  • long double
  • const char *
  • ITString
  • ITInt8
  • bool (if the C++ compiler supports bool)
ITContainerIter &ITContainerIter::operator<< (<type>) Sets the value of a contained item from the value of the C++ type given as <type>, where <type> can be any of the following type specifiers:
  • short
  • int
  • double
  • long
  • float
  • long double
  • const char *
  • ITString &
  • const ITString &
  • ITInt8
  • bool (if the C++ compiler supports bool)

ITContainerIter has a state that can be either StateOK, StateOutOfBounds, StateUninitialized, or StateConversionFailed. If ITContainerIter state is not StateOK, the use any of the operators does not perform any conversions and does not change the state or position in the container.

void Reset() Resets the state to StateUninitialized or StateOK, depending on whether the container iterator was initialized.
StateCode State() Retrieves the state of the container iterator. State might be one of the following: StateUninitialized, StateOK, StateOutOfBounds, or StateConversionFailed.

The initial state of the ITContainerIter is StateUninitialized if the value object that ITContainerIter was created on does not expose ITContainCvt or ITContainer; otherwise the initial state is StateOK. Calling ITContainerIter::Reset() resets a state to this initial state. StateOutOfBounds is set by the shift operators (<< >>) when the item position exceeds the number of items in the container. StateConversionFailed is set by the operator if the container does not expose ITContainCvt and the item does not expose ITConversions, or if the conversion function fails.

int Index() Retrieves the current container iterator index.