Re: More on IDL

Jayakumar Muthukumarasamy ([email protected])
Tue, 20 Dec 1994 11:16:43 -0500 (EST)

>
>
> How do you use the macro. Don't you have to declare the iterator somewhere
> else?
>

Here is an example:

//- DEFINE_ITERATOR(T)
//.
//. Macro to define an iterator for a collection which holds objects
//. of type T.
//-
#define DEFINE_ITERATOR(T) \
interface T ## _Iterator { \
T next() \
T prev() \
T first() \
T last() \
}


//- Iterator(T)
//.
//. Macro to declare an iterator for a collection which holds objects
//. of type T.
//-
#define Iterator(T) T ## _Iterator

Inorder to use an iterator, we will first have to define the specific
iterator. I assume all iterators will be defined in a standard IDL
file. The definition will look something like

DEFINE_ITERATOR(string);
DEFINE_ITERATOR(Iinterface);
DEFINE_ITERATOR(Iattribute);

etc.

Once, this is done, we can use it as Iterator(string), Iterator(Iinterface),
Iterator(Iattribute) etc. The operator "##" in the macros above is the
token pasting operator. i.e. the semantics of "a ## b" is to concatenate
the two tokens "a" and "b" and reparse it as the single token "ab".

-jk