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 
24 
62 class DDLParser
63 {
64  public:
65  typedef XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader;
66 
67  typedef std::map< int, std::pair<std::string, std::string> > FileNameHolder;
68 
69  DDLParser( DDCompactView& cpv );
70 
71  DDLParser() = delete;
72 
73  ~DDLParser();
74 
76  int parse( const DDLDocumentProvider& dp );
77 
79 
99  bool parseOneFile(const std::string& filename);
100 
101  // I ASSUME I take ownership of this blob
102  // void parse( std::vector<unsigned char>* ablob, unsigned int bsize ) ;
103  //old way void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
104  void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
105 
107  SAX2XMLReader* getXMLParser();
108 
110 
114 
116 
119  void clearFiles();
120 
121  private:
123  void parseFile (const int& numtoproc);
124 
126  size_t isFound(const std::string& filename);
127 
129  bool isParsed(const std::string& filename);
130 
131  std::string const extractFileName( const std::string& fullname );
132 
133  std::string const getNameSpace( const std::string& fname );
134 
137 
139  FileNameHolder fileNames_;
140 
142  std::map<int, bool> parsed_;
143 
145  size_t nFiles_;
146 
149 
151  SAX2XMLReader* SAX2Parser_;
152 
156 };
157 
158 #endif
int parse(const DDLDocumentProvider &dp)
Parse all files. Return is meaningless.
Definition: DDLParser.cc:145
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:142
DDLParser()=delete
XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader
Definition: DDLParser.h:65
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:153
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:151
std::string currFileName_
Which file is currently being processed.
Definition: DDLParser.h:148
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:139
type of data representation of DDCompactView
Definition: DDCompactView.h:90
~DDLParser()
Destructor terminates the XMLPlatformUtils (as required by Xerces)
Definition: DDLParser.cc:40
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:67
std::string const extractFileName(const std::string &fullname)
Definition: DDLParser.cc:247
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:66
DDLSAX2ExpressionHandler is the first pass SAX2 Handler for XML files found in the configuration file...
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:154
bool parseOneFile(const std::string &filename)
Process a single files.
Definition: DDLParser.cc:97
DDLSAX2Handler * errHandler_
Definition: DDLParser.h:155
void clearFiles()
Clear the file list - see Warning!
Definition: DDLParser.cc:240
DDLSAX2FileHandler * getDDLSAX2FileHandler()
To get the parent this class allows access to the handler.
Definition: DDLParser.cc:60
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:62
void parseFile(const int &numtoproc)
Parse File. Just to hold some common looking code.
Definition: DDLParser.cc:228
size_t nFiles_
Number of files + 1.
Definition: DDLParser.h:145
auto dp
Definition: deltaR.h:22
SAX2XMLReader * getXMLParser()
Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.
Definition: DDLParser.cc:54
string fname
main script
DDLDocumentProvider provides a set of URLs and filenames.
std::string const getNameSpace(const std::string &fname)
Definition: DDLParser.cc:253
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
DDCompactView & cpv_
reference to storage
Definition: DDLParser.h:136
bool isParsed(const std::string &filename)
Is the file already parsed?
Definition: DDLParser.cc:86