CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 public:
65  typedef XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader;
66 
67  typedef std::map<int, std::pair<std::string, std::string> > FileNameHolder;
68 
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 
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 
134 
137 
140 
142  std::map<int, bool> parsed_;
143 
145  size_t nFiles_;
146 
149 
152 
157 };
158 
159 #endif
int parse(const DDLDocumentProvider &dp)
Parse all files. Return is meaningless.
Definition: DDLParser.cc:123
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:154
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
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
~DDLParser()
Destructor terminates the XMLPlatformUtils (as required by Xerces)
Definition: DDLParser.cc:38
DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file.
std::string const extractFileName(const std::string &fullname)
Definition: DDLParser.cc:213
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:55
DDLSAX2ExpressionHandler is the first pass SAX2 Handler for XML files found in the configuration file...
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:155
bool parseOneFile(const std::string &filename)
Process a single files.
Definition: DDLParser.cc:80
DDLSAX2Handler * errHandler_
Definition: DDLParser.h:156
DDLElementRegistry * elementRegistry_
Definition: DDLParser.h:153
void clearFiles()
Clear the file list - see Warning!
Definition: DDLParser.cc:208
DDLSAX2FileHandler * getDDLSAX2FileHandler()
To get the parent this class allows access to the handler.
Definition: DDLParser.cc:53
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:199
size_t nFiles_
Number of files + 1.
Definition: DDLParser.h:145
SAX2XMLReader * getXMLParser()
Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.
Definition: DDLParser.cc:51
string fname
main script
DDLDocumentProvider provides a set of URLs and filenames.
tuple filename
Definition: lut2db_cfg.py:20
std::string const getNameSpace(const std::string &fname)
Definition: DDLParser.cc:217
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
The main class for processing parsed elements.
std::map< int, std::pair< std::string, std::string > > FileNameHolder
Definition: DDLParser.h:67
DDCompactView & cpv_
reference to storage
Definition: DDLParser.h:136
bool isParsed(const std::string &filename)
Is the file already parsed?
Definition: DDLParser.cc:71