CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDLParser.h
Go to the documentation of this file.
1 #ifndef DDL_Parser_H
2 #define DDL_Parser_H
3 
4 // ---------------------------------------------------------------------------
5 // Includes
6 // ---------------------------------------------------------------------------
10 
11 // Xerces C++ dependencies
12 #include <xercesc/util/XercesDefs.hpp>
13 #include <xercesc/util/PlatformUtils.hpp>
14 #include <xercesc/sax2/SAX2XMLReader.hpp>
15 #include <xercesc/sax2/XMLReaderFactory.hpp>
16 #include <xercesc/sax/SAXException.hpp>
17 
18 #include <string>
19 #include <vector>
20 #include <map>
21 #include <iosfwd>
22 
24 
26 
64 class DDLParser
65 
66 {
67  public:
68  typedef XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader;
69 
70  typedef std::map< int, std::pair<std::string, std::string> > FileNameHolder;
71 
72  DDLParser ( DDCompactView& cpv );
73 
74  protected:
75  DDLParser( );
76 
77  public:
78  ~DDLParser();
79 
81  int parse( const DDLDocumentProvider& dp );
82 
84 
104  bool parseOneFile(const std::string& filename);
105 
106  // I ASSUME I take ownership of this blob
107  // void parse( std::vector<unsigned char>* ablob, unsigned int bsize ) ;
108  //old way void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
109  void parse( const std::vector<unsigned char>& ablob, unsigned int bsize ) ;
110 
111 /* void parse( std::iostream ) ; */
112 
114  std::vector<std::string> getFileList();
115 
117  void dumpFileList();
118  void dumpFileList(std::ostream& co);
119 
122 
125 
127 
131 
133  size_t isFound(const std::string& filename);
134 
136  bool isParsed(const std::string& filename);
137 
139 
142  void clearFiles () ;
143 
146 
147  protected:
148 
150  void parseFile (const int& numtoproc);
151 
152  private:
153 
156 
159 
161  std::map<int, bool> parsed_;
162 
164  int nFiles_;
165 
168 
171 
174 
178 
179 
180 };
181 
182 #endif
int parse(const DDLDocumentProvider &dp)
Parse all files. Return is meaningless.
Definition: DDLParser.cc:221
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:161
std::string configFileName_
Configuration file name. Only necessary until deprecated methods removed.
Definition: DDLParser.h:167
std::string getNameSpace(const std::string &fname)
Definition: DDLParser.cc:416
XERCES_CPP_NAMESPACE::SAX2XMLReader SAX2XMLReader
Definition: DDLParser.h:68
std::string extractFileName(std::string fullname)
Definition: DDLParser.cc:405
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:175
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:173
std::string getCurrFileName()
Report which file currently being processed (or last processed).
Definition: DDLParser.cc:392
std::string currFileName_
Which file is currently being processed.
Definition: DDLParser.h:170
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:158
type of data representation of DDCompactView
Definition: DDCompactView.h:77
~DDLParser()
Destructor terminates the XMLPlatformUtils (as required by Xerces)
Definition: DDLParser.cc:53
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:70
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:80
DDLSAX2ExpressionHandler is the first pass SAX2 Handler for XML files found in the configuration file...
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:176
bool parseOneFile(const std::string &filename)
Process a single files.
Definition: DDLParser.cc:111
DDLSAX2Handler * errHandler_
Definition: DDLParser.h:177
void clearFiles()
Clear the file list - see Warning!
Definition: DDLParser.cc:398
DDLSAX2FileHandler * getDDLSAX2FileHandler()
To get the parent this class allows access to the handler.
Definition: DDLParser.cc:74
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:64
void parseFile(const int &numtoproc)
Parse File. Just to hold some common looking code.
Definition: DDLParser.cc:360
std::vector< std::string > getFileList()
Return list of files.
Definition: DDLParser.cc:194
auto dp
Definition: deltaR.h:24
SAX2XMLReader * getXMLParser()
Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.
Definition: DDLParser.cc:68
string fname
main script
DDLDocumentProvider provides a set of URLs and filenames.
tuple filename
Definition: lut2db_cfg.py:20
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
void dumpFileList()
Print out the list of files.
Definition: DDLParser.cc:205
DDCompactView & cpv_
reference to storage
Definition: DDLParser.h:155
bool isParsed(const std::string &filename)
Is the file already parsed?
Definition: DDLParser.cc:100
int nFiles_
Number of files + 1.
Definition: DDLParser.h:164