iphreeqc/common/PHRQ_base.cxx
Scott R Charlton adbe4d666f added common directory for Parser/PHRQ_base/PHRQ_io/phrqtype/Utils
git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@10053 1feff8c3-07ed-0310-ac33-dd36852eb9cd
2015-08-08 00:32:59 +00:00

108 lines
1.5 KiB
C++

#include "PHRQ_base.h"
#include <iostream>
#include "PHRQ_io.h"
PHRQ_base::
PHRQ_base(void)
{
this->io = NULL;
base_error_count = 0;
}
PHRQ_base::
PHRQ_base(PHRQ_io * p_io)
{
this->io = p_io;
base_error_count = 0;
}
PHRQ_base::
~PHRQ_base()
{
}
void PHRQ_base::
error_msg(const std::string & stdstr, int stop)
{
this->base_error_count++;
std::ostringstream msg;
msg << "ERROR: " << stdstr << "\n";
if (this->io)
{
this->io->output_msg(msg.str().c_str());
this->io->log_msg(msg.str().c_str());
this->io->error_msg("\n");
this->io->error_msg(msg.str().c_str(), stop!=0);
}
else
{
#if !defined(R_SO)
std::cerr << msg.str().c_str();
std::cout << msg.str().c_str();
#endif
}
if (stop != 0)
{
throw PhreeqcStop();
}
}
void PHRQ_base::
warning_msg(const std::string & stdstr)
{
if (this->io)
{
this->io->warning_msg(stdstr.c_str());
}
else
{
#if !defined(R_SO)
std::cerr << stdstr << "\n";
std::cout << stdstr << "\n";
#endif
}
}
void PHRQ_base::
output_msg(const std::string & stdstr)
{
if (this->io)
{
this->io->output_msg(stdstr.c_str());
}
else
{
#if !defined(R_SO)
std::cout << stdstr << "\n";
#endif
}
}
void PHRQ_base::
screen_msg(const std::string & stdstr)
{
if (this->io)
{
this->io->screen_msg(stdstr.c_str());
}
else
{
#if !defined(R_SO)
std::cerr << stdstr << "\n";
#endif
}
}
void PHRQ_base::
echo_msg(const std::string & stdstr)
{
if (this->io)
{
this->io->echo_msg(stdstr.c_str());
}
else
{
#if !defined(R_SO)
std::cout << stdstr << "\n";
#endif
}
}