CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
lhef::XMLDocument Class Reference

#include <XMLUtils.h>

Classes

class  Handler
 
class  XercesPlatform
 

Public Member Functions

bool parse ()
 
 XMLDocument (std::unique_ptr< std::istream > &in, Handler &handler)
 
 XMLDocument (std::unique_ptr< StorageWrap > &in, Handler &handler)
 
virtual ~XMLDocument ()
 

Static Public Member Functions

static std::shared_ptr< void > platformHandle ()
 

Private Member Functions

void init (Handler &handler)
 

Private Attributes

bool done
 
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
 
std::unique_ptr< XercesPlatformplatform
 
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSourcesource
 
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token
 

Detailed Description

Definition at line 35 of file XMLUtils.h.

Constructor & Destructor Documentation

◆ XMLDocument() [1/2]

XMLDocument::XMLDocument ( std::unique_ptr< std::istream > &  in,
Handler handler 
)

Definition at line 48 of file XMLUtils.cc.

49  : platform(new XercesPlatform()),
50  source(new STLInputSource(in)),
51  parser(XMLReaderFactory::createXMLReader()),
52  done(false) {
53  init(handler);
54  }

References init().

◆ XMLDocument() [2/2]

XMLDocument::XMLDocument ( std::unique_ptr< StorageWrap > &  in,
Handler handler 
)

Definition at line 56 of file XMLUtils.cc.

57  : platform(new XercesPlatform()),
59  parser(XMLReaderFactory::createXMLReader()),
60  done(false) {
61  init(handler);
62  }

References init().

◆ ~XMLDocument()

XMLDocument::~XMLDocument ( )
virtual

Definition at line 86 of file XMLUtils.cc.

86 {}

Member Function Documentation

◆ init()

void XMLDocument::init ( Handler handler)
private

Definition at line 64 of file XMLUtils.cc.

64  {
65  try {
66  parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
67  parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
68  parser->setFeature(XMLUni::fgXercesSchema, false);
69  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
70 
71  parser->setContentHandler(&handler);
72  parser->setLexicalHandler(&handler);
73  parser->setErrorHandler(&handler);
74 
75  if (!parser->parseFirst(*source, token))
76  throw cms::Exception("XMLParseError") << "SAXParser::parseFirst failed" << std::endl;
77  } catch (const XMLException &e) {
78  throw cms::Exception("XMLDocument")
79  << "cms::concurrency::xercesInitialize failed because of " << XMLSimpleStr(e.getMessage()) << std::endl;
80  } catch (const SAXException &e) {
81  throw cms::Exception("XMLDocument")
82  << "XML parser reported: " << XMLSimpleStr(e.getMessage()) << "." << std::endl;
83  }
84  }

References MillePedeFileConverter_cfg::e, Exception, parser, source, and token.

Referenced by XMLDocument().

◆ parse()

bool XMLDocument::parse ( void  )

Definition at line 88 of file XMLUtils.cc.

88  {
89  try {
90  if (done || parser->getErrorCount())
91  return false;
92 
93  done = !parser->parseNext(token);
94  } catch (const XMLException &e) {
95  throw cms::Exception("XMLDocument")
96  << "cms::concurrency::xercesInitialize failed because of " << XMLSimpleStr(e.getMessage()) << std::endl;
97  } catch (const SAXException &e) {
98  throw cms::Exception("XMLDocument")
99  << "XML parser reported: " << XMLSimpleStr(e.getMessage()) << "." << std::endl;
100  }
101 
102  return !done;
103  }

References done, MillePedeFileConverter_cfg::e, Exception, parser, and token.

◆ platformHandle()

static std::shared_ptr<void> lhef::XMLDocument::platformHandle ( )
inlinestatic

Definition at line 45 of file XMLUtils.h.

45 { return std::make_shared<XercesPlatform>(); }

Referenced by lhef::LHEReader::next().

Member Data Documentation

◆ done

bool lhef::XMLDocument::done
private

Definition at line 70 of file XMLUtils.h.

Referenced by parse().

◆ parser

std::unique_ptr<XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader> lhef::XMLDocument::parser
private

Definition at line 66 of file XMLUtils.h.

Referenced by das.DASOptionParser::get_opt(), init(), and parse().

◆ platform

std::unique_ptr<XercesPlatform> lhef::XMLDocument::platform
private

Definition at line 63 of file XMLUtils.h.

◆ source

std::unique_ptr<XERCES_CPP_NAMESPACE_QUALIFIER InputSource> lhef::XMLDocument::source
private

◆ token

XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken lhef::XMLDocument::token
private

Definition at line 68 of file XMLUtils.h.

Referenced by init(), and parse().

lhef::XMLDocument::platform
std::unique_ptr< XercesPlatform > platform
Definition: XMLUtils.h:63
lhef::XMLDocument::init
void init(Handler &handler)
Definition: XMLUtils.cc:64
lhef::XMLDocument::done
bool done
Definition: XMLUtils.h:70
lhef::StorageInputSource
XMLInputSourceWrapper< StorageInputStream > StorageInputSource
Definition: XMLUtils.h:187
lhef::STLInputSource
XMLInputSourceWrapper< STLInputStream > STLInputSource
Definition: XMLUtils.h:186
lhef::XMLDocument::token
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token
Definition: XMLUtils.h:68
recoMuon::in
Definition: RecoMuonEnumerators.h:6
Exception
Definition: hltDiff.cc:246
lhef::XMLDocument::source
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
Definition: XMLUtils.h:65
cms::Exception
Definition: Exception.h:70
lhef::XMLDocument::parser
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:66
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37