22 #include <xercesc/framework/MemBufInputSource.hpp>
29 using namespace XERCES_CPP_NAMESPACE;
36 XMLPlatformUtils::Initialize();
40 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
41 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
51 DCOUT_V(
'P',
"DDLParser::DDLParser(): new (and only) DDLParser");
61 XMLPlatformUtils::Terminate();
62 DCOUT_V(
'P',
"DDLParser::~DDLParser(): destruct DDLParser");
84 FileNameHolder::const_iterator it =
fileNames_.begin();
86 bool foundFile =
false;
89 if( it->second.first == filename )
120 std::string absoluteFileName = fp.
fullPath();
121 size_t foundFile =
isFound(filename);
124 int fIndex = foundFile;
125 pair <std::string, std::string>
pss;
127 pss.second = absoluteFileName;
143 LogDebug (
"DDLParser") <<
"ParseOneFile() Parsing: " <<
fileNames_[fIndex].second << std::endl;
157 DCOUT_V(
'P',
"DDLParser::ParseOneFile(): PASS2: Just before setting Xerces content and error handlers... ");
180 DCOUT(
'P',
" WARNING: DDLParser::ParseOneFile() file " + filename
192 MemBufInputSource mbis( &*ablob.begin(), bsize, dummy );
196 std::vector < std::string >
199 std::vector<std::string> flist;
202 flist.push_back(fit->second.first);
210 edm::LogInfo (
"DDLParser") <<
"File List:" << std::endl;
212 edm::LogInfo (
"DDLParser") << it->second.second << std::endl;
218 co <<
"File List:" << std::endl;
220 co << it->second.second << std::endl;
227 edm::LogInfo (
"DDLParser") <<
"Start Parsing. Validation is set off for the time being." << std::endl;
241 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
242 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
248 size_t fileIndex = 0;
249 std::vector<std::string> fullFileName;
255 if ( ts.size() > 0 ) {
256 if ( ts[ts.size() - 1] ==
'/') {
257 fullFileName.push_back( ts + tf );
259 fullFileName.push_back( ts +
"/" + tf );
262 fullFileName.push_back( tf );
266 for (std::vector<std::string>::const_iterator fnit = fullFileName.begin();
267 fnit != fullFileName.end();
274 pair <std::string, std::string>
pss;
286 DCOUT(
'P',
"DDLParser::parse(): PASS1: Just before setting Xerces content and error handlers... ");
319 DCOUT(
'P',
"DDLParser::parse(): PASS2: Just before setting Xerces content and error handlers... ");
347 pair<std::string, std::string> namePair =
fileNames_[
i];
348 LogDebug (
"DDLParser") <<
"Completed parsing file " << namePair.second << std::endl;
410 std::string
ret =
"";
411 size_t bit = fullname.rfind(
'/');
412 if ( bit < fullname.size() - 2 ) {
413 ret=fullname.substr(bit+1);
423 while (j < fname.size() && fname[
j] !=
'.')
425 if (j < fname.size() && fname[
j] ==
'.')
426 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.