8 #include <xercesc/util/XMLString.hpp>
9 #include <xercesc/util/XMLUni.hpp>
10 #include <xercesc/sax2/SAX2XMLReader.hpp>
11 #include <xercesc/sax2/XMLReaderFactory.hpp>
35 }
catch (
const XMLException &
e) {
36 throw cms::Exception(
"XMLDocument") <<
"cms::concurrency::xercesInitialize failed "
51 parser(XMLReaderFactory::createXMLReader()),
59 parser(XMLReaderFactory::createXMLReader()),
66 parser->setFeature(XMLUni::fgSAX2CoreValidation,
false);
67 parser->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
68 parser->setFeature(XMLUni::fgXercesSchema,
false);
69 parser->setFeature(XMLUni::fgXercesSchemaFullChecking,
false);
71 parser->setContentHandler(&handler);
72 parser->setLexicalHandler(&handler);
73 parser->setErrorHandler(&handler);
76 throw cms::Exception(
"XMLParseError") <<
"SAXParser::parseFirst failed" << std::endl;
77 }
catch (
const XMLException &
e) {
79 <<
"cms::concurrency::xercesInitialize failed because of " <<
XMLSimpleStr(
e.getMessage()) << std::endl;
80 }
catch (
const SAXException &
e) {
82 <<
"XML parser reported: " <<
XMLSimpleStr(
e.getMessage()) <<
"." << std::endl;
94 }
catch (
const XMLException &
e) {
96 <<
"cms::concurrency::xercesInitialize failed because of " <<
XMLSimpleStr(
e.getMessage()) << std::endl;
97 }
catch (
const SAXException &
e) {
99 <<
"XML parser reported: " <<
XMLSimpleStr(
e.getMessage()) <<
"." << std::endl;
112 char *rawBuf = reinterpret_cast<char *>(
buf);
113 unsigned int bytes =
size *
sizeof(XMLByte);
114 unsigned int read = 0;
116 while (
read < bytes) {
123 unsigned int len =
buffer.length();
124 unsigned int rem = bytes -
read;
126 std::memcpy(rawBuf +
read,
buffer.c_str(), rem);
132 std::memcpy(rawBuf +
read,
buffer.c_str(), len);
137 read /=
sizeof(XMLByte);
145 throw cms::Exception(
"FileStreamError") <<
"I/O stream bad in STLInputStream::STLInputStream()" << std::endl;
151 char *rawBuf = reinterpret_cast<char *>(
buf);
152 unsigned int bytes =
size *
sizeof(XMLByte);
153 in.read(rawBuf, bytes);
157 throw cms::Exception(
"FileStreamError") <<
"I/O stream bad in STLInputStream::readBytes()" << std::endl;
161 for (
unsigned int i = 1;
i <=
rest;
i++)
169 :
in(
in), lstr(LZMA_STREAM_INIT), compression_(
false), lasttotal_(0) {
178 lstr = LZMA_STREAM_INIT;
182 #if LZMA_VERSION <= UINT32_C(49990030)
185 int ret = lzma_auto_decoder(&
lstr, -1, 0);
188 if (
ret != LZMA_OK) {
190 throw cms::Exception(
"IO") <<
"Error while reading compressed LHE file";
199 assert(
sizeof(XMLByte) ==
sizeof(
unsigned char));
206 ex <<
"Error while reading buffered LHE file";
215 unsigned int dataRead;
223 lstr.avail_in = dataRead;
226 int ret = lzma_code(&
lstr, LZMA_RUN);
227 if (
ret != LZMA_OK &&
ret != LZMA_STREAM_END) {
229 throw cms::Exception(
"IO") <<
"Error while reading compressed LHE file (error code " <<
ret <<
")";
231 dataRead -=
lstr.avail_in;