Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

VMapIterator.h

00001 /*****************************************************************************
00002  * Author:   Valient Gough <vgough@pobox.com>
00003  *
00004  *****************************************************************************
00005  * Copyright (c) 2001, Valient Gough
00006  *
00007  * This library is free software; you can distribute it and/or modify it under
00008  * the terms of the GNU Lesser General Public License (LGPL), as published by
00009  * the Free Software Foundation; either version 2.1 of the License, or (at your
00010  * option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
00015  * details.
00016  *
00017  */
00018 
00019 #ifndef _VMapIterator_incl_
00020 #define _VMapIterator_incl_
00021 
00022 #include <iterator>
00023 #include <utility>
00024 #include <string>
00025 
00026 #include <rel/SmartPtr.h>
00027 
00028 namespace rel
00029 {
00030 
00031     class VMap;
00032 
00033     /*
00034         Iterator over VMap entries.  This should not be created directly - it is
00035         returned from VMap::begin() and VMap::end() methods.
00036      */
00037     class VMapIterator : public std::iterator<std::forward_iterator_tag, 
00038                                     std::pair<std::string,OpaqueValue> >
00039     {
00040     public:
00041         VMapIterator(VMap *map, const OpaqueValue &privateData);
00042         VMapIterator(const VMapIterator &src);
00043         ~VMapIterator();
00044 
00045         VMapIterator &operator = (const VMapIterator &src);
00046 
00047         // compare two iterators - returns true if they point to the same VMap,
00048         // and same part of the map.
00049         bool operator == (const VMapIterator &rhs) const;
00050         bool operator != (const VMapIterator &rhs) const;
00051 
00053         const std::pair<std::string,OpaqueValue> &operator*() const;
00054         const std::pair<std::string,OpaqueValue> *operator->() const;
00056         VMapIterator &operator++();
00060         VMapIterator operator++(int);
00061 
00062     private:
00063         VMap *fMap;
00064         bool fCached;  // if response has already been retrieved (and now cached)
00065         std::pair<std::string,OpaqueValue> fCachedValue;
00066         OpaqueValue fPrivateData;
00067     };
00068 
00069 
00070     inline bool VMapIterator::operator != (const VMapIterator &rhs) const
00071     { return !operator==(rhs); }
00072 
00073 
00074 } // namespace rel
00075 
00076 
00077 #endif
00078 

Generated at Sat Sep 22 02:20:00 2001 for librel by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001