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 )
118 std::string absoluteFileName = fp.
fullPath();
119 size_t foundFile =
isFound(filename);
122 int fIndex = foundFile;
123 pair <std::string, std::string>
pss;
125 pss.second = absoluteFileName;
141 LogDebug (
"DDLParser") <<
"ParseOneFile() Parsing: " <<
fileNames_[fIndex].second << std::endl;
155 DCOUT_V(
'P',
"DDLParser::ParseOneFile(): PASS2: Just before setting Xerces content and error handlers... ");
178 DCOUT(
'P',
" WARNING: DDLParser::ParseOneFile() file " + filename
190 MemBufInputSource mbis( &*ablob.begin(), bsize, dummy );
194 std::vector < std::string >
197 std::vector<std::string> flist;
200 flist.push_back(fit->second.first);
208 edm::LogInfo (
"DDLParser") <<
"File List:" << std::endl;
210 edm::LogInfo (
"DDLParser") << it->second.second << std::endl;
216 co <<
"File List:" << std::endl;
218 co << it->second.second << std::endl;
225 edm::LogInfo (
"DDLParser") <<
"Start Parsing. Validation is set off for the time being." << std::endl;
239 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation,
false);
240 SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
246 size_t fileIndex = 0;
247 std::vector<std::string> fullFileName;
253 if ( ts.size() > 0 ) {
254 if ( ts[ts.size() - 1] ==
'/') {
255 fullFileName.push_back( ts + tf );
257 fullFileName.push_back( ts +
"/" + tf );
260 fullFileName.push_back( tf );
264 for (std::vector<std::string>::const_iterator fnit = fullFileName.begin();
265 fnit != fullFileName.end();
272 pair <std::string, std::string>
pss;
284 DCOUT(
'P',
"DDLParser::parse(): PASS1: Just before setting Xerces content and error handlers... ");
317 DCOUT(
'P',
"DDLParser::parse(): PASS2: Just before setting Xerces content and error handlers... ");
345 pair<std::string, std::string> namePair =
fileNames_[
i];
346 LogDebug (
"DDLParser") <<
"Completed parsing file " << namePair.second << std::endl;
408 std::string
ret =
"";
409 size_t bit = fullname.rfind(
'/');
410 if ( bit < fullname.size() - 2 ) {
411 ret=fullname.substr(bit+1);
421 while (j < fname.size() && fname[
j] !=
'.')
423 if (j < fname.size() && fname[
j] ==
'.')
424 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.