CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
InputSource
source
 
XERCES_CPP_NAMESPACE_QUALIFIER
XMLPScanToken 
token
 

Detailed Description

Definition at line 39 of file XMLUtils.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file XMLUtils.cc.

References init().

50  : platform(new XercesPlatform()),
51  source(new STLInputSource(in)),
52  parser(XMLReaderFactory::createXMLReader()),
53  done(false) {
54  init(handler);
55  }
XMLInputSourceWrapper< STLInputStream > STLInputSource
Definition: XMLUtils.h:189
void init(Handler &handler)
Definition: XMLUtils.cc:65
std::unique_ptr< XercesPlatform > platform
Definition: XMLUtils.h:66
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:69
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
Definition: XMLUtils.h:68
XMLDocument::XMLDocument ( std::unique_ptr< StorageWrap > &  in,
Handler handler 
)

Definition at line 57 of file XMLUtils.cc.

References init().

58  : platform(new XercesPlatform()),
60  parser(XMLReaderFactory::createXMLReader()),
61  done(false) {
62  init(handler);
63  }
XMLInputSourceWrapper< StorageInputStream > StorageInputSource
Definition: XMLUtils.h:190
void init(Handler &handler)
Definition: XMLUtils.cc:65
std::unique_ptr< XercesPlatform > platform
Definition: XMLUtils.h:66
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:69
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
Definition: XMLUtils.h:68
XMLDocument::~XMLDocument ( )
virtual

Definition at line 87 of file XMLUtils.cc.

87 {}

Member Function Documentation

void XMLDocument::init ( Handler handler)
private

Definition at line 65 of file XMLUtils.cc.

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

Referenced by XMLDocument().

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

Definition at line 89 of file XMLUtils.cc.

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

89  {
90  try {
91  if (done || parser->getErrorCount())
92  return false;
93 
94  done = !parser->parseNext(token);
95  } catch (const XMLException &e) {
96  throw cms::Exception("XMLDocument")
97  << "cms::concurrency::xercesInitialize failed because of " << XMLSimpleStr(e.getMessage()) << std::endl;
98  } catch (const SAXException &e) {
99  throw cms::Exception("XMLDocument")
100  << "XML parser reported: " << XMLSimpleStr(e.getMessage()) << "." << std::endl;
101  }
102 
103  return !done;
104  }
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token
Definition: XMLUtils.h:71
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:69
static std::shared_ptr<void> lhef::XMLDocument::platformHandle ( )
inlinestatic

Definition at line 49 of file XMLUtils.h.

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

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

Member Data Documentation

bool lhef::XMLDocument::done
private

Definition at line 73 of file XMLUtils.h.

Referenced by parse().

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

Definition at line 69 of file XMLUtils.h.

Referenced by init(), and parse().

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

Definition at line 66 of file XMLUtils.h.

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

Definition at line 71 of file XMLUtils.h.

Referenced by init(), and parse().