2008-07-09 00:56:57 +02:00
|
|
|
#include "wx/wx.h"
|
2008-07-14 18:21:48 +02:00
|
|
|
#include "xmlctrl.h"
|
2008-07-09 00:56:57 +02:00
|
|
|
#include "validationthread.h"
|
|
|
|
#include "wrapxerces.h"
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
ValidationThread::ValidationThread (
|
|
|
|
const char *buffer,
|
|
|
|
const char *system,
|
|
|
|
bool *finished,
|
|
|
|
bool *success,
|
2008-07-09 19:07:02 +02:00
|
|
|
bool *release,
|
2008-07-09 00:56:57 +02:00
|
|
|
std::pair<int, int> *position,
|
|
|
|
std::string *message ) : wxThread()
|
|
|
|
{
|
|
|
|
if (!buffer || !success || !position || !message )
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
myBuffer = buffer;
|
|
|
|
mySystem = system;
|
|
|
|
myFinishedPtr = finished;
|
|
|
|
mySuccessPtr = success;
|
2008-07-09 19:07:02 +02:00
|
|
|
myReleasePtr = release;
|
2008-07-09 00:56:57 +02:00
|
|
|
myPositionPtr = position;
|
|
|
|
myMessagePtr = message;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *ValidationThread::Entry()
|
|
|
|
{
|
|
|
|
std::auto_ptr<WrapXerces> validator ( new WrapXerces() );
|
2008-07-10 19:06:32 +02:00
|
|
|
|
2008-07-14 18:21:48 +02:00
|
|
|
{
|
|
|
|
//wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection );
|
2008-07-10 19:06:32 +02:00
|
|
|
if ( *myReleasePtr || TestDestroy() )
|
|
|
|
{
|
|
|
|
Exit();
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-14 18:21:48 +02:00
|
|
|
}
|
2008-07-09 00:56:57 +02:00
|
|
|
|
|
|
|
bool res = validator->validateMemory (
|
|
|
|
myBuffer.c_str(),
|
|
|
|
mySystem.c_str(),
|
|
|
|
myBuffer.size() );
|
|
|
|
|
2008-07-14 18:21:48 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
//wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection );
|
2008-07-10 19:06:32 +02:00
|
|
|
if ( *myReleasePtr || TestDestroy() )
|
|
|
|
{
|
|
|
|
Exit();
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-09 00:56:57 +02:00
|
|
|
|
2008-07-10 19:06:32 +02:00
|
|
|
if ( !res )
|
|
|
|
{
|
|
|
|
*mySuccessPtr = res;
|
|
|
|
*myPositionPtr = validator->getErrorPosition();
|
|
|
|
*myMessagePtr = validator->getLastError();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*mySuccessPtr = true;
|
|
|
|
*myPositionPtr = std::make_pair ( 0, 0 );
|
|
|
|
*myMessagePtr = "";
|
|
|
|
}
|
2008-07-14 18:21:48 +02:00
|
|
|
}
|
2008-07-09 00:56:57 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ValidationThread::OnExit()
|
|
|
|
{
|
2008-07-14 18:21:48 +02:00
|
|
|
{
|
|
|
|
//wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection );
|
|
|
|
if ( *myReleasePtr )
|
|
|
|
return;
|
|
|
|
*myFinishedPtr = true;
|
|
|
|
}
|
2008-07-09 00:56:57 +02:00
|
|
|
}
|