CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | 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::auto_ptr< std::istream > &in, Handler &handler)
 
 XMLDocument (std::auto_ptr< StorageWrap > &in, Handler &handler)
 
virtual ~XMLDocument ()
 

Private Member Functions

void init (Handler &handler)
 

Private Attributes

bool done
 
std::auto_ptr
< XERCES_CPP_NAMESPACE_QUALIFIER
SAX2XMLReader > 
parser
 
std::auto_ptr< XercesPlatformplatform
 
std::auto_ptr
< XERCES_CPP_NAMESPACE_QUALIFIER
InputSource > 
source
 
XERCES_CPP_NAMESPACE_QUALIFIER
XMLPScanToken 
token
 

Detailed Description

Definition at line 33 of file XMLUtils.h.

Constructor & Destructor Documentation

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

Definition at line 55 of file XMLUtils.cc.

References init().

55  :
56  platform(new XercesPlatform()),
57  source(new STLInputSource(in)),
58  parser(XMLReaderFactory::createXMLReader()),
59  done(false)
60 {
61  init(handler);
62 }
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:62
XMLInputSourceWrapper< STLInputStream > STLInputSource
Definition: XMLUtils.h:185
void init(Handler &handler)
Definition: XMLUtils.cc:73
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
Definition: XMLUtils.h:61
std::auto_ptr< XercesPlatform > platform
Definition: XMLUtils.h:59
XMLDocument::XMLDocument ( std::auto_ptr< StorageWrap > &  in,
Handler handler 
)

Definition at line 64 of file XMLUtils.cc.

References init().

64  :
65  platform(new XercesPlatform()),
67  parser(XMLReaderFactory::createXMLReader()),
68  done(false)
69 {
70  init(handler);
71 }
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:62
XMLInputSourceWrapper< StorageInputStream > StorageInputSource
Definition: XMLUtils.h:186
void init(Handler &handler)
Definition: XMLUtils.cc:73
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
Definition: XMLUtils.h:61
std::auto_ptr< XercesPlatform > platform
Definition: XMLUtils.h:59
XMLDocument::~XMLDocument ( )
virtual

Definition at line 99 of file XMLUtils.cc.

100 {
101 }

Member Function Documentation

void XMLDocument::init ( Handler handler)
private

Definition at line 73 of file XMLUtils.cc.

References ExpressReco_HICollisions_FallBack::e, edm::hlt::Exception, parser, source, and token.

Referenced by XMLDocument().

74 {
75  try {
76  parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
77  parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
78  parser->setFeature(XMLUni::fgXercesSchema, false);
79  parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
80 
81  parser->setContentHandler(&handler);
82  parser->setLexicalHandler(&handler);
83  parser->setErrorHandler(&handler);
84 
85  if (!parser->parseFirst(*source, token))
86  throw cms::Exception("XMLParseError")
87  << "SAXParser::parseFirst failed" << std::endl;
88  } catch(const XMLException &e) {
89  throw cms::Exception("XMLDocument")
90  << "XMLPlatformUtils::Initialize failed because of "
91  << XMLSimpleStr(e.getMessage()) << std::endl;
92  } catch(const SAXException &e) {
93  throw cms::Exception("XMLDocument")
94  << "XML parser reported: "
95  << XMLSimpleStr(e.getMessage()) << "." << std::endl;
96  }
97 }
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:62
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
Definition: XMLUtils.h:61
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token
Definition: XMLUtils.h:64
bool XMLDocument::parse ( void  )

Definition at line 103 of file XMLUtils.cc.

References done, ExpressReco_HICollisions_FallBack::e, edm::hlt::Exception, parser, and token.

104 {
105  try {
106  if (done || parser->getErrorCount())
107  return false;
108 
109  done = !parser->parseNext(token);
110  } catch(const XMLException &e) {
111  throw cms::Exception("XMLDocument")
112  << "XMLPlatformUtils::Initialize failed because of "
113  << XMLSimpleStr(e.getMessage()) << std::endl;
114  } catch(const SAXException &e) {
115  throw cms::Exception("XMLDocument")
116  << "XML parser reported: "
117  << XMLSimpleStr(e.getMessage()) << "." << std::endl;
118  }
119 
120  return !done;
121 }
std::auto_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
Definition: XMLUtils.h:62
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token
Definition: XMLUtils.h:64

Member Data Documentation

bool lhef::XMLDocument::done
private

Definition at line 66 of file XMLUtils.h.

Referenced by parse().

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

Definition at line 62 of file XMLUtils.h.

Referenced by init(), and parse().

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

Definition at line 59 of file XMLUtils.h.

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

Definition at line 64 of file XMLUtils.h.

Referenced by init(), and parse().