Main Page | Class Hierarchy | Class List | File List | Class Members

classadItor.h

00001 /*********************************************************************
00002  *
00003  * Condor ClassAd library
00004  * Copyright (C) 1990-2003, Condor Team, Computer Sciences Department,
00005  * University of Wisconsin-Madison, WI and Rajesh Raman.
00006  *
00007  * This source code is covered by the Condor Public License, which can
00008  * be found in the accompanying LICENSE file, or online at
00009  * www.condorproject.org.
00010  *
00011  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00012  * AND THE UNIVERSITY OF WISCONSIN-MADISON "AS IS" AND ANY EXPRESS OR
00013  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00014  * WARRANTIES OF MERCHANTABILITY, OF SATISFACTORY QUALITY, AND FITNESS
00015  * FOR A PARTICULAR PURPOSE OR USE ARE DISCLAIMED. THE COPYRIGHT
00016  * HOLDERS AND CONTRIBUTORS AND THE UNIVERSITY OF WISCONSIN-MADISON
00017  * MAKE NO MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS,
00018  * ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY
00019  * PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY
00020  * RIGHT.
00021  *
00022  *********************************************************************/
00023 
00024 #ifndef __CLASSAD_ITOR_H__
00025 #define __CLASSAD_ITOR_H__
00026 
00027 BEGIN_NAMESPACE( classad )
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 class ClassAdIterator
00037 {
00038     public:
00040         ClassAdIterator() { ad = NULL; }
00041 
00046         ClassAdIterator(const ClassAd &ca) { ad=&ca; ToFirst( ); }
00047 
00049         ~ClassAdIterator(){ }
00050 
00059         inline void Initialize(const ClassAd &ca){ ad=&ca; ToFirst( ); }
00060 
00062         inline void ToFirst () { if(ad) itr = ad->attrList.begin( ); }
00063 
00065         inline void ToAfterLast ()  { if(ad) itr = ad->attrList.end( ); }
00066 
00073         bool NextAttribute( std::string& attr, const ExprTree*& expr );
00074 
00080         bool CurrentAttribute( std::string& attr, const ExprTree*& expr ) const;
00081 
00085         inline bool IsAtFirst() const {
00086                         return(ad?(itr==ad->attrList.begin()):false);
00087                 }
00088 
00092         inline bool IsAfterLast() const {
00093                         return(ad?(itr==ad->attrList.end()):false); 
00094                 }
00095 
00096     private:
00097                 AttrList::const_iterator        itr;
00098         const ClassAd                           *ad;
00099 };
00100 
00101 END_NAMESPACE // classad
00102 
00103 #endif//CLASSAD_ITOR