iphreeqc/ErrorReporter.hxx
Scott R Charlton e180be69b0 Rearranging IPhreeqc
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@4106 1feff8c3-07ed-0310-ac33-dd36852eb9cd
2010-02-23 05:04:35 +00:00

61 lines
1.1 KiB
C++

#if !defined(__ERROR_REPORTER_HXX_INC)
#define __ERROR_REPORTER_HXX_INC
#include <iosfwd> // std::ostream
#include <cstdio> // std::fprintf
#include "phreeqcns.hxx"
class IErrorReporter {
public:
virtual size_t AddError(const char* error_msg) = 0;
virtual void Clear(void) = 0;
};
template <typename OS>
class CErrorReporter : public IErrorReporter
{
public:
CErrorReporter(void);
virtual ~CErrorReporter(void);
virtual size_t AddError(const char *error_msg);
virtual void Clear(void);
OS* GetOS(void) { return m_pOS; }
protected:
OS* m_pOS;
size_t m_error_count;
};
template<typename OS>
CErrorReporter<OS>::CErrorReporter(void)
: m_pOS(0)
, m_error_count(0)
{
this->m_pOS = new OS;
}
template<typename OS>
CErrorReporter<OS>::~CErrorReporter(void)
{
delete this->m_pOS;
}
template<typename OS>
size_t CErrorReporter<OS>::AddError(const char* error_msg)
{
++this->m_error_count;
(*this->m_pOS) << error_msg;
return this->m_error_count;
}
template<typename OS>
void CErrorReporter<OS>::Clear(void)
{
this->m_error_count = 0;
delete this->m_pOS;
this->m_pOS = new OS;
}
#endif // __ERROR_REPORTER_HXX_INC