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) {
|
job_receiver::job_receiver(std::string the_jobfilenamepattern) {
|
||||||
try {
|
try {
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize();
|
xercesc::XMLPlatformUtils::Initialize();
|
||||||
}
|
}
|
||||||
catch (const XERCES_CPP_NAMESPACE_QUALIFIER XMLException& toCatch) {
|
catch (const xercesc::XMLException& toCatch) {
|
||||||
char* ini_error=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
char* ini_error=xercesc::XMLString::transcode(toCatch.getMessage());
|
||||||
job_exception new_exception(std::string("xerces initialisation error: ")+ini_error);
|
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;
|
throw new_exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobfilename=NULL;
|
jobfilename=NULL;
|
||||||
setFilenamePattern(the_jobfilenamepattern);
|
setFilenamePattern(the_jobfilenamepattern);
|
||||||
parser=new XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser();
|
parser=new xercesc::XercesDOMParser();
|
||||||
if (parser==NULL) {
|
if (parser==NULL) {
|
||||||
delete jobfilename;
|
delete jobfilename;
|
||||||
throw job_exception("could not allocate parser");
|
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);
|
parser->setDoNamespaces(true);
|
||||||
errHandler = (XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler*) new XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase();
|
errHandler = (xercesc::ErrorHandler*) new xercesc::HandlerBase();
|
||||||
parser->setErrorHandler(errHandler);
|
parser->setErrorHandler(errHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,58 +55,58 @@ job* job_receiver::receive(const std::string& filename) {
|
|||||||
try {
|
try {
|
||||||
parser->parse(filename.c_str());
|
parser->parse(filename.c_str());
|
||||||
}
|
}
|
||||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER XMLException& toCatch) {
|
catch(const xercesc::XMLException& toCatch) {
|
||||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
char* message = xercesc::XMLString::transcode(toCatch.getMessage());
|
||||||
job_exception je(std::string("XML error: ")+message);
|
job_exception je(std::string("XML error: ")+message);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
xercesc::XMLString::release(&message);
|
||||||
throw je;
|
throw je;
|
||||||
}
|
}
|
||||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& toCatch) {
|
catch(const xercesc::DOMException& toCatch) {
|
||||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.msg);
|
char* message = xercesc::XMLString::transcode(toCatch.msg);
|
||||||
job_exception je(std::string("XML DOM error: ")+message);
|
job_exception je(std::string("XML DOM error: ")+message);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
xercesc::XMLString::release(&message);
|
||||||
throw je;
|
throw je;
|
||||||
}
|
}
|
||||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER SAXParseException& toCatch) {
|
catch(const xercesc::SAXParseException& toCatch) {
|
||||||
// more verbose for parser errors
|
// 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);
|
job_exception je(std::string("XML SAX Parser error: ")+message);
|
||||||
char location[100];
|
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);
|
je.append(location);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
xercesc::XMLString::release(&message);
|
||||||
throw je;
|
throw je;
|
||||||
}
|
}
|
||||||
catch(const XERCES_CPP_NAMESPACE_QUALIFIER SAXException& toCatch) {
|
catch(const xercesc::SAXException& toCatch) {
|
||||||
char* message = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toCatch.getMessage());
|
char* message = xercesc::XMLString::transcode(toCatch.getMessage());
|
||||||
job_exception je(std::string("XML SAX error: ")+message);
|
job_exception je(std::string("XML SAX error: ")+message);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&message);
|
xercesc::XMLString::release(&message);
|
||||||
throw je;
|
throw je;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract root element, root attributes and root name
|
// 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");
|
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");
|
if (rootelement==NULL) throw job_exception("xml job root document not found");
|
||||||
char* docname=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(rootelement->getNodeName());
|
char* docname=xercesc::XMLString::transcode(rootelement->getNodeName());
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNamedNodeMap* rootattrs=rootelement->getAttributes();
|
xercesc::DOMNamedNodeMap* rootattrs=rootelement->getAttributes();
|
||||||
|
|
||||||
// check the job number
|
// check the job number
|
||||||
XMLCh* docnoname=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode("no");
|
XMLCh* docnoname=xercesc::XMLString::transcode("no");
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* jobno_attr=rootattrs->getNamedItem(docnoname);
|
xercesc::DOMNode* jobno_attr=rootattrs->getNamedItem(docnoname);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docnoname);
|
xercesc::XMLString::release(&docnoname);
|
||||||
if (jobno_attr==NULL) {
|
if (jobno_attr==NULL) {
|
||||||
docnoname=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode("no");
|
docnoname=xercesc::XMLString::transcode("no");
|
||||||
jobno_attr=rootattrs->getNamedItem(docnoname);
|
jobno_attr=rootattrs->getNamedItem(docnoname);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docnoname);
|
xercesc::XMLString::release(&docnoname);
|
||||||
}
|
}
|
||||||
size_t no=0;
|
size_t no=0;
|
||||||
if (jobno_attr==NULL) fprintf(stderr,"Warning: job %" SIZETPRINTFLETTER ": root element has no job number\n",no);
|
if (jobno_attr==NULL) fprintf(stderr,"Warning: job %" SIZETPRINTFLETTER ": root element has no job number\n",no);
|
||||||
else {
|
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);
|
no=strtoul(docno,NULL,0);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docno);
|
xercesc::XMLString::release(&docno);
|
||||||
}
|
}
|
||||||
|
|
||||||
job* this_job=NULL;
|
job* this_job=NULL;
|
||||||
@ -130,15 +130,15 @@ job* job_receiver::receive(const std::string& filename) {
|
|||||||
try {
|
try {
|
||||||
this_job=new experiment(no, rootelement);
|
this_job=new experiment(no, rootelement);
|
||||||
}
|
}
|
||||||
catch (const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& de) {
|
catch (const xercesc::DOMException& de) {
|
||||||
char* domerrmsg=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(de.msg);
|
char* domerrmsg=xercesc::XMLString::transcode(de.msg);
|
||||||
char domerrno[5];
|
char domerrno[5];
|
||||||
snprintf(domerrno,5,"%d",de.code);
|
snprintf(domerrno,5,"%d",de.code);
|
||||||
job_exception je("sorry, something happend while parsing experiment job: ");
|
job_exception je("sorry, something happend while parsing experiment job: ");
|
||||||
je.append(domerrmsg);
|
je.append(domerrmsg);
|
||||||
je.append(", code ");
|
je.append(", code ");
|
||||||
je.append(domerrno);
|
je.append(domerrno);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&domerrmsg);
|
xercesc::XMLString::release(&domerrmsg);
|
||||||
// cleanup missing
|
// cleanup missing
|
||||||
throw je;
|
throw je;
|
||||||
}
|
}
|
||||||
@ -147,21 +147,21 @@ job* job_receiver::receive(const std::string& filename) {
|
|||||||
try {
|
try {
|
||||||
this_job=new configuration(no, rootelement);
|
this_job=new configuration(no, rootelement);
|
||||||
}
|
}
|
||||||
catch (const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& de) {
|
catch (const xercesc::DOMException& de) {
|
||||||
char* domerrmsg=XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(de.msg);
|
char* domerrmsg=xercesc::XMLString::transcode(de.msg);
|
||||||
char domerrno[5];
|
char domerrno[5];
|
||||||
snprintf(domerrno,5,"%d",de.code);
|
snprintf(domerrno,5,"%d",de.code);
|
||||||
job_exception je("sorry, something happend while parsing configuration job: ");
|
job_exception je("sorry, something happend while parsing configuration job: ");
|
||||||
je.append(domerrmsg);
|
je.append(domerrmsg);
|
||||||
je.append(", code ");
|
je.append(", code ");
|
||||||
je.append(domerrno);
|
je.append(domerrno);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&domerrmsg);
|
xercesc::XMLString::release(&domerrmsg);
|
||||||
// cleanup missing
|
// cleanup missing
|
||||||
throw je;
|
throw je;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&docname);
|
xercesc::XMLString::release(&docname);
|
||||||
parser->reset();
|
parser->reset();
|
||||||
parser->resetDocument();
|
parser->resetDocument();
|
||||||
parser->resetDocumentPool();
|
parser->resetDocumentPool();
|
||||||
@ -174,5 +174,5 @@ job_receiver::~job_receiver() {
|
|||||||
delete jobfilename;
|
delete jobfilename;
|
||||||
delete errHandler;
|
delete errHandler;
|
||||||
delete parser;
|
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,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
|
||||||
fprintf(out,"<result job=\"%" SIZETPRINTFLETTER "\">\n<configuration>\n",ress.job_no);
|
fprintf(out,"<result job=\"%" SIZETPRINTFLETTER "\">\n<configuration>\n",ress.job_no);
|
||||||
XMLCh tempStr[100];
|
XMLCh tempStr[100];
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode("LS", tempStr, 99);
|
xercesc::XMLString::transcode("LS", tempStr, 99);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation *impl2=XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementationRegistry::getDOMImplementation(tempStr);
|
xercesc::DOMImplementation *impl2 = xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMLSSerializer *theSerializer=((XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementationLS*)impl2)->createLSSerializer();
|
xercesc::DOMLSSerializer *theSerializer=(static_cast<xercesc::DOMImplementationLS*>(impl2))->createLSSerializer();
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER DOMLSOutput *theOutputDesc=((XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementationLS*)impl2)->createLSOutput();
|
xercesc::DOMLSOutput *theOutputDesc=(static_cast<xercesc::DOMImplementationLS*>(impl2))->createLSOutput();
|
||||||
|
|
||||||
for (configuration_results::const_iterator i=ress.begin(); i!=ress.end(); ++i)
|
for (configuration_results::const_iterator i=ress.begin(); i!=ress.end(); ++i)
|
||||||
if ((*i)->tag->getDocumentElement()!=NULL) {
|
if ((*i)->tag->getDocumentElement()!=NULL) {
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER MemBufFormatTarget mem;
|
xercesc::MemBufFormatTarget mem;
|
||||||
theOutputDesc->setByteStream(&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->write(the_node ,theOutputDesc);
|
||||||
//theSerializer->writeNode(&mem,*((*i)->tag->getDocumentElement()));
|
//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 {
|
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);
|
fprintf(out,"<adcdata samples=\"%" SIZETPRINTFLETTER "\" rate=\"%g\" channels=\"%i\">\n",res->samples,res->sampling_frequency, res->nchannels);
|
||||||
unsigned int base64length=0;
|
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);
|
fwrite(base64buffer,1,base64length,out);
|
||||||
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release((char**)&base64buffer);
|
xercesc::XMLString::release(reinterpret_cast<char**>(&base64buffer));
|
||||||
fprintf(out,"</adcdata>\n");
|
fprintf(out,"</adcdata>\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user