From e7724180d7747d70e4ccec7adf12e7a0ee7a1fd0 Mon Sep 17 00:00:00 2001 From: Gerald Schmidt Date: Tue, 8 Jul 2008 22:56:57 +0000 Subject: [PATCH] Updated for 1.2.0 - all changes relating to full background validation --- src/validationthread.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ src/validationthread.h | 21 ++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/validationthread.cpp create mode 100644 src/validationthread.h diff --git a/src/validationthread.cpp b/src/validationthread.cpp new file mode 100644 index 0000000..e41c10e --- /dev/null +++ b/src/validationthread.cpp @@ -0,0 +1,62 @@ +#include "wx/wx.h" +#include "validationthread.h" +#include "wrapxerces.h" +#include +#include + +ValidationThread::ValidationThread ( + const char *buffer, + const char *system, + bool *finished, + bool *success, + std::pair *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 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() +{ +} diff --git a/src/validationthread.h b/src/validationthread.h new file mode 100644 index 0000000..06b0fd3 --- /dev/null +++ b/src/validationthread.h @@ -0,0 +1,21 @@ +#ifndef VALIDATION_THREAD_H +#define VALIDATION_THREAD_H + +#include +#include +#include + +class ValidationThread : public wxThread +{ +public: + ValidationThread ( const char *buffer, const char *system, bool *finished, bool *success, std::pair *position, std::string *message ); + virtual void *Entry(); + virtual void OnExit(); +private: + std::string myBuffer, mySystem; + bool *myFinishedPtr, *mySuccessPtr; + std::pair *myPositionPtr; + std::string *myMessagePtr; +}; + +#endif