8 #include <xercesc/util/XMLString.hpp> 9 #include <xercesc/util/XMLUni.hpp> 10 #include <xercesc/sax2/SAX2XMLReader.hpp> 11 #include <xercesc/sax2/XMLReaderFactory.hpp> 26 StorageWrap::StorageWrap(std::unique_ptr<Storage> storage) : storage(
std::
move(storage)) {}
36 }
catch (
const XMLException &
e) {
37 throw cms::Exception(
"XMLDocument") <<
"cms::concurrency::xercesInitialize failed " 52 parser(XMLReaderFactory::createXMLReader()),
60 parser(XMLReaderFactory::createXMLReader()),
67 parser->setFeature(XMLUni::fgSAX2CoreValidation,
false);
68 parser->setFeature(XMLUni::fgSAX2CoreNameSpaces,
false);
69 parser->setFeature(XMLUni::fgXercesSchema,
false);
70 parser->setFeature(XMLUni::fgXercesSchemaFullChecking,
false);
72 parser->setContentHandler(&handler);
73 parser->setLexicalHandler(&handler);
74 parser->setErrorHandler(&handler);
77 throw cms::Exception(
"XMLParseError") <<
"SAXParser::parseFirst failed" << std::endl;
78 }
catch (
const XMLException &
e) {
80 <<
"cms::concurrency::xercesInitialize failed because of " <<
XMLSimpleStr(
e.getMessage()) << std::endl;
81 }
catch (
const SAXException &
e) {
83 <<
"XML parser reported: " <<
XMLSimpleStr(
e.getMessage()) <<
"." << std::endl;
95 }
catch (
const XMLException &
e) {
97 <<
"cms::concurrency::xercesInitialize failed because of " <<
XMLSimpleStr(
e.getMessage()) << std::endl;
98 }
catch (
const SAXException &
e) {
100 <<
"XML parser reported: " <<
XMLSimpleStr(
e.getMessage()) <<
"." << std::endl;
113 char *rawBuf =
reinterpret_cast<char *
>(
buf);
114 unsigned int bytes = size *
sizeof(XMLByte);
115 unsigned int read = 0;
117 while (
read < bytes) {
124 unsigned int len =
buffer.length();
125 unsigned int rem = bytes -
read;
127 std::memcpy(rawBuf +
read,
buffer.c_str(), rem);
133 std::memcpy(rawBuf +
read,
buffer.c_str(), len);
138 read /=
sizeof(XMLByte);
146 throw cms::Exception(
"FileStreamError") <<
"I/O stream bad in STLInputStream::STLInputStream()" << std::endl;
152 char *rawBuf =
reinterpret_cast<char *
>(
buf);
153 unsigned int bytes = size *
sizeof(XMLByte);
154 in.read(rawBuf, bytes);
158 throw cms::Exception(
"FileStreamError") <<
"I/O stream bad in STLInputStream::readBytes()" << std::endl;
162 for (
unsigned int i = 1;
i <=
rest;
i++)
170 :
in(
in), lstr(LZMA_STREAM_INIT), compression_(
false), lasttotal_(0) {
179 lstr = LZMA_STREAM_INIT;
183 #if LZMA_VERSION <= UINT32_C(49990030) 186 int ret = lzma_auto_decoder(&
lstr, -1, 0);
189 if (
ret != LZMA_OK) {
191 throw cms::Exception(
"IO") <<
"Error while reading compressed LHE file";
200 assert(
sizeof(XMLByte) ==
sizeof(
unsigned char));
207 ex <<
"Error while reading buffered LHE file";
216 unsigned int dataRead;
224 lstr.avail_in = dataRead;
226 lstr.avail_out = size;
227 int ret = lzma_code(&
lstr, LZMA_RUN);
228 if (
ret != LZMA_OK &&
ret != LZMA_STREAM_END) {
230 throw cms::Exception(
"IO") <<
"Error while reading compressed LHE file (error code " <<
ret <<
")";
232 dataRead -=
lstr.avail_in;
243 dataRead = (size -
lstr.avail_out);
void init(Handler &handler)
ret
prodAgent to be discontinued
std::unique_ptr< XercesPlatform > platform
XERCES_CPP_NAMESPACE_QUALIFIER XMLPScanToken token
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER SAX2XMLReader > parser
std::unique_ptr< XERCES_CPP_NAMESPACE_QUALIFIER InputSource > source
XMLDocument(std::unique_ptr< std::istream > &in, Handler &handler)
virtual IOOffset position() const
std::unique_ptr< Storage > storage
static std::string const source