Skip to content

Commit cbf4b6a

Browse files
committed
Added additional operator overloads '--', '*' and '->' for ChannelList::Iterator and ChannelList::ConstIterator. Also added global operator overloads '==' and '!=' for Iterator class.
(issue #1325) Signed-off-by: Aries Moczar <arcmantis@protulae.com>
1 parent fd6bbaa commit cbf4b6a

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

src/lib/OpenEXR/ImfChannelList.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,26 @@ class IMF_EXPORT_TYPE ChannelList::Iterator
264264
IMF_EXPORT
265265
Iterator operator++ (int);
266266

267+
IMF_EXPORT
268+
Iterator& operator-- ();
269+
IMF_EXPORT
270+
Iterator operator-- (int);
271+
272+
IMF_EXPORT
273+
Channel& operator* () const;
274+
275+
IMF_EXPORT
276+
Channel* operator-> () const;
277+
267278
IMF_EXPORT
268279
const char* name () const;
269280
IMF_EXPORT
270281
Channel& channel () const;
271282

272283
private:
273284
friend class ChannelList::ConstIterator;
285+
friend bool operator== (Iterator&, Iterator&);
286+
friend bool operator!= (Iterator&, Iterator&);
274287

275288
ChannelList::ChannelMap::iterator _i;
276289
};
@@ -290,6 +303,17 @@ class IMF_EXPORT_TYPE ChannelList::ConstIterator
290303
IMF_EXPORT
291304
ConstIterator operator++ (int);
292305

306+
IMF_EXPORT
307+
ConstIterator& operator-- ();
308+
IMF_EXPORT
309+
ConstIterator operator-- (int);
310+
311+
IMF_EXPORT
312+
const Channel& operator* () const;
313+
314+
IMF_EXPORT
315+
const Channel* operator-> () const;
316+
293317
IMF_EXPORT
294318
const char* name () const;
295319
IMF_EXPORT
@@ -333,6 +357,33 @@ ChannelList::Iterator::operator++ (int)
333357
return tmp;
334358
}
335359

360+
inline ChannelList::Iterator&
361+
ChannelList::Iterator::operator-- ()
362+
{
363+
--_i;
364+
return *this;
365+
}
366+
367+
inline ChannelList::Iterator
368+
ChannelList::Iterator::operator-- (int)
369+
{
370+
Iterator tmp = *this;
371+
--_i;
372+
return tmp;
373+
}
374+
375+
inline Channel&
376+
ChannelList::Iterator::operator* () const
377+
{
378+
return _i->second;
379+
}
380+
381+
inline Channel*
382+
ChannelList::Iterator::operator-> () const
383+
{
384+
return &_i->second;
385+
}
386+
336387
inline const char*
337388
ChannelList::Iterator::name () const
338389
{
@@ -345,6 +396,20 @@ ChannelList::Iterator::channel () const
345396
return _i->second;
346397
}
347398

399+
inline bool
400+
operator== (
401+
ChannelList::Iterator& x, ChannelList::Iterator& y)
402+
{
403+
return x._i == y._i;
404+
}
405+
406+
inline bool
407+
operator!= (
408+
ChannelList::Iterator& x, ChannelList::Iterator& y)
409+
{
410+
return !(x == y);
411+
}
412+
348413
inline ChannelList::ConstIterator::ConstIterator () : _i ()
349414
{
350415
// empty
@@ -379,6 +444,33 @@ ChannelList::ConstIterator::operator++ (int)
379444
return tmp;
380445
}
381446

447+
inline ChannelList::ConstIterator&
448+
ChannelList::ConstIterator::operator-- ()
449+
{
450+
--_i;
451+
return *this;
452+
}
453+
454+
inline ChannelList::ConstIterator
455+
ChannelList::ConstIterator::operator-- (int)
456+
{
457+
ConstIterator tmp = *this;
458+
--_i;
459+
return tmp;
460+
}
461+
462+
inline const Channel&
463+
ChannelList::ConstIterator::operator* () const
464+
{
465+
return _i->second;
466+
}
467+
468+
inline const Channel*
469+
ChannelList::ConstIterator::operator-> () const
470+
{
471+
return &_i->second;
472+
}
473+
382474
inline const char*
383475
ChannelList::ConstIterator::name () const
384476
{

0 commit comments

Comments
 (0)