CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

lhef::XMLDocument Class Reference

#include <XMLUtils.h>

List of all members.

Classes

class  Handler
class  XercesPlatform

Public Member Functions

bool parse ()
 XMLDocument (std::auto_ptr< StorageWrap > &in, Handler &handler)
 XMLDocument (std::auto_ptr< std::istream > &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().

                                                                      :
        platform(new XercesPlatform()),
        source(new STLInputSource(in)),
        parser(XMLReaderFactory::createXMLReader()),
        done(false)
{
        init(handler);
}
XMLDocument::XMLDocument ( std::auto_ptr< StorageWrap > &  in,
Handler handler 
)

Definition at line 64 of file XMLUtils.cc.

References init().

                                                                       :
        platform(new XercesPlatform()),
        source(new StorageInputSource(in)),
        parser(XMLReaderFactory::createXMLReader()),
        done(false)
{
        init(handler);
}
XMLDocument::~XMLDocument ( ) [virtual]

Definition at line 99 of file XMLUtils.cc.

{
}

Member Function Documentation

void XMLDocument::init ( Handler handler) [private]

Definition at line 73 of file XMLUtils.cc.

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

Referenced by XMLDocument().

{
        try {
                parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
                parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
                parser->setFeature(XMLUni::fgXercesSchema, false);
                parser->setFeature(XMLUni::fgXercesSchemaFullChecking, false);

                parser->setContentHandler(&handler);
                parser->setLexicalHandler(&handler);
                parser->setErrorHandler(&handler);

                if (!parser->parseFirst(*source, token))
                        throw cms::Exception("XMLParseError")
                                << "SAXParser::parseFirst failed" << std::endl;
        } catch(const XMLException &e) {
                throw cms::Exception("XMLDocument")
                        << "XMLPlatformUtils::Initialize failed because of "
                        << XMLSimpleStr(e.getMessage()) << std::endl;
        } catch(const SAXException &e) {
                throw cms::Exception("XMLDocument")
                        << "XML parser reported: "
                        << XMLSimpleStr(e.getMessage()) << "." << std::endl;  
        }
}
bool XMLDocument::parse ( void  )

Definition at line 103 of file XMLUtils.cc.

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

{
        try {
                if (done || parser->getErrorCount())
                        return false;

                done = !parser->parseNext(token);
        } catch(const XMLException &e) {
                throw cms::Exception("XMLDocument")
                        << "XMLPlatformUtils::Initialize failed because of "
                        << XMLSimpleStr(e.getMessage()) << std::endl;
        } catch(const SAXException &e) {
                throw cms::Exception("XMLDocument")
                        << "XML parser reported: "
                        << XMLSimpleStr(e.getMessage()) << "." << std::endl;  
        }

        return !done;
}

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]

Definition at line 61 of file XMLUtils.h.

Referenced by init().

XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken lhef::XMLDocument::token [private]

Definition at line 64 of file XMLUtils.h.

Referenced by init(), and parse().