CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DetectorDescription/Parser/interface/DDLParser.h

Go to the documentation of this file.
00001 #ifndef DDL_Parser_H
00002 #define DDL_Parser_H
00003 
00004 // ---------------------------------------------------------------------------
00005 //  Includes
00006 // ---------------------------------------------------------------------------
00007 #include "DetectorDescription/Parser/interface/DDLSAX2Handler.h"
00008 #include "DetectorDescription/Parser/interface/DDLSAX2FileHandler.h"
00009 #include "DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler.h"
00010 
00011 // Xerces C++ dependencies
00012 #include <xercesc/util/XercesDefs.hpp>
00013 #include <xercesc/util/PlatformUtils.hpp>
00014 #include <xercesc/sax2/SAX2XMLReader.hpp>
00015 #include <xercesc/sax2/XMLReaderFactory.hpp>
00016 #include <xercesc/sax/SAXException.hpp>
00017 
00018 #include <string>
00019 #include <vector>
00020 #include <map>
00021 #include <iosfwd>
00022 
00023 class DDLDocumentProvider;
00024 
00026 
00064 class DDLParser 
00065 
00066 {
00067  public:
00068   typedef XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader;
00069 
00070   typedef std::map< int, std::pair<std::string, std::string> > FileNameHolder;
00071   
00072   DDLParser ( DDCompactView& cpv );
00073 
00074  protected:
00075   DDLParser( );
00076   
00077  public:
00078   ~DDLParser();
00079 
00081   int parse( const DDLDocumentProvider& dp );
00082 
00084 
00104   bool parseOneFile(const std::string& filename);
00105 
00106   // I ASSUME I take ownership of this blob
00107   //  void parse( std::vector<unsigned char>* ablob, unsigned int bsize ) ;
00108   //old way  void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
00109   void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
00110 
00111 /*   void parse( std::iostream ) ; */
00112 
00114   std::vector<std::string> getFileList();
00115 
00117   void dumpFileList();
00118   void dumpFileList(std::ostream& co);
00119 
00121   std::string getCurrFileName();
00122 
00124   SAX2XMLReader* getXMLParser();
00125 
00127 
00130   DDLSAX2FileHandler* getDDLSAX2FileHandler();
00131   
00133   size_t isFound(const std::string& filename);
00134   
00136   bool isParsed(const std::string& filename);
00137 
00139 
00142   void clearFiles () ;
00143 
00144   std::string extractFileName(std::string fullname);
00145   std::string getNameSpace(const std::string& fname);
00146 
00147  protected:
00148   
00150   void parseFile (const int& numtoproc);
00151 
00152  private:
00153 
00155   DDCompactView& cpv_;
00156 
00158   FileNameHolder fileNames_;
00159 
00161   std::map<int, bool> parsed_;
00162 
00164   int nFiles_;
00165 
00167   std::string configFileName_;
00168 
00170   std::string currFileName_;
00171 
00173   SAX2XMLReader* SAX2Parser_;
00174   
00175   DDLSAX2FileHandler* fileHandler_;
00176   DDLSAX2ExpressionHandler* expHandler_;
00177   DDLSAX2Handler* errHandler_;
00178   
00179   
00180 };
00181 
00182 #endif