Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

BasicListParser.h

Go to the documentation of this file.
00001 // 
00002 // Copyright (C) CERN, Geneva 
00003 // 
00004 
00005 #ifndef _BASICLISTPARSER_H_
00006 #define _BASICLISTPARSER_H_
00007 
00008 #include <vector>
00009 #include <string>
00010 
00011 #ifdef AIDA_STD
00012 # undef AIDA_STD
00013 #endif
00014 
00015 #ifdef AIDA_NOT_USE_STD
00016 # define AIDA_STD
00017 #else
00018 # define AIDA_STD std
00019 #endif
00020 
00029 class BasicListParser  {
00030 public:
00032   BasicListParser(): pair_count(0), iter_index(0), parsing_successful(0) {}
00034   virtual ~BasicListParser() { clear(); }
00039   virtual bool parse( AIDA_STD::string a_string ) = 0;
00041   bool isValid() { return parsing_successful; }
00043   virtual void clear() {
00044         pair_names_os.clear();
00045         pair_values_os.clear();
00046         iter_index  = 0;
00047         pair_count = 0;
00048         parsing_successful = 0;
00049   }            
00051   size_t count() { return pair_count; }
00052 
00064 
00065   void startTerm() { iter_index = 0; }          
00067   void forthTerm() {iter_index ++;}
00069   bool hasTerm() {return( iter_index < count() );}
00071   const AIDA_STD::string getName() {return( pair_names_os[ iter_index ] );}
00073   const AIDA_STD::string getValue() {return( pair_values_os[ iter_index ] );}
00074 protected:
00075   typedef AIDA_STD::vector<AIDA_STD::string > StringVector;
00076   StringVector pair_names_os;
00077   StringVector pair_values_os;
00078   size_t pair_count;
00079   size_t iter_index;
00080   bool parsing_successful;
00081 };
00082 
00083 #endif // _BASICLIST_H_
00084 

Generated on Tue May 20 14:50:25 2003 for HepUtilities by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002