CMS 3D CMS Logo

DDLParser.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_PARSER_DDL_PARSER_H
2 #define DETECTOR_DESCRIPTION_PARSER_DDL_PARSER_H
3 
8 #include <xercesc/sax/SAXException.hpp>
9 #include <xercesc/sax2/SAX2XMLReader.hpp>
10 #include <xercesc/sax2/XMLReaderFactory.hpp>
11 #include <xercesc/util/XercesDefs.hpp>
12 #include <xercesc/util/XercesVersion.hpp>
13 #include <iosfwd>
14 #include <map>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 #include <cstddef>
19 
20 class DDCompactView;
22 class DDLElementRegistry;
23 
25 
63 class DDLParser
64 {
65  public:
66  typedef XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader;
67 
68  typedef std::map< int, std::pair<std::string, std::string> > FileNameHolder;
69 
70  DDLParser( DDCompactView& cpv );
71 
72  DDLParser() = delete;
73 
74  ~DDLParser();
75 
77  int parse( const DDLDocumentProvider& dp );
78 
80 
100  bool parseOneFile(const std::string& filename);
101 
102  // I ASSUME I take ownership of this blob
103  // void parse( std::vector<unsigned char>* ablob, unsigned int bsize ) ;
104  //old way void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
105  void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
106 
108  SAX2XMLReader* getXMLParser();
109 
111 
115 
117 
120  void clearFiles();
121 
122  private:
124  void parseFile (const int& numtoproc);
125 
127  size_t isFound(const std::string& filename);
128 
130  bool isParsed(const std::string& filename);
131 
132  std::string const extractFileName( const std::string& fullname );
133 
134  std::string const getNameSpace( const std::string& fname );
135 
138 
140  FileNameHolder fileNames_;
141 
143  std::map<int, bool> parsed_;
144 
146  size_t nFiles_;
147 
150 
152  SAX2XMLReader* SAX2Parser_;
153 
158 };
159 
160 #endif
int parse(const DDLDocumentProvider &dp)
Parse all files. Return is meaningless.
Definition: DDLParser.cc:149
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:143
DDLParser()=delete
XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader
Definition: DDLParser.h:66
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:155
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:152
std::string currFileName_
Which file is currently being processed.
Definition: DDLParser.h:149
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:140
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
~DDLParser()
Destructor terminates the XMLPlatformUtils (as required by Xerces)
Definition: DDLParser.cc:41
DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file.
std::map< int, std::pair< std::string, std::string > > FileNameHolder
Definition: DDLParser.h:68
std::string const extractFileName(const std::string &fullname)
Definition: DDLParser.cc:252
size_t isFound(const std::string &filename)
Is the file already known by the DDLParser? Returns 0 if not found, and index if found.
Definition: DDLParser.cc:68
DDLSAX2ExpressionHandler is the first pass SAX2 Handler for XML files found in the configuration file...
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:156
bool parseOneFile(const std::string &filename)
Process a single files.
Definition: DDLParser.cc:99
DDLSAX2Handler * errHandler_
Definition: DDLParser.h:157
DDLElementRegistry * elementRegistry_
Definition: DDLParser.h:154
void clearFiles()
Clear the file list - see Warning!
Definition: DDLParser.cc:245
DDLSAX2FileHandler * getDDLSAX2FileHandler()
To get the parent this class allows access to the handler.
Definition: DDLParser.cc:62
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
void parseFile(const int &numtoproc)
Parse File. Just to hold some common looking code.
Definition: DDLParser.cc:233
size_t nFiles_
Number of files + 1.
Definition: DDLParser.h:146
SAX2XMLReader * getXMLParser()
Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.
Definition: DDLParser.cc:56
string fname
main script
DDLDocumentProvider provides a set of URLs and filenames.
std::string const getNameSpace(const std::string &fname)
Definition: DDLParser.cc:258
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
The main class for processing parsed elements.
DDCompactView & cpv_
reference to storage
Definition: DDLParser.h:137
bool isParsed(const std::string &filename)
Is the file already parsed?
Definition: DDLParser.cc:88