cleaned up xerces and some old-style-casts
This commit is contained in:
parent
03552b0bb6
commit
505c6ca44d
@ -12,25 +12,25 @@
|
||||
|
||||
job_receiver::job_receiver(std::string the_jobfilenamepattern) {
|
||||
try {
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize();
|
||||
xercesc::XMLPlatformUtils::Initialize();
|
||||
}
|
||||
catch (const XERCES_CPP_NAMESPACE_QUALIFIER XMLException& toCatch) {
|
||||
char* ini_error=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
||||
catch (const xercesc::XMLException& toCatch) {
|
||||
char* ini_error=xercesc::XMLString::transcode(toCatch.getMessage());
|
||||
job_exception new_exception(std::string("xerces initialisation error: ")+ini_error);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&ini_error);
|
||||
xercesc::XMLString::release(&ini_error);
|
||||
throw new_exception;
|
||||
}
|
||||
|
||||
jobfilename=NULL;
|
||||
setFilenamePattern(the_jobfilenamepattern);
|
||||
parser=new XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser();
|
||||
parser=new xercesc::XercesDOMParser();
|
||||
if (parser==NULL) {
|
||||
delete jobfilename;
|
||||
throw job_exception("could not allocate parser");
|
||||
}
|
||||
parser->setValidationScheme(XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser::Val_Always);
|
||||
parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
|
||||
parser->setDoNamespaces(true);
|
||||
errHandler = (XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler*) new XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase();
|
||||
errHandler = (xercesc::ErrorHandler*) new xercesc::HandlerBase();
|
||||
parser->setErrorHandler(errHandler);
|
||||
}
|
||||
|
||||
@ -55,58 +55,58 @@ job* job_receiver::receive(const std::string& filename) {
|
||||
try {
|
||||
parser->parse(filename.c_str());
|
||||
}
|
||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER XMLException& toCatch) {
|
||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
||||
catch(const xercesc::XMLException& toCatch) {
|
||||
char* message = xercesc::XMLString::transcode(toCatch.getMessage());
|
||||
job_exception je(std::string("XML error: ")+message);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
||||
xercesc::XMLString::release(&message);
|
||||
throw je;
|
||||
}
|
||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& toCatch) {
|
||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.msg);
|
||||
catch(const xercesc::DOMException& toCatch) {
|
||||
char* message = xercesc::XMLString::transcode(toCatch.msg);
|
||||
job_exception je(std::string("XML DOM error: ")+message);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
||||
xercesc::XMLString::release(&message);
|
||||
throw je;
|
||||
}
|
||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER SAXParseException& toCatch) {
|
||||
catch(const xercesc::SAXParseException& toCatch) {
|
||||
// more verbose for parser errors
|
||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
||||
char* message = xercesc::XMLString::transcode(toCatch.getMessage());
|
||||
job_exception je(std::string("XML SAX Parser error: ")+message);
|
||||
char location[100];
|
||||
snprintf(location,sizeof(location),", line %ld column %ld",toCatch.getLineNumber(),toCatch.getColumnNumber());
|
||||
snprintf(location,sizeof(location),", line %ld column %ld",(long int) toCatch.getLineNumber(),(long int)toCatch.getColumnNumber());
|
||||
je.append(location);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
||||
xercesc::XMLString::release(&message);
|
||||
throw je;
|
||||
}
|
||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER SAXException& toCatch) {
|
||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
||||
catch(const xercesc::SAXException& toCatch) {
|
||||
char* message = xercesc::XMLString::transcode(toCatch.getMessage());
|
||||
job_exception je(std::string("XML SAX error: ")+message);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
||||
xercesc::XMLString::release(&message);
|
||||
throw je;
|
||||
}
|
||||
|
||||
// extract root element, root attributes and root name
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* doc=parser->getDocument();
|
||||
xercesc::DOMDocument* doc=parser->getDocument();
|
||||
if (doc==NULL) throw job_exception("xml job document not found");
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* rootelement=doc->getDocumentElement();
|
||||
xercesc::DOMElement* rootelement=doc->getDocumentElement();
|
||||
if (rootelement==NULL) throw job_exception("xml job root document not found");
|
||||
char* docname=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(rootelement->getNodeName());
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNamedNodeMap* rootattrs=rootelement->getAttributes();
|
||||
char* docname=xercesc::XMLString::transcode(rootelement->getNodeName());
|
||||
xercesc::DOMNamedNodeMap* rootattrs=rootelement->getAttributes();
|
||||
|
||||
// check the job number
|
||||
XMLCh* docnoname=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode("no");
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* jobno_attr=rootattrs->getNamedItem(docnoname);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docnoname);
|
||||
XMLCh* docnoname=xercesc::XMLString::transcode("no");
|
||||
xercesc::DOMNode* jobno_attr=rootattrs->getNamedItem(docnoname);
|
||||
xercesc::XMLString::release(&docnoname);
|
||||
if (jobno_attr==NULL) {
|
||||
docnoname=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode("no");
|
||||
docnoname=xercesc::XMLString::transcode("no");
|
||||
jobno_attr=rootattrs->getNamedItem(docnoname);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docnoname);
|
||||
xercesc::XMLString::release(&docnoname);
|
||||
}
|
||||
size_t no=0;
|
||||
if (jobno_attr==NULL) fprintf(stderr,"Warning: job %" SIZETPRINTFLETTER ": root element has no job number\n",no);
|
||||
else {
|
||||
char* docno=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(jobno_attr->getNodeValue());
|
||||
char* docno=xercesc::XMLString::transcode(jobno_attr->getNodeValue());
|
||||
no=strtoul(docno,NULL,0);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docno);
|
||||
xercesc::XMLString::release(&docno);
|
||||
}
|
||||
|
||||
job* this_job=NULL;
|
||||
@ -130,15 +130,15 @@ job* job_receiver::receive(const std::string& filename) {
|
||||
try {
|
||||
this_job=new experiment(no, rootelement);
|
||||
}
|
||||
catch (const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& de) {
|
||||
char* domerrmsg=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(de.msg);
|
||||
catch (const xercesc::DOMException& de) {
|
||||
char* domerrmsg=xercesc::XMLString::transcode(de.msg);
|
||||
char domerrno[5];
|
||||
snprintf(domerrno,5,"%d",de.code);
|
||||
job_exception je("sorry, something happend while parsing experiment job: ");
|
||||
je.append(domerrmsg);
|
||||
je.append(", code ");
|
||||
je.append(domerrno);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&domerrmsg);
|
||||
xercesc::XMLString::release(&domerrmsg);
|
||||
// cleanup missing
|
||||
throw je;
|
||||
}
|
||||
@ -147,21 +147,21 @@ job* job_receiver::receive(const std::string& filename) {
|
||||
try {
|
||||
this_job=new configuration(no, rootelement);
|
||||
}
|
||||
catch (const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& de) {
|
||||
char* domerrmsg=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(de.msg);
|
||||
catch (const xercesc::DOMException& de) {
|
||||
char* domerrmsg=xercesc::XMLString::transcode(de.msg);
|
||||
char domerrno[5];
|
||||
snprintf(domerrno,5,"%d",de.code);
|
||||
job_exception je("sorry, something happend while parsing configuration job: ");
|
||||
je.append(domerrmsg);
|
||||
je.append(", code ");
|
||||
je.append(domerrno);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&domerrmsg);
|
||||
xercesc::XMLString::release(&domerrmsg);
|
||||
// cleanup missing
|
||||
throw je;
|
||||
}
|
||||
}
|
||||
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docname);
|
||||
xercesc::XMLString::release(&docname);
|
||||
parser->reset();
|
||||
parser->resetDocument();
|
||||
parser->resetDocumentPool();
|
||||
@ -174,5 +174,5 @@ job_receiver::~job_receiver() {
|
||||
delete jobfilename;
|
||||
delete errHandler;
|
||||
delete parser;
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Terminate();
|
||||
xercesc::XMLPlatformUtils::Terminate();
|
||||
}
|
||||
|
@ -476,16 +476,16 @@ int xml_result_writer::write_configuration_results_to_file(const std::string& fi
|
||||
fprintf(out,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
|
||||
fprintf(out,"<result job=\"%" SIZETPRINTFLETTER "\">\n<configuration>\n",ress.job_no);
|
||||
XMLCh tempStr[100];
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode("LS", tempStr, 99);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation *impl2=XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementationRegistry::getDOMImplementation(tempStr);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMLSSerializer *theSerializer=((XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementationLS*)impl2)->createLSSerializer();
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMLSOutput *theOutputDesc=((XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementationLS*)impl2)->createLSOutput();
|
||||
xercesc::XMLString::transcode("LS", tempStr, 99);
|
||||
xercesc::DOMImplementation *impl2 = xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr);
|
||||
xercesc::DOMLSSerializer *theSerializer=(static_cast<xercesc::DOMImplementationLS*>(impl2))->createLSSerializer();
|
||||
xercesc::DOMLSOutput *theOutputDesc=(static_cast<xercesc::DOMImplementationLS*>(impl2))->createLSOutput();
|
||||
|
||||
for (configuration_results::const_iterator i=ress.begin(); i!=ress.end(); ++i)
|
||||
if ((*i)->tag->getDocumentElement()!=NULL) {
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER MemBufFormatTarget mem;
|
||||
xercesc::MemBufFormatTarget mem;
|
||||
theOutputDesc->setByteStream(&mem);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *the_node = (*i)->tag->getDocumentElement();
|
||||
xercesc::DOMNode *the_node = (*i)->tag->getDocumentElement();
|
||||
theSerializer->write(the_node ,theOutputDesc);
|
||||
//theSerializer->writeNode(&mem,*((*i)->tag->getDocumentElement()));
|
||||
|
||||
@ -614,9 +614,9 @@ int xml_result_writer::write_adcdata_formated(FILE* out, const std::string& form
|
||||
int xml_result_writer::write_adcdata_base64(FILE* out, const adc_result* res) const {
|
||||
fprintf(out,"<adcdata samples=\"%" SIZETPRINTFLETTER "\" rate=\"%g\" channels=\"%i\">\n",res->samples,res->sampling_frequency, res->nchannels);
|
||||
unsigned int base64length=0;
|
||||
XMLByte* base64buffer=XERCES_CPP_NAMESPACE_QUALIFIER Base64::encode((XMLByte*)res->data,res->samples*res->nchannels*sizeof(short int),(XMLSize_t*)&base64length);
|
||||
XMLByte* base64buffer=xercesc::Base64::encode( reinterpret_cast<XMLByte*>(res->data),res->samples*res->nchannels*sizeof(short int),reinterpret_cast<XMLSize_t*>(&base64length));
|
||||
fwrite(base64buffer,1,base64length,out);
|
||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release((char**)&base64buffer);
|
||||
xercesc::XMLString::release(reinterpret_cast<char**>(&base64buffer));
|
||||
fprintf(out,"</adcdata>\n");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user