19 #include <xercesc/framework/MemBufInputSource.hpp>
27 using namespace XERCES_CPP_NAMESPACE;
37 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
38 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
48 DCOUT_V(
'P',
"DDLParser::DDLParser(): new (and only) DDLParser");
59 DCOUT_V(
'P',
"DDLParser::~DDLParser(): destruct DDLParser");
81 FileNameHolder::const_iterator it =
fileNames_.begin();
83 bool foundFile =
false;
86 if( it->second.first == filename )
118 size_t foundFile =
isFound(filename);
121 pair <std::string, std::string>
pss;
123 pss.second = absoluteFileName;
139 LogDebug (
"DDLParser") <<
"ParseOneFile() Parsing: " <<
fileNames_[fIndex].second << std::endl;
153 DCOUT_V(
'P',
"DDLParser::ParseOneFile(): PASS2: Just before setting Xerces content and error handlers... ");
176 DCOUT(
'P',
" WARNING: DDLParser::ParseOneFile() file " + filename
188 MemBufInputSource mbis( &*ablob.begin(), bsize, dummy );
192 std::vector < std::string >
195 std::vector<std::string> flist;
198 flist.push_back(fit->second.first);
207 edm::LogInfo (
"DDLParser") <<
"Start Parsing. Validation is set off for the time being." << std::endl;
221 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
222 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
228 size_t fileIndex = 0;
229 std::vector<std::string> fullFileName;
235 if ( ts.size() > 0 ) {
236 if ( ts[ts.size() - 1] ==
'/') {
237 fullFileName.push_back( ts + tf );
239 fullFileName.push_back( ts +
"/" + tf );
242 fullFileName.push_back( tf );
246 for (std::vector<std::string>::const_iterator fnit = fullFileName.begin();
247 fnit != fullFileName.end();
254 pair <std::string, std::string>
pss;
266 DCOUT(
'P',
"DDLParser::parse(): PASS1: Just before setting Xerces content and error handlers... ");
298 DCOUT(
'P',
"DDLParser::parse(): PASS2: Just before setting Xerces content and error handlers... ");
326 pair<std::string, std::string> namePair =
fileNames_[
i];
327 LogDebug (
"DDLParser") <<
"Completed parsing file " << namePair.second << std::endl;
383 size_t bit = fullname.rfind(
'/');
384 if ( bit < fullname.size() - 2 ) {
385 ret=fullname.substr(bit+1);
395 while (j < fname.size() && fname[
j] !=
'.')
397 if (j < fname.size() && fname[
j] ==
'.')
398 ret = fname.substr(0, j);
int parse(const DDLDocumentProvider &dp)
Parse all files. Return is meaningless.
std::map< int, bool > parsed_
Parse status of a given file.
std::pair< ALIstring, ALIstring > pss
std::string getNameSpace(const std::string &fname)
std::string extractFileName(std::string fullname)
DDLSAX2FileHandler * fileHandler_
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
std::string currFileName_
Which file is currently being processed.
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
type of data representation of DDCompactView
~DDLParser()
Destructor terminates the XMLPlatformUtils (as required by Xerces)
DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file.
virtual const std::vector< std::string > & getFileList(void) const =0
Return a list of files as a vector of strings.
U second(std::pair< T, U > const &p)
void dumpElementTypeCounter()
This dumps some statistics on elements encountered in the file.
size_t isFound(const std::string &filename)
Is the file already known by the DDLParser? Returns 0 if not found, and index if found.
DDLSAX2ExpressionHandler is the first pass SAX2 Handler for XML files found in the configuration file...
DDLSAX2ExpressionHandler * expHandler_
bool parseOneFile(const std::string &filename)
Process a single files.
DDLSAX2Handler * errHandler_
void clearFiles()
Clear the file list - see Warning!
DDLSAX2FileHandler * getDDLSAX2FileHandler()
To get the parent this class allows access to the handler.
virtual const std::vector< std::string > & getURLList(void) const =0
Return a list of urls as a vector of strings.
void parseFile(const int &numtoproc)
Parse File. Just to hold some common looking code.
#define DCOUT_V(M_v_Y, M_v_S)
std::vector< std::string > getFileList()
Return list of files.
SAX2XMLReader * getXMLParser()
Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.
virtual void setNameSpace(const std::string &nms)
DDLDocumentProvider provides a set of URLs and filenames.
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
std::string fullPath() const
#define DCOUT(M_v_Y, M_v_S)
tuple size
Write out results.
bool isParsed(const std::string &filename)
Is the file already parsed?
int nFiles_
Number of files + 1.