An iterator encapsulates a list of objects and a cursor that maintains the current position in the list. A C or C++ application uses an iterator to retrieve each object in the list in turn.
When an iterator is created, the position of the cursor is before the first object. An application uses an iterator to retrieve each object in turn. To retrieve the objects, the application uses the following three methods of the Iterator class:
The Iterator class is equivalent to the Enumerator class in Java. XMS .NET is similar to Java and uses an IEnumerator interface.
/********************************************************/ /* XMS Sample using an iterator to browse properties */ /********************************************************/ rc = xmsMsgGetProperties(hMsg, &it, xmsError); if (rc == XMS_OK) { rc = xmsIteratorHasNext(it, &more, xmsError); while (more) { rc = xmsIteratorGetNext(it, (xmsHObj)&p, xmsError); if (rc == XMS_OK) { xmsPropertyGetName(p, name, 100, &len, xmsError); printf("Property name=\"%s\"\n", name); xmsPropertyGetTypeId(p, &type, xmsError); switch (type) { case XMS_PROPERTY_TYPE_INT: { xmsINT value=0; xmsPropertyGetInt(p, &value, xmsError); printf("Property value=%d\n", value); break; } case XMS_PROPERTY_TYPE_STRING: { xmsINT len=0; char value[100]; xmsPropertyGetString(p, value, 100, &len, xmsError); printf("Property value=\"%s\"\n", value); break; } default: { printf("Unhandled property type (%d)\n", (int)type); } } xmsPropertyDispose(&p, xmsError); } rc = xmsIteratorHasNext(it, &more, xmsError); } printf("Finished iterator....\n"); xmsIteratorDispose(&it, xmsError); } /********************************************************/