20 #include <xercesc/framework/MemBufInputSource.hpp>
27 using namespace XERCES_CPP_NAMESPACE;
34 XMLPlatformUtils::Initialize();
38 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
39 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
49 DCOUT_V(
'P',
"DDLParser::DDLParser(): new (and only) DDLParser");
59 XMLPlatformUtils::Terminate();
60 DCOUT_V(
'P',
"DDLParser::~DDLParser(): destruct DDLParser");
82 FileNameHolder::const_iterator it =
fileNames_.begin();
84 bool foundFile =
false;
87 if( it->second.first == filename )
119 size_t foundFile =
isFound(filename);
122 pair <std::string, std::string>
pss;
124 pss.second = absoluteFileName;
140 LogDebug (
"DDLParser") <<
"ParseOneFile() Parsing: " <<
fileNames_[fIndex].second << std::endl;
154 DCOUT_V(
'P',
"DDLParser::ParseOneFile(): PASS2: Just before setting Xerces content and error handlers... ");
177 DCOUT(
'P',
" WARNING: DDLParser::ParseOneFile() file " + filename
189 MemBufInputSource mbis( &*ablob.begin(), bsize, dummy );
193 std::vector < std::string >
196 std::vector<std::string> flist;
199 flist.push_back(fit->second.first);
207 edm::LogInfo (
"DDLParser") <<
"File List:" << std::endl;
209 edm::LogInfo (
"DDLParser") << it->second.second << std::endl;
215 co <<
"File List:" << std::endl;
217 co << it->second.second << std::endl;
224 edm::LogInfo (
"DDLParser") <<
"Start Parsing. Validation is set off for the time being." << std::endl;
238 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
239 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
245 size_t fileIndex = 0;
246 std::vector<std::string> fullFileName;
252 if ( ts.size() > 0 ) {
253 if ( ts[ts.size() - 1] ==
'/') {
254 fullFileName.push_back( ts + tf );
256 fullFileName.push_back( ts +
"/" + tf );
259 fullFileName.push_back( tf );
263 for (std::vector<std::string>::const_iterator fnit = fullFileName.begin();
264 fnit != fullFileName.end();
271 pair <std::string, std::string>
pss;
283 DCOUT(
'P',
"DDLParser::parse(): PASS1: Just before setting Xerces content and error handlers... ");
316 DCOUT(
'P',
"DDLParser::parse(): PASS2: Just before setting Xerces content and error handlers... ");
344 pair<std::string, std::string> namePair =
fileNames_[
i];
345 LogDebug (
"DDLParser") <<
"Completed parsing file " << namePair.second << std::endl;
408 size_t bit = fullname.rfind(
'/');
409 if ( bit < fullname.size() - 2 ) {
410 ret=fullname.substr(bit+1);
420 while (j < fname.size() && fname[
j] !=
'.')
422 if (j < fname.size() && fname[
j] ==
'.')
423 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 getCurrFileName()
Report which file currently being processed (or last processed).
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.
void dumpFileList()
Print out the list of files.
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.