classadItor.h

00001 /***************************************************************
00002  *
00003  * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
00004  * University of Wisconsin-Madison, WI.
00005  * 
00006  * Licensed under the Apache License, Version 2.0 (the "License"); you
00007  * may not use this file except in compliance with the License.  You may
00008  * obtain a copy of the License at
00009  * 
00010  *    http://www.apache.org/licenses/LICENSE-2.0
00011  * 
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  *
00018  ***************************************************************/
00019 
00020 
00021 #ifndef __CLASSAD_CLASSAD_ITOR_H__
00022 #define __CLASSAD_CLASSAD_ITOR_H__
00023 
00024 BEGIN_NAMESPACE( classad )
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 class ClassAdIterator
00034 {
00035     public:
00037         ClassAdIterator() { ad = NULL; }
00038 
00043         ClassAdIterator(const ClassAd &ca) { ad=&ca; ToFirst( ); }
00044 
00046         ~ClassAdIterator(){ }
00047 
00056         inline void Initialize(const ClassAd &ca){ ad=&ca; ToFirst( ); }
00057 
00059         inline void ToFirst () { if(ad) itr = ad->attrList.begin( ); }
00060 
00062         inline void ToAfterLast ()  { if(ad) itr = ad->attrList.end( ); }
00063 
00070         bool NextAttribute( std::string& attr, const ExprTree*& expr );
00071 
00077         bool CurrentAttribute( std::string& attr, const ExprTree*& expr ) const;
00078 
00082         inline bool IsAtFirst() const {
00083             return(ad?(itr==ad->attrList.begin()):false);
00084         }
00085 
00089         inline bool IsAfterLast() const {
00090             return(ad?(itr==ad->attrList.end()):false); 
00091         }
00092 
00093     private:
00094         AttrList::const_iterator    itr;
00095         const ClassAd               *ad;
00096 };
00097 
00098 END_NAMESPACE // classad
00099 
00100 #endif//__CLASSAD_CLASSAD_ITOR_H__
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends