* Suggestion how to "solve" the XML-reading problems in certain environments:

A workaround has been implemented where it is not tried any more to "directly
  parse the file" but rather the file is read into a memory buffer which then
  is parsed.
  For further information, see MUSR-122.

* Fixed a linking problem when only shared libraries are built on Cygwin
  (introduced with the split-off of libPUserFcnBase).
This commit is contained in:
Bastian M. Wojek
2011-06-16 22:00:33 +00:00
parent e244d2093a
commit dc48ea9712
12 changed files with 533 additions and 29 deletions

View File

@ -30,6 +30,7 @@
#include "TLondon1D.h"
#include <iostream>
#include <fstream>
#include <cassert>
#include <cmath>
using namespace std;
@ -153,7 +154,27 @@ TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -301,7 +322,27 @@ TLondon1D1L::TLondon1D1L() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -484,7 +525,27 @@ TLondon1D2L::TLondon1D2L() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -654,7 +715,27 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -801,7 +882,27 @@ TLondon1D3L::TLondon1D3L() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -970,7 +1071,27 @@ TLondon1D3LS::TLondon1D3LS() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1139,7 +1260,27 @@ double TLondon1D3LS::operator()(double t, const vector<double> &par) const {
// TSAXParser *saxParser = new TSAXParser();
// BMWStartupHandler *startupHandler = new BMWStartupHandler();
// saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
// int status (saxParser->ParseFile(startup_path_name.c_str()));
// //int status (saxParser->ParseFile(startup_path_name.c_str()));
// // parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
// fstream xmlFile;
// unsigned int xmlSize = 0;
// char *xmlBuffer = 0;
// xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
// if (xmlFile.is_open()) { // check if file has been opened successfully
// xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
// xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
// xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
// xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
// xmlFile.close(); // close the XML file
// }
// int status;
// if (!xmlBuffer) { // file has not been read into the buffer
// status = 1;
// } else {
// status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
// delete[] xmlBuffer; // free the buffer memory
// xmlBuffer = 0;
// }
// // check for parse errors
// if (status) { // error
// cout << endl << "**WARNING** Reading/parsing " << startup_path_name << " failed." << endl;

View File

@ -30,6 +30,7 @@
#include "TVortex.h"
#include <iostream>
#include <fstream>
#include <cassert>
#include <cmath>
using namespace std;
@ -165,7 +166,27 @@ TBulkTriVortexLondon::TBulkTriVortexLondon() : fCalcNeeded(true), fFirstCall(tru
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -222,7 +243,27 @@ TBulkSqVortexLondon::TBulkSqVortexLondon() : fCalcNeeded(true), fFirstCall(true)
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -449,7 +490,27 @@ TBulkTriVortexML::TBulkTriVortexML() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -585,7 +646,27 @@ TBulkTriVortexAGL::TBulkTriVortexAGL() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -720,7 +801,27 @@ TBulkTriVortexAGLII::TBulkTriVortexAGLII() : fCalcNeeded(true), fFirstCall(true)
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -868,7 +969,27 @@ TBulkTriVortexNGL::TBulkTriVortexNGL() : fCalcNeeded(true), fFirstCall(true) {
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1020,7 +1141,27 @@ TBulkAnisotropicTriVortexLondonGlobal::TBulkAnisotropicTriVortexLondonGlobal() :
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1259,7 +1400,27 @@ TBulkAnisotropicTriVortexMLGlobal::TBulkAnisotropicTriVortexMLGlobal() : fCalcNe
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \
@ -1498,7 +1659,27 @@ TBulkAnisotropicTriVortexAGLGlobal::TBulkAnisotropicTriVortexAGLGlobal() : fCalc
TSAXParser *saxParser = new TSAXParser();
BMWStartupHandler *startupHandler = new BMWStartupHandler();
saxParser->ConnectToHandler("BMWStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
//int status (saxParser->ParseFile(startup_path_name.c_str()));
// parsing the file as above seems to lead to problems in certain environments; try working around through a buffer as follows
fstream xmlFile;
unsigned int xmlSize = 0;
char *xmlBuffer = 0;
xmlFile.open(startup_path_name.c_str(), ios::in | ios::ate); // open file for reading and go to the end of the file
if (xmlFile.is_open()) { // check if file has been opened successfully
xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
xmlFile.seekg(0, ios::beg); // go back to the beginning of the stream
xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
xmlFile.close(); // close the XML file
}
int status;
if (!xmlBuffer) { // file has not been read into the buffer
status = 1;
} else {
status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
delete[] xmlBuffer; // free the buffer memory
xmlBuffer = 0;
}
// check for parse errors
if (status) { // error
cerr << endl << "**ERROR** Reading/parsing " << startup_path_name << " failed." \