mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
need to test on linux
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4165 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
4a1f9aa373
commit
da893cd778
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <iosfwd> // std::ostream
|
#include <iosfwd> // std::ostream
|
||||||
#include <cstdio> // std::fprintf
|
#include <cstdio> // std::fprintf
|
||||||
#include "phreeqcns.hxx"
|
|
||||||
|
|
||||||
class IErrorReporter
|
class IErrorReporter
|
||||||
{
|
{
|
||||||
|
|||||||
233
IPhreeqc.cpp
233
IPhreeqc.cpp
@ -40,6 +40,19 @@ GetLastErrorString(void)
|
|||||||
return IPhreeqc::LibraryInstance()->GetLastErrorString();
|
return IPhreeqc::LibraryInstance()->GetLastErrorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
GetLastWarningString(void)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->GetLastWarningString();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
GetDumpString(void)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->GetDumpString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VRESULT
|
VRESULT
|
||||||
AccumulateLine(const char *line)
|
AccumulateLine(const char *line)
|
||||||
{
|
{
|
||||||
@ -70,6 +83,18 @@ SetLogOn(int value)
|
|||||||
return IPhreeqc::LibraryInstance()->SetLogOn(value != 0);
|
return IPhreeqc::LibraryInstance()->SetLogOn(value != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetDumpOn(int value)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->SetDumpOn(value != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetDumpStringOn(int value)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->SetDumpStringOn(value != 0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Run(void)
|
Run(void)
|
||||||
{
|
{
|
||||||
@ -131,10 +156,34 @@ ClearAccumulatedLines(void)
|
|||||||
IPhreeqc::LibraryInstance()->ClearAccumulatedLines();
|
IPhreeqc::LibraryInstance()->ClearAccumulatedLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GetDumpLineCount(void)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->GetDumpLineCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
GetDumpLine(int n)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->GetDumpLine(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GetErrorLineCount(void)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->GetErrorLineCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
GetErrorLine(int n)
|
||||||
|
{
|
||||||
|
return IPhreeqc::LibraryInstance()->GetErrorLine(n);
|
||||||
|
}
|
||||||
|
|
||||||
IPhreeqc::IPhreeqc(void)
|
IPhreeqc::IPhreeqc(void)
|
||||||
: Phreeqc()
|
: Phreeqc()
|
||||||
, ErrorReporter(0)
|
, ErrorReporter(0)
|
||||||
|
, WarningReporter(0)
|
||||||
, SelectedOutput(0)
|
, SelectedOutput(0)
|
||||||
, DatabaseLoaded(false)
|
, DatabaseLoaded(false)
|
||||||
, SelectedOutputOn(false)
|
, SelectedOutputOn(false)
|
||||||
@ -146,6 +195,7 @@ IPhreeqc::IPhreeqc(void)
|
|||||||
{
|
{
|
||||||
ASSERT(this->phast == 0);
|
ASSERT(this->phast == 0);
|
||||||
this->ErrorReporter = new CErrorReporter<std::ostringstream>;
|
this->ErrorReporter = new CErrorReporter<std::ostringstream>;
|
||||||
|
this->WarningReporter = new CErrorReporter<std::ostringstream>;
|
||||||
this->SelectedOutput = new CSelectedOutput();
|
this->SelectedOutput = new CSelectedOutput();
|
||||||
this->init();
|
this->init();
|
||||||
this->UnLoadDatabase();
|
this->UnLoadDatabase();
|
||||||
@ -154,6 +204,7 @@ IPhreeqc::IPhreeqc(void)
|
|||||||
IPhreeqc::~IPhreeqc(void)
|
IPhreeqc::~IPhreeqc(void)
|
||||||
{
|
{
|
||||||
delete this->ErrorReporter;
|
delete this->ErrorReporter;
|
||||||
|
delete this->WarningReporter;
|
||||||
delete this->SelectedOutput;
|
delete this->SelectedOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,6 +248,11 @@ size_t IPhreeqc::AddError(const char* error_msg)
|
|||||||
return this->ErrorReporter->AddError(error_msg);
|
return this->ErrorReporter->AddError(error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t IPhreeqc::AddWarning(const char* error_msg)
|
||||||
|
{
|
||||||
|
return this->WarningReporter->AddError(error_msg);
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& IPhreeqc::GetAccumulatedLines(void)
|
const std::string& IPhreeqc::GetAccumulatedLines(void)
|
||||||
{
|
{
|
||||||
return this->StringInput;
|
return this->StringInput;
|
||||||
@ -212,18 +268,29 @@ void IPhreeqc::UnLoadDatabase(void)
|
|||||||
// init IPhreeqc
|
// init IPhreeqc
|
||||||
//
|
//
|
||||||
this->DatabaseLoaded = false;
|
this->DatabaseLoaded = false;
|
||||||
this->SelectedOutputOn = false;
|
|
||||||
|
|
||||||
// clear error state
|
// clear error state
|
||||||
//
|
//
|
||||||
ASSERT(this->ErrorReporter);
|
ASSERT(this->ErrorReporter);
|
||||||
this->ErrorReporter->Clear();
|
this->ErrorReporter->Clear();
|
||||||
|
this->LastErrorString.clear();
|
||||||
|
|
||||||
|
// clear warning state
|
||||||
|
//
|
||||||
|
ASSERT(this->WarningReporter);
|
||||||
|
this->WarningReporter->Clear();
|
||||||
|
this->LastWarningString.clear();
|
||||||
|
|
||||||
// clear selectedoutput
|
// clear selectedoutput
|
||||||
//
|
//
|
||||||
ASSERT(this->ErrorReporter);
|
ASSERT(this->SelectedOutput);
|
||||||
this->SelectedOutput->Clear();
|
this->SelectedOutput->Clear();
|
||||||
|
|
||||||
|
// clear dump string
|
||||||
|
//
|
||||||
|
this->DumpString.clear();
|
||||||
|
this->DumpLines.clear();
|
||||||
|
|
||||||
// initialize phreeqc
|
// initialize phreeqc
|
||||||
//
|
//
|
||||||
this->clean_up();
|
this->clean_up();
|
||||||
@ -317,14 +384,25 @@ int IPhreeqc::LoadDatabaseString(const char* input)
|
|||||||
|
|
||||||
void IPhreeqc::OutputLastError(void)
|
void IPhreeqc::OutputLastError(void)
|
||||||
{
|
{
|
||||||
std::cout << ((CErrorReporter<std::ostringstream>*)this->ErrorReporter)->GetOS()->str().c_str() << std::endl;
|
std::cout << this->GetLastErrorString() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* IPhreeqc::GetLastErrorString(void)
|
const char* IPhreeqc::GetLastErrorString(void)
|
||||||
{
|
{
|
||||||
static std::string str;
|
this->LastErrorString = ((CErrorReporter<std::ostringstream>*)this->ErrorReporter)->GetOS()->str();
|
||||||
str = ((CErrorReporter<std::ostringstream>*)this->ErrorReporter)->GetOS()->str();
|
return this->LastErrorString.c_str();
|
||||||
return str.c_str();
|
}
|
||||||
|
|
||||||
|
const char* IPhreeqc::GetLastWarningString(void)
|
||||||
|
{
|
||||||
|
this->LastWarningString = ((CErrorReporter<std::ostringstream>*)this->WarningReporter)->GetOS()->str();
|
||||||
|
return this->LastWarningString.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* IPhreeqc::GetDumpString(void)
|
||||||
|
{
|
||||||
|
return this->DumpString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPhreeqc::check_database(const char* sz_routine)
|
void IPhreeqc::check_database(const char* sz_routine)
|
||||||
@ -341,12 +419,12 @@ void IPhreeqc::check_database(const char* sz_routine)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int output_on, int error_on, int log_on, int selected_output_on, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie)
|
void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie)
|
||||||
{
|
{
|
||||||
std::auto_ptr<std::istringstream> auto_iss(NULL);
|
std::auto_ptr<std::istringstream> auto_iss(NULL);
|
||||||
char token[MAX_LENGTH];
|
char token[MAX_LENGTH];
|
||||||
|
|
||||||
if (output_on)
|
if (this->OutputOn)
|
||||||
{
|
{
|
||||||
if (this->output_open(OUTPUT_MESSAGE, OUTPUT_FILENAME) != OK)
|
if (this->output_open(OUTPUT_MESSAGE, OUTPUT_FILENAME) != OK)
|
||||||
{
|
{
|
||||||
@ -355,7 +433,7 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
this->warning_msg(oss.str().c_str());
|
this->warning_msg(oss.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error_on)
|
if (this->ErrorOn)
|
||||||
{
|
{
|
||||||
if (this->output_open(OUTPUT_ERROR, ERROR_FILENAME) != OK)
|
if (this->output_open(OUTPUT_ERROR, ERROR_FILENAME) != OK)
|
||||||
{
|
{
|
||||||
@ -364,7 +442,7 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
this->warning_msg(oss.str().c_str());
|
this->warning_msg(oss.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (log_on)
|
if (this->LogOn)
|
||||||
{
|
{
|
||||||
if (this->output_open(OUTPUT_LOG, LOG_FILENAME) != OK)
|
if (this->output_open(OUTPUT_LOG, LOG_FILENAME) != OK)
|
||||||
{
|
{
|
||||||
@ -374,8 +452,6 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SelectedOutputOn = (selected_output_on != 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call pre-run callback
|
* call pre-run callback
|
||||||
*/
|
*/
|
||||||
@ -465,7 +541,7 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
// TRUE ???
|
// TRUE ???
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
if (!selected_output_on) ASSERT(!this->output_isopen(OUTPUT_PUNCH));
|
if (!this->SelectedOutputOn) ASSERT(!this->output_isopen(OUTPUT_PUNCH));
|
||||||
|
|
||||||
if (this->pr.punch == FALSE)
|
if (this->pr.punch == FALSE)
|
||||||
{
|
{
|
||||||
@ -479,7 +555,7 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
{
|
{
|
||||||
if (this->punch.new_def == FALSE)
|
if (this->punch.new_def == FALSE)
|
||||||
{
|
{
|
||||||
if (selected_output_on && !this->output_isopen(OUTPUT_PUNCH))
|
if (this->SelectedOutputOn && !this->output_isopen(OUTPUT_PUNCH))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// LoadDatabase
|
// LoadDatabase
|
||||||
@ -504,7 +580,7 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (selected_output_on && !this->output_isopen(OUTPUT_PUNCH))
|
if (this->SelectedOutputOn && !this->output_isopen(OUTPUT_PUNCH))
|
||||||
{
|
{
|
||||||
// This is a special case which could not occur in
|
// This is a special case which could not occur in
|
||||||
// phreeqc
|
// phreeqc
|
||||||
@ -536,7 +612,7 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selected_output_on) ASSERT(!this->output_isopen(OUTPUT_PUNCH));
|
if (!this->SelectedOutputOn) ASSERT(!this->output_isopen(OUTPUT_PUNCH));
|
||||||
/* the converse is not necessarily true */
|
/* the converse is not necessarily true */
|
||||||
|
|
||||||
this->n_user_punch_index = -1;
|
this->n_user_punch_index = -1;
|
||||||
@ -605,7 +681,37 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
/*
|
/*
|
||||||
* dump
|
* dump
|
||||||
*/
|
*/
|
||||||
|
dumper dump_info_save(dump_info);
|
||||||
|
if (this->DumpOn)
|
||||||
|
{
|
||||||
this->dump_entities();
|
this->dump_entities();
|
||||||
|
}
|
||||||
|
if (this->DumpStringOn)
|
||||||
|
{
|
||||||
|
dump_info = dump_info_save;
|
||||||
|
if (dump_info.Get_bool_any())
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
this->dump_ostream(oss);
|
||||||
|
if (dump_info.get_append())
|
||||||
|
{
|
||||||
|
this->DumpString += oss.str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->DumpString = oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill dump lines */
|
||||||
|
this->DumpLines.clear();
|
||||||
|
std::istringstream iss(this->DumpString);
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(iss, line))
|
||||||
|
{
|
||||||
|
this->DumpLines.push_back(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* delete
|
* delete
|
||||||
*/
|
*/
|
||||||
@ -642,6 +748,9 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, FILE* fp, int o
|
|||||||
oss << "</input>\n";
|
oss << "</input>\n";
|
||||||
this->error_msg(oss.str().c_str(), CONTINUE);
|
this->error_msg(oss.str().c_str(), CONTINUE);
|
||||||
}
|
}
|
||||||
|
//{{
|
||||||
|
this->update_errors();
|
||||||
|
//}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -694,7 +803,7 @@ int IPhreeqc::output_handler(const int type, const char *err_str, const int stop
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case OUTPUT_ERROR:
|
case OUTPUT_ERROR:
|
||||||
if (pIPhreeqc && pIPhreeqc->ErrorReporter)
|
if (pIPhreeqc)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "ERROR: " << err_str << "\n";
|
oss << "ERROR: " << err_str << "\n";
|
||||||
@ -706,6 +815,15 @@ int IPhreeqc::output_handler(const int type, const char *err_str, const int stop
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OUTPUT_WARNING:
|
||||||
|
if (pIPhreeqc)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "WARNING: " << err_str << "\n";
|
||||||
|
pIPhreeqc->AddWarning(oss.str().c_str());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case OUTPUT_PUNCH:
|
case OUTPUT_PUNCH:
|
||||||
this->AddSelectedOutput(err_str, format, args);
|
this->AddSelectedOutput(err_str, format, args);
|
||||||
break;
|
break;
|
||||||
@ -1240,6 +1358,11 @@ void IPhreeqc::SetDumpOn(bool bValue)
|
|||||||
this->DumpOn = bValue;
|
this->DumpOn = bValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IPhreeqc::SetDumpStringOn(bool bValue)
|
||||||
|
{
|
||||||
|
this->DumpStringOn = bValue;
|
||||||
|
}
|
||||||
|
|
||||||
void IPhreeqc::SetErrorOn(bool bValue)
|
void IPhreeqc::SetErrorOn(bool bValue)
|
||||||
{
|
{
|
||||||
this->ErrorOn = bValue;
|
this->ErrorOn = bValue;
|
||||||
@ -1424,6 +1547,7 @@ VRESULT IPhreeqc::AccumulateLine(const char *line)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this->ErrorReporter->Clear();
|
this->ErrorReporter->Clear();
|
||||||
|
this->WarningReporter->Clear();
|
||||||
this->StringInput.append(line);
|
this->StringInput.append(line);
|
||||||
this->StringInput.append("\n");
|
this->StringInput.append("\n");
|
||||||
return VR_OK;
|
return VR_OK;
|
||||||
@ -1449,11 +1573,7 @@ int IPhreeqc::Run(void)
|
|||||||
std::istringstream iss(this->GetAccumulatedLines());
|
std::istringstream iss(this->GetAccumulatedLines());
|
||||||
|
|
||||||
// this may throw
|
// this may throw
|
||||||
int output_on = this->OutputOn ? 1 : 0;
|
this->do_run(sz_routine, &iss, NULL, NULL, NULL, NULL);
|
||||||
int error_on = this->ErrorOn ? 1 : 0;
|
|
||||||
int log_on = this->LogOn ? 1 : 0;
|
|
||||||
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
|
|
||||||
this->do_run(sz_routine, &iss, NULL, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
catch (PhreeqcStop)
|
catch (PhreeqcStop)
|
||||||
{
|
{
|
||||||
@ -1474,6 +1594,8 @@ int IPhreeqc::Run(void)
|
|||||||
|
|
||||||
this->ClearAccumulatedLines();
|
this->ClearAccumulatedLines();
|
||||||
this->close_output_files();
|
this->close_output_files();
|
||||||
|
this->update_errors();
|
||||||
|
|
||||||
return this->input_error;
|
return this->input_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1499,11 +1621,7 @@ int IPhreeqc::RunFile(const char* filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this may throw
|
// this may throw
|
||||||
int output_on = this->OutputOn ? 1 : 0;
|
this->do_run(sz_routine, &ifs, NULL, NULL, NULL, NULL);
|
||||||
int error_on = this->ErrorOn ? 1 : 0;
|
|
||||||
int log_on = this->LogOn ? 1 : 0;
|
|
||||||
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
|
|
||||||
this->do_run(sz_routine, &ifs, NULL, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
|
|
||||||
#else
|
#else
|
||||||
// open file
|
// open file
|
||||||
//
|
//
|
||||||
@ -1516,11 +1634,7 @@ int IPhreeqc::RunFile(const char* filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this may throw
|
// this may throw
|
||||||
int output_on = this->OutputOn ? 1 : 0;
|
this->do_run(sz_routine, NULL, f, NULL, NULL, NULL);
|
||||||
int error_on = this->ErrorOn ? 1 : 0;
|
|
||||||
int log_on = this->LogOn ? 1 : 0;
|
|
||||||
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
|
|
||||||
this->do_run(sz_routine, NULL, f, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (PhreeqcStop)
|
catch (PhreeqcStop)
|
||||||
@ -1541,6 +1655,8 @@ int IPhreeqc::RunFile(const char* filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->close_output_files();
|
this->close_output_files();
|
||||||
|
this->update_errors();
|
||||||
|
|
||||||
return this->input_error;
|
return this->input_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1559,11 +1675,7 @@ int IPhreeqc::RunString(const char* input)
|
|||||||
std::istringstream iss(s);
|
std::istringstream iss(s);
|
||||||
|
|
||||||
// this may throw
|
// this may throw
|
||||||
int output_on = this->OutputOn ? 1 : 0;
|
this->do_run(sz_routine, &iss, NULL, NULL, NULL, NULL);
|
||||||
int error_on = this->ErrorOn ? 1 : 0;
|
|
||||||
int log_on = this->LogOn ? 1 : 0;
|
|
||||||
int selected_output_on = this->SelectedOutputOn ? 1 : 0;
|
|
||||||
this->do_run(sz_routine, &iss, NULL, output_on, error_on, log_on, selected_output_on, NULL, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
catch (PhreeqcStop)
|
catch (PhreeqcStop)
|
||||||
{
|
{
|
||||||
@ -1583,6 +1695,8 @@ int IPhreeqc::RunString(const char* input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->close_output_files();
|
this->close_output_files();
|
||||||
|
this->update_errors();
|
||||||
|
|
||||||
return this->input_error;
|
return this->input_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1601,7 +1715,8 @@ VRESULT IPhreeqc::GetSelectedOutputValue(int row, int col, VAR* pVAR)
|
|||||||
this->ErrorReporter->Clear();
|
this->ErrorReporter->Clear();
|
||||||
if (!pVAR)
|
if (!pVAR)
|
||||||
{
|
{
|
||||||
this->AddError("GetSelectedOutputValue: VR_INVALIDARG pVar is NULL.\n");
|
this->AddError("GetSelectedOutputValue: VR_INVALIDARG pVAR is NULL.\n");
|
||||||
|
this->update_errors();
|
||||||
return VR_INVALIDARG;
|
return VR_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1626,5 +1741,47 @@ VRESULT IPhreeqc::GetSelectedOutputValue(int row, int col, VAR* pVAR)
|
|||||||
this->AddError("GetSelectedOutputValue: VR_INVALIDCOL Column index out of range.\n");
|
this->AddError("GetSelectedOutputValue: VR_INVALIDCOL Column index out of range.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this->update_errors();
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int IPhreeqc::GetDumpLineCount(void)const
|
||||||
|
{
|
||||||
|
return (int)this->DumpLines.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* IPhreeqc::GetDumpLine(int n)
|
||||||
|
{
|
||||||
|
if (n < 0 || n >= this->GetDumpLineCount())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this->DumpLines[n].c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
int IPhreeqc::GetErrorLineCount(void)const
|
||||||
|
{
|
||||||
|
return (int)this->ErrorLines.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* IPhreeqc::GetErrorLine(int n)
|
||||||
|
{
|
||||||
|
if (n < 0 || n >= this->GetErrorLineCount())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this->ErrorLines[n].c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IPhreeqc::update_errors(void)
|
||||||
|
{
|
||||||
|
this->LastErrorString = ((CErrorReporter<std::ostringstream>*)this->ErrorReporter)->GetOS()->str();
|
||||||
|
|
||||||
|
this->ErrorLines.clear();
|
||||||
|
std::istringstream iss(this->LastErrorString);
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(iss, line))
|
||||||
|
{
|
||||||
|
this->ErrorLines.push_back(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
34
IPhreeqc.hpp
34
IPhreeqc.hpp
@ -24,17 +24,29 @@ public:
|
|||||||
void UnLoadDatabase(void);
|
void UnLoadDatabase(void);
|
||||||
|
|
||||||
void OutputLastError(void);
|
void OutputLastError(void);
|
||||||
|
|
||||||
const char* GetLastErrorString(void);
|
const char* GetLastErrorString(void);
|
||||||
|
const char* GetLastWarningString(void);
|
||||||
|
const char* GetDumpString(void);
|
||||||
|
|
||||||
|
int GetDumpLineCount(void)const;
|
||||||
|
const char* GetDumpLine(int n);
|
||||||
|
|
||||||
|
int GetErrorLineCount(void)const;
|
||||||
|
const char* GetErrorLine(int n);
|
||||||
|
|
||||||
VRESULT AccumulateLine(const char *line);
|
VRESULT AccumulateLine(const char *line);
|
||||||
|
|
||||||
//{{
|
|
||||||
void SetDumpOn(bool bValue);
|
void SetDumpOn(bool bValue);
|
||||||
|
void SetDumpStringOn(bool bValue);
|
||||||
|
|
||||||
void SetErrorOn(bool bValue);
|
void SetErrorOn(bool bValue);
|
||||||
|
|
||||||
void SetLogOn(bool bValue);
|
void SetLogOn(bool bValue);
|
||||||
|
|
||||||
void SetOutputOn(bool bValue);
|
void SetOutputOn(bool bValue);
|
||||||
|
|
||||||
void SetSelectedOutputOn(bool bValue);
|
void SetSelectedOutputOn(bool bValue);
|
||||||
//}}
|
|
||||||
|
|
||||||
int Run(void);
|
int Run(void);
|
||||||
int RunFile(const char* filename);
|
int RunFile(const char* filename);
|
||||||
@ -47,6 +59,7 @@ public:
|
|||||||
void OutputLines(void);
|
void OutputLines(void);
|
||||||
|
|
||||||
size_t AddError(const char* error_msg);
|
size_t AddError(const char* error_msg);
|
||||||
|
size_t AddWarning(const char* warning_msg);
|
||||||
|
|
||||||
const std::string& GetAccumulatedLines(void);
|
const std::string& GetAccumulatedLines(void);
|
||||||
void ClearAccumulatedLines(void);
|
void ClearAccumulatedLines(void);
|
||||||
@ -74,27 +87,36 @@ public:
|
|||||||
void AddSelectedOutput(const char* name, const char* format, va_list argptr);
|
void AddSelectedOutput(const char* name, const char* format, va_list argptr);
|
||||||
|
|
||||||
void check_database(const char* sz_routine);
|
void check_database(const char* sz_routine);
|
||||||
void do_run(const char* sz_routine, std::istream* pis, FILE* fp, int output_on, int error_on, int log_on, int selected_output_on, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie);
|
void do_run(const char* sz_routine, std::istream* pis, FILE* fp, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void init(void);
|
void init(void);
|
||||||
|
void update_errors(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Data
|
|
||||||
IErrorReporter *ErrorReporter;
|
IErrorReporter *ErrorReporter;
|
||||||
|
std::string LastErrorString;
|
||||||
|
std::vector< std::string > ErrorLines;
|
||||||
|
|
||||||
|
IErrorReporter *WarningReporter;
|
||||||
|
std::string LastWarningString;
|
||||||
|
std::vector< std::string > WarningLines;
|
||||||
|
|
||||||
CSelectedOutput *SelectedOutput;
|
CSelectedOutput *SelectedOutput;
|
||||||
std::string PunchFileName;
|
std::string PunchFileName;
|
||||||
bool DatabaseLoaded;
|
bool DatabaseLoaded;
|
||||||
std::string StringInput;
|
std::string StringInput;
|
||||||
|
|
||||||
bool SelectedOutputOn;
|
bool SelectedOutputOn;
|
||||||
//{{
|
|
||||||
bool OutputOn;
|
bool OutputOn;
|
||||||
bool LogOn;
|
bool LogOn;
|
||||||
bool ErrorOn;
|
bool ErrorOn;
|
||||||
bool DumpOn;
|
bool DumpOn;
|
||||||
bool DumpStringOn;
|
bool DumpStringOn;
|
||||||
//}}
|
|
||||||
|
std::string DumpString;
|
||||||
|
std::vector< std::string > DumpLines;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static IPhreeqc* Instance;
|
static IPhreeqc* Instance;
|
||||||
|
|||||||
@ -12,244 +12,11 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(PHREEQC_CLASS)
|
|
||||||
#include "phrqtype.h"
|
|
||||||
#include "p2c.h"
|
|
||||||
#include "global_structures.h"
|
|
||||||
#include "basic.h"
|
|
||||||
#include "Phreeqc.h"
|
|
||||||
|
|
||||||
// COMMENT: {2/24/2010 6:01:56 PM}extern int user_punch_count_headings;
|
|
||||||
// COMMENT: {2/24/2010 6:01:56 PM}extern char **user_punch_headings;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "SelectedOutput.hxx"
|
#include "SelectedOutput.hxx"
|
||||||
#include "phreeqcns.hxx"
|
|
||||||
|
|
||||||
const size_t RESERVE_ROWS = 80;
|
const size_t RESERVE_ROWS = 80;
|
||||||
const size_t RESERVE_COLS = 80;
|
const size_t RESERVE_COLS = 80;
|
||||||
|
|
||||||
// COMMENT: {3/3/2010 5:31:34 PM}int EndRow(void);
|
|
||||||
void AddSelectedOutput(const char* name, const char* format, va_list argptr);
|
|
||||||
int warning_msg (const char *err_str);
|
|
||||||
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM}int Phreeqc::EndRow(void)
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM}// COMMENT: {3/3/2010 7:29:42 PM} if (CSelectedOutput::Instance()->GetRowCount() <= 1)
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} if (this->SelectedOutput.GetRowCount() <= 1)
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} {
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} // ensure all user_punch headings are included
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} for (int i = n_user_punch_index; i < user_punch_count_headings; ++i)
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} {
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} CSelectedOutput::Instance()->PushBackEmpty(user_punch_headings[i]);
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM} return CSelectedOutput::Instance()->EndRow();
|
|
||||||
// COMMENT: {3/3/2010 8:55:29 PM}}
|
|
||||||
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}int PushBackDouble(const char* key, double dVal)
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM} return CSelectedOutput::Instance()->PushBackDouble(key, dVal);
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}}
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}int PushBackLong(const char* key, long lVal)
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM} return CSelectedOutput::Instance()->PushBackLong(key, lVal);
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}}
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}int PushBackString(const char* key, const char* sVal)
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM} return CSelectedOutput::Instance()->PushBackString(key, sVal);
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}}
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}int PushBackEmpty(const char* key)
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM} return CSelectedOutput::Instance()->PushBackEmpty(key);
|
|
||||||
// COMMENT: {3/3/2010 8:55:40 PM}}
|
|
||||||
|
|
||||||
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}void AddSelectedOutput(const char* name, const char* format, va_list argptr)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} int bInt;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} int bDouble;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} int bString;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} int state;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} int bLongDouble;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} char ch;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} /* state values
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 0 Haven't found start(%)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 1 Just read start(%)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 2 Just read Flags(-0+ #) (zero or more)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 3 Just read Width
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 4 Just read Precision start (.)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 5 Just read Size modifier
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} 6 Just read Type
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} if (name == NULL) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} return;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bDouble = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bInt = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bString = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bLongDouble = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} while (ch != '\0') {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (state) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 0: /* looking for Start specification (%) */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (ch) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case '%':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 1;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} default:
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 1: /* reading Flags (zero or more(-,+,0,# or space)) */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (ch) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case '-': case '0': case '+': case ' ': case '#':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} default:
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 2;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 2: /* reading Minimum field width (decimal integer constant) */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (ch) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case '.':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 3;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} default:
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 4;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 3: /* reading Precision specification (period already read) */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (ch)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} default:
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 4;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 4: /* reading Size modifier */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (ch)
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'l':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'L':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bLongDouble = 1;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'h':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = *format++;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} state = 5;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 5: /* reading Conversion letter */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} switch (ch) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'c':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'd':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'i':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bInt = 1;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'n':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'o':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'p':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 's':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bString = 1;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'u':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'x':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'X':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case '%':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'f':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'e':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'E':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'g':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} case 'G':
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} bDouble = 1;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} default:
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ASSERT(false);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ch = '\0'; /* done */
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} break;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} if (bDouble) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} double valDouble;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} if (bLongDouble) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} valDouble = (double)va_arg(argptr, long double);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} else {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} valDouble = va_arg(argptr, double);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} CSelectedOutput::Instance()->PushBackDouble(name, valDouble);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} else if (bInt) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} int valInt;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} valInt = va_arg(argptr, int);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} CSelectedOutput::Instance()->PushBackLong(name, (long)valInt);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} else if (bString) {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} char* valString;
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} valString = (char *)va_arg(argptr, char *);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} CSelectedOutput::Instance()->PushBackString(name, valString);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} else {
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} ASSERT(false);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} CSelectedOutput::Instance()->PushBackEmpty(name);
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:58:25 PM}}
|
|
||||||
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}// COMMENT: {11/16/2004 10:18:22 PM}CSelectedOutput CSelectedOutput::singleton;
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}CSelectedOutput* CSelectedOutput::s_instance = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}CSelectedOutput* CSelectedOutput::Instance()
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} if (s_instance == 0)
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} {
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} s_instance = new CSelectedOutput;
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} return s_instance;
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}}
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}void CSelectedOutput::Release()
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}{
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} if (s_instance)
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} {
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} delete s_instance;
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} s_instance = 0;
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM} }
|
|
||||||
// COMMENT: {3/3/2010 8:56:03 PM}}
|
|
||||||
|
|
||||||
CSelectedOutput::CSelectedOutput()
|
CSelectedOutput::CSelectedOutput()
|
||||||
: m_nRowCount(0)
|
: m_nRowCount(0)
|
||||||
@ -343,9 +110,6 @@ int CSelectedOutput::EndRow(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// COMMENT: {11/27/2006 7:22:37 PM}#if defined(_DEBUG)
|
|
||||||
// COMMENT: {11/27/2006 7:22:37 PM} this->AssertValid();
|
|
||||||
// COMMENT: {11/27/2006 7:22:37 PM}#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
60
fwrap.c
60
fwrap.c
@ -131,6 +131,42 @@ SetLogOnF(int* log_on)
|
|||||||
::SetLogOn(*log_on);
|
::SetLogOn(*log_on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetDumpOnF(int* dump_on)
|
||||||
|
{
|
||||||
|
::SetDumpOn(*dump_on);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SetDumpStringOnF(int* dump_string_on)
|
||||||
|
{
|
||||||
|
::SetDumpStringOn(*dump_string_on);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GetDumpLineCountF(void)
|
||||||
|
{
|
||||||
|
return ::GetDumpLineCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GetDumpLineF(int* n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
padfstring(line, ::GetDumpLine((*n) - 1), line_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GetErrorLineCountF(void)
|
||||||
|
{
|
||||||
|
return ::GetErrorLineCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GetErrorLineF(int* n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
padfstring(line, ::GetErrorLine((*n) - 1), line_length);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
RunF(void)
|
RunF(void)
|
||||||
{
|
{
|
||||||
@ -293,6 +329,30 @@ void __stdcall SETLOGON(int *log_on)
|
|||||||
{
|
{
|
||||||
SetLogOnF(log_on);
|
SetLogOnF(log_on);
|
||||||
}
|
}
|
||||||
|
void __stdcall SETDUMPON(int *dump_on)
|
||||||
|
{
|
||||||
|
SetDumpOnF(dump_on);
|
||||||
|
}
|
||||||
|
void __stdcall SETDUMPSTRINGON(int *dump_string_on)
|
||||||
|
{
|
||||||
|
SetDumpStringOnF(dump_string_on);
|
||||||
|
}
|
||||||
|
int __stdcall GETDUMPLINECOUNT(void)
|
||||||
|
{
|
||||||
|
return GetDumpLineCountF();
|
||||||
|
}
|
||||||
|
void __stdcall GETDUMPLINE(int *n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
GetDumpLineF(n, line, line_length);
|
||||||
|
}
|
||||||
|
int __stdcall GETERRORLINECOUNT(void)
|
||||||
|
{
|
||||||
|
return GetErrorLineCountF();
|
||||||
|
}
|
||||||
|
void __stdcall GETERRORLINE(int *n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
GetErrorLineF(n, line, line_length);
|
||||||
|
}
|
||||||
int __stdcall RUN(void)
|
int __stdcall RUN(void)
|
||||||
{
|
{
|
||||||
return RunF();
|
return RunF();
|
||||||
|
|||||||
14
fwrap.h
14
fwrap.h
@ -29,7 +29,19 @@ extern "C" {
|
|||||||
|
|
||||||
void SetErrorOnF(int* error_on);
|
void SetErrorOnF(int* error_on);
|
||||||
|
|
||||||
void SetLogOnF(int* error_on);
|
void SetLogOnF(int* log_on);
|
||||||
|
|
||||||
|
void SetDumpOnF(int* dump_on);
|
||||||
|
|
||||||
|
void SetDumpStringOnF(int* dump_string_on);
|
||||||
|
|
||||||
|
int GetDumpLineCountF(void);
|
||||||
|
|
||||||
|
void GetDumpLineF(int* n, char* line, unsigned int line_length);
|
||||||
|
|
||||||
|
int GetErrorLineCountF(void);
|
||||||
|
|
||||||
|
void GetErrorLineF(int* n, char* line, unsigned int line_length);
|
||||||
|
|
||||||
void OutputLastErrorF(void);
|
void OutputLastErrorF(void);
|
||||||
|
|
||||||
|
|||||||
24
fwrap2.c
24
fwrap2.c
@ -38,6 +38,30 @@ void SETLOGON(int *log_on)
|
|||||||
{
|
{
|
||||||
SetLogOnF(log_on);
|
SetLogOnF(log_on);
|
||||||
}
|
}
|
||||||
|
void SETDUMPON(int *dump_on)
|
||||||
|
{
|
||||||
|
SetDumpOnF(dump_on);
|
||||||
|
}
|
||||||
|
void SETDUMPSTRINGON(int *dump_string_on)
|
||||||
|
{
|
||||||
|
SetDumpStringOnF(dump_string_on);
|
||||||
|
}
|
||||||
|
int GETDUMPLINECOUNT(void)
|
||||||
|
{
|
||||||
|
return GetDumpLineCountF();
|
||||||
|
}
|
||||||
|
void GETDUMPLINE(int *n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
GetDumpLineF(n, line, line_length);
|
||||||
|
}
|
||||||
|
int GETERRORLINECOUNT(void)
|
||||||
|
{
|
||||||
|
return GetErrorLineCountF();
|
||||||
|
}
|
||||||
|
void GETERRORLINE(int *n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
GetErrorLineF(n, line, line_length);
|
||||||
|
}
|
||||||
int RUN(void)
|
int RUN(void)
|
||||||
{
|
{
|
||||||
return RunF();
|
return RunF();
|
||||||
|
|||||||
24
fwrap3.c
24
fwrap3.c
@ -38,6 +38,30 @@ void setlogon_(int *log_on)
|
|||||||
{
|
{
|
||||||
SetLogOnF(log_on);
|
SetLogOnF(log_on);
|
||||||
}
|
}
|
||||||
|
void setdumpon_(int *dump_on)
|
||||||
|
{
|
||||||
|
SetLogOnF(dump_on);
|
||||||
|
}
|
||||||
|
void setdumpstringon_(int *dump_string_on)
|
||||||
|
{
|
||||||
|
SetDumpStringOnF(dump_string_on);
|
||||||
|
}
|
||||||
|
int getdumplinecount_(void)
|
||||||
|
{
|
||||||
|
return GetDumpLineCountF();
|
||||||
|
}
|
||||||
|
void getdumpline_(int *n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
GetDumpLineF(n, line, line_length);
|
||||||
|
}
|
||||||
|
int geterrorlinecount_(void)
|
||||||
|
{
|
||||||
|
return GetErrorLineCountF();
|
||||||
|
}
|
||||||
|
void geterrorline_(int *n, char* line, unsigned int line_length)
|
||||||
|
{
|
||||||
|
GetErrorLineF(n, line, line_length);
|
||||||
|
}
|
||||||
int run_(void)
|
int run_(void)
|
||||||
{
|
{
|
||||||
return RunF();
|
return RunF();
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
// phreeqc namespace
|
|
||||||
//
|
|
||||||
|
|
||||||
#if !defined(_INC_GLOBALNS)
|
|
||||||
#define _INC_GLOBALNS
|
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
|
||||||
#pragma warning(disable : 4786) // disable truncation warning
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(PHREEQC_CLASS)
|
|
||||||
#define EXTERNAL extern
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "phqalloc.h"
|
|
||||||
#include "input.h"
|
|
||||||
#include "output.h"
|
|
||||||
#include "phrqproto.h"
|
|
||||||
EXTERNAL int n_user_punch_index;
|
|
||||||
|
|
||||||
#undef EXTERNAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _INC_GLOBALNS */
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user