Updated for 1.2.0 - all changes relating to full background validation
This commit is contained in:
parent
73b96def2a
commit
e7724180d7
|
@ -0,0 +1,62 @@
|
|||
#include "wx/wx.h"
|
||||
#include "validationthread.h"
|
||||
#include "wrapxerces.h"
|
||||
#include <stdexcept>
|
||||
#include <memory>
|
||||
|
||||
ValidationThread::ValidationThread (
|
||||
const char *buffer,
|
||||
const char *system,
|
||||
bool *finished,
|
||||
bool *success,
|
||||
std::pair<int, int> *position,
|
||||
std::string *message ) : wxThread()
|
||||
{
|
||||
if (!buffer || !success || !position || !message )
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
myBuffer = buffer;
|
||||
mySystem = system;
|
||||
myFinishedPtr = finished;
|
||||
mySuccessPtr = success;
|
||||
myPositionPtr = position;
|
||||
myMessagePtr = message;
|
||||
}
|
||||
|
||||
void *ValidationThread::Entry()
|
||||
{
|
||||
std::auto_ptr<WrapXerces> validator ( new WrapXerces() );
|
||||
|
||||
if ( TestDestroy() )
|
||||
Exit();
|
||||
|
||||
bool res = validator->validateMemory (
|
||||
myBuffer.c_str(),
|
||||
mySystem.c_str(),
|
||||
myBuffer.size() );
|
||||
|
||||
if ( TestDestroy() )
|
||||
Exit();
|
||||
|
||||
if ( !res )
|
||||
{
|
||||
*mySuccessPtr = res;
|
||||
*myPositionPtr = validator->getErrorPosition();
|
||||
*myMessagePtr = validator->getLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
*mySuccessPtr = true;
|
||||
*myPositionPtr = std::make_pair ( 0, 0 );
|
||||
*myMessagePtr = "";
|
||||
}
|
||||
*myFinishedPtr = true;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ValidationThread::OnExit()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef VALIDATION_THREAD_H
|
||||
#define VALIDATION_THREAD_H
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <wx/thread.h>
|
||||
|
||||
class ValidationThread : public wxThread
|
||||
{
|
||||
public:
|
||||
ValidationThread ( const char *buffer, const char *system, bool *finished, bool *success, std::pair<int, int> *position, std::string *message );
|
||||
virtual void *Entry();
|
||||
virtual void OnExit();
|
||||
private:
|
||||
std::string myBuffer, mySystem;
|
||||
bool *myFinishedPtr, *mySuccessPtr;
|
||||
std::pair<int, int> *myPositionPtr;
|
||||
std::string *myMessagePtr;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue