test
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 35 of file XMLUtils.h.

Constructor & Destructor Documentation

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

Definition at line 57 of file XMLUtils.cc.

References init().

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

Definition at line 66 of file XMLUtils.cc.

References init().

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

Definition at line 101 of file XMLUtils.cc.

102 {
103 }

Member Function Documentation

void XMLDocument::init ( Handler handler)
private

Definition at line 75 of file XMLUtils.cc.

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

Referenced by XMLDocument().

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

Definition at line 105 of file XMLUtils.cc.

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

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

Member Data Documentation

bool lhef::XMLDocument::done
private

Definition at line 68 of file XMLUtils.h.

Referenced by parse().

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

Definition at line 64 of file XMLUtils.h.

Referenced by init(), and parse().

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

Definition at line 61 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 66 of file XMLUtils.h.

Referenced by init(), and parse().