updated for (Set)CurrentSelectedOutputUserNumber

git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@8028 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
Scott R Charlton 2013-09-13 05:52:16 +00:00
parent ca9a7a486e
commit f5bcccafcb
7 changed files with 365 additions and 304 deletions

View File

@ -11,7 +11,18 @@ int main(void)
return EXIT_FAILURE;
}
iphreeqc.AccumulateLine("TITLE Example 2.--Temperature dependence of solubility");
iphreeqc.SetCurrentSelectedOutputUserNumber(1);
iphreeqc.SetSelectedOutputStringOn(true);
iphreeqc.SetSelectedOutputFileOn(true);
iphreeqc.SetSelectedOutputFileName("state.sel");
iphreeqc.SetCurrentSelectedOutputUserNumber(2);
iphreeqc.SetSelectedOutputStringOn(true);
iphreeqc.SetSelectedOutputFileOn(true);
iphreeqc.SetSelectedOutputFileName("si.sel");
iphreeqc.AccumulateLine("TITLE Temperature dependence of solubility");
iphreeqc.AccumulateLine(" of gypsum and anhydrite ");
iphreeqc.AccumulateLine("SOLUTION 1 Pure water ");
iphreeqc.AccumulateLine(" pH 7.0 ");
@ -22,10 +33,8 @@ int main(void)
iphreeqc.AccumulateLine("REACTION_TEMPERATURE 1 ");
iphreeqc.AccumulateLine(" 25.0 75.0 in 51 steps ");
iphreeqc.AccumulateLine("SELECTED_OUTPUT 1 ");
iphreeqc.AccumulateLine(" -file state.sel ");
iphreeqc.AccumulateLine(" -temperature ");
iphreeqc.AccumulateLine("SELECTED_OUTPUT 2 ");
iphreeqc.AccumulateLine(" -file si.sel ");
iphreeqc.AccumulateLine(" -si anhydrite gypsum ");
iphreeqc.AccumulateLine("END ");
@ -34,33 +43,12 @@ int main(void)
return EXIT_FAILURE;
}
VAR v;
::VarInit(&v);
int c = iphreeqc.GetSelectedOutputCount();
for (int k = 0; k < c; ++k) {
int n = iphreeqc.GetNthSelectedOutputUserNumber(k);
iphreeqc.SetCurrentSelectedOutputUserNumber(n);
std::cout << "selected-output " << n << ":" << std::endl;
for (int i = 0; i < iphreeqc.GetSelectedOutputRowCount(); ++i) {
for (int j = 0; j < iphreeqc.GetSelectedOutputColumnCount(); ++j) {
if (iphreeqc.GetSelectedOutputValue(i, j, &v) == VR_OK) {
switch (v.type) {
case TT_LONG:
std::cout << v.lVal << " ";
break;
case TT_DOUBLE:
std::cout << v.dVal << " ";
break;
case TT_STRING:
std::cout << v.sVal << " ";
break;
}
}
::VarClear(&v);
}
std::cout << std::endl;
}
std::cout << iphreeqc.GetSelectedOutputString() << std::endl;
}
return EXIT_SUCCESS;
}

View File

@ -29,7 +29,6 @@ IPhreeqc::IPhreeqc(void)
: DatabaseLoaded(false)
, ClearAccumulated(false)
, UpdateComponents(true)
, SelectedOutputFileOn(false)
, OutputFileOn(false)
, LogFileOn(false)
, ErrorFileOn(false)
@ -383,7 +382,7 @@ const char* IPhreeqc::GetSelectedOutputFileName(void)const
bool IPhreeqc::GetSelectedOutputFileOn(void)const
{
return this->SelectedOutputFileOn;
return this->get_sel_out_file_on(this->CurrentSelectedOutputUserNumber);
}
int IPhreeqc::GetSelectedOutputRowCount(void)const
@ -811,7 +810,7 @@ void IPhreeqc::SetBasicFortranCallback(double (*fcn)(double *x1, double *x2, cha
VRESULT IPhreeqc::SetCurrentSelectedOutputUserNumber(int n)
{
if (this->PhreeqcPtr->SelectedOutput_map.find(n) != this->PhreeqcPtr->SelectedOutput_map.end())
if (0 <= n)
{
this->CurrentSelectedOutputUserNumber = n;
return VR_OK;
@ -904,7 +903,11 @@ void IPhreeqc::SetSelectedOutputFileName(const char *filename)
void IPhreeqc::SetSelectedOutputFileOn(bool bValue)
{
this->SelectedOutputFileOn = bValue;
// COMMENT: {9/12/2013 6:40:50 PM} this->SelectedOutputFileOn = bValue;
if (0 <= this->CurrentSelectedOutputUserNumber)
{
this->SelectedOutputFileOnMap[this->CurrentSelectedOutputUserNumber] = bValue;
}
}
void IPhreeqc::SetSelectedOutputStringOn(bool bValue)
@ -934,6 +937,10 @@ void IPhreeqc::UnLoadDatabase(void)
// clear selectedoutput
//
this->CurrentSelectedOutputUserNumber = 1;
this->SelectedOutputFileOnMap.clear();
this->SelectedOutputFileOnMap[1] = false;
std::map< int, CSelectedOutput* >::iterator itt = this->SelectedOutputMap.begin();
for (; itt != this->SelectedOutputMap.end(); ++itt)
{
@ -1140,18 +1147,26 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, PFN_PRERUN_CALL
// TRUE ???
//
//
if (!this->SelectedOutputFileOn)
// COMMENT: {9/12/2013 6:47:53 PM} if (!this->SelectedOutputFileOn)
// COMMENT: {9/12/2013 6:47:53 PM} {
// COMMENT: {9/12/2013 6:47:53 PM} std::map< int, SelectedOutput >::iterator it = this->PhreeqcPtr->SelectedOutput_map.begin();
// COMMENT: {9/12/2013 6:47:53 PM} for (; it != this->PhreeqcPtr->SelectedOutput_map.end(); ++it)
// COMMENT: {9/12/2013 6:47:53 PM} {
// COMMENT: {9/12/2013 6:47:53 PM} ASSERT((*it).second.Get_punch_ostream() == 0);
// COMMENT: {9/12/2013 6:47:53 PM} }
// COMMENT: {9/12/2013 6:47:53 PM} }
// COMMENT: {9/12/2013 6:47:53 PM} else
// COMMENT: {9/12/2013 6:47:53 PM} {
// COMMENT: {9/12/2013 6:47:53 PM} ASSERT(TRUE);
// COMMENT: {9/12/2013 6:47:53 PM} }
std::map< int, SelectedOutput >::iterator ai = this->PhreeqcPtr->SelectedOutput_map.begin();
for (; ai != this->PhreeqcPtr->SelectedOutput_map.end(); ++ai)
{
std::map< int, SelectedOutput >::iterator it = this->PhreeqcPtr->SelectedOutput_map.begin();
for (; it != this->PhreeqcPtr->SelectedOutput_map.end(); ++it)
if (!this->SelectedOutputFileOnMap[(*ai).first])
{
ASSERT((*it).second.Get_punch_ostream() == 0);
ASSERT((*ai).second.Get_punch_ostream() == 0);
}
}
else
{
ASSERT(TRUE);
}
if (this->PhreeqcPtr->pr.punch == FALSE)
{
@ -1167,7 +1182,8 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, PFN_PRERUN_CALL
std::map< int, SelectedOutput >::iterator it = this->PhreeqcPtr->SelectedOutput_map.begin();
for (; it != this->PhreeqcPtr->SelectedOutput_map.end(); ++it)
{
if (this->SelectedOutputFileOn && !(*it).second.Get_punch_ostream())
// COMMENT: {9/12/2013 6:42:03 PM} if (this->SelectedOutputFileOn && !(*it).second.Get_punch_ostream())
if (this->SelectedOutputFileOnMap[(*it).first] && !(*it).second.Get_punch_ostream())
{
//
// LoadDatabase
@ -1209,7 +1225,8 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, PFN_PRERUN_CALL
std::map< int, SelectedOutput >::iterator it = this->PhreeqcPtr->SelectedOutput_map.begin();
for (; it != this->PhreeqcPtr->SelectedOutput_map.end(); ++it)
{
if (this->SelectedOutputFileOn)
// COMMENT: {9/12/2013 6:53:23 PM} if (this->SelectedOutputFileOn)
if (this->SelectedOutputFileOnMap[(*it).first])
{
ASSERT((*it).second.Get_punch_ostream());
}
@ -1651,6 +1668,17 @@ void IPhreeqc::fpunchf_end_row(const char *format)
this->EndRow();
}
bool IPhreeqc::get_sel_out_file_on(int n)const
{
// if not found in list SelectedOutputFileOn is false
std::map< int, bool >::const_iterator ci = this->SelectedOutputFileOnMap.find(n);
if (ci != this->SelectedOutputFileOnMap.end())
{
return (*ci).second;
}
return false;
}
bool IPhreeqc::punch_open(const char *file_name, std::ios_base::openmode mode, int n_user)
{
if (this->PhreeqcPtr->SelectedOutput_map[n_user].Get_have_punch_name() &&
@ -1662,7 +1690,7 @@ bool IPhreeqc::punch_open(const char *file_name, std::ios_base::openmode mode, i
{
this->SelectedOutputFileNameMap[n_user] = this->sel_file_name(n_user);
}
if (this->SelectedOutputFileOn)
if (this->get_sel_out_file_on(n_user))
{
ASSERT(!this->SelectedOutputFileNameMap[n_user].empty());
this->PhreeqcPtr->SelectedOutput_map[n_user].Set_file_name(this->SelectedOutputFileNameMap[n_user]);

File diff suppressed because it is too large Load Diff

View File

@ -47,9 +47,9 @@ class IPQ_DLL_EXPORT IPhreeqc : public PHRQ_io
public:
/**
* Constructor.
* \anchor IPhreeqc_cpp
* @anchor IPhreeqc_cpp
* @par Example:
* \include IPhreeqc.cpp
* @include IPhreeqc.cpp
*/
IPhreeqc(void);
@ -88,14 +88,14 @@ public:
size_t AddWarning(const char* warning_msg);
/**
* Clears the accumulated input buffer. Input buffer is accumulated from calls to \ref AccumulateLine.
* Clears the accumulated input buffer. Input buffer is accumulated from calls to @ref AccumulateLine.
* @see AccumulateLine, GetAccumulatedLines, OutputAccumulatedLines, RunAccumulated
*/
void ClearAccumulatedLines(void);
/**
* Retrieve the accumulated input string. The accumulated input string can be run
* with \ref RunAccumulated.
* with @ref RunAccumulated.
* @return The accumulated input string.
* @see AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated
*/
@ -126,7 +126,7 @@ public:
/**
* Retrieves the name of the dump file. This file name is used if not specified within <B>DUMP</B> input.
* The default value is <B><I>dump.id.out</I></B>, where id is obtained from \ref GetId.
* The default value is <B><I>dump.id.out</I></B>, where id is obtained from @ref GetId.
* @return filename The name of the file to write <B>DUMP</B> output to.
* @see GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileName, SetDumpFileOn, SetDumpStringOn
*/
@ -134,7 +134,7 @@ public:
/**
* Retrieves the current value of the dump file switch.
* @retval true Output is written to the <B>DUMP</B> (<B><I>dump.id.out</I></B> if unspecified, where id is obtained from \ref GetId) file.
* @retval true Output is written to the <B>DUMP</B> (<B><I>dump.id.out</I></B> if unspecified, where id is obtained from @ref GetId) file.
* @retval false No output is written.
* @see GetDumpStringLine, GetDumpStringLineCount, GetDumpStringOn, GetDumpString, SetDumpFileOn, SetDumpStringOn
*/
@ -144,7 +144,7 @@ public:
* Retrieves the string buffer containing <b>DUMP</b> output.
* @return A null terminated string containing <b>DUMP</b> output.
* @pre
* \ref SetDumpStringOn must have been set to true in order to receive <b>DUMP</b> output.
* @ref SetDumpStringOn must have been set to true in order to receive <b>DUMP</b> output.
* @see GetDumpStringLine, GetDumpFileOn, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
*/
const char* GetDumpString(void)const;
@ -154,7 +154,7 @@ public:
* @param n The zero-based index of the line to retrieve.
* @return A null terminated string containing the given line.
* Returns an empty string if n is out of range.
* @pre \ref SetDumpStringOn must have been set to true.
* @pre @ref SetDumpStringOn must have been set to true.
* @see GetDumpFileOn, GetDumpString, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
*/
const char* GetDumpStringLine(int n);
@ -162,7 +162,7 @@ public:
/**
* Retrieves the number of lines in the current dump string buffer.
* @return The number of lines.
* @pre \ref SetDumpStringOn must have been set to true.
* @pre @ref SetDumpStringOn must have been set to true.
* @see GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
*/
int GetDumpStringLineCount(void)const;
@ -176,7 +176,7 @@ public:
bool GetDumpStringOn(void)const;
/**
* Retrieves the name of the error file. The default value is <B><I>phreeqc.id.err</I></B>, where id is obtained from \ref GetId.
* Retrieves the name of the error file. The default value is <B><I>phreeqc.id.err</I></B>, where id is obtained from @ref GetId.
* @return filename The name of the file to write to.
* @see GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileName, SetErrorFileOn, SetErrorStringOn
*/
@ -184,14 +184,14 @@ public:
/**
* Retrieves the current value of the error file switch.
* @retval true Errors are written to the <B><I>phreeqc.id.err</I></B> (where id is obtained from \ref GetId) file.
* @retval true Errors are written to the <B><I>phreeqc.id.err</I></B> (where id is obtained from @ref GetId) file.
* @retval false No errors are written.
* @see SetErrorFileOn
*/
bool GetErrorFileOn(void)const;
/**
* Retrieves the error messages from the last call to \ref RunAccumulated, \ref RunFile, \ref RunString, \ref LoadDatabase, or \ref LoadDatabaseString.
* Retrieves the error messages from the last call to @ref RunAccumulated, @ref RunFile, @ref RunString, @ref LoadDatabase, or @ref LoadDatabaseString.
* @return A null terminated string containing error messages.
* @see GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString, SetErrorFileOn
*/
@ -228,7 +228,7 @@ public:
int GetId(void)const;
/**
* Retrieves the name of the log file. The default value is <B><I>phreeqc.id.log</I></B>, where id is obtained from \ref GetId.
* Retrieves the name of the log file. The default value is <B><I>phreeqc.id.log</I></B>, where id is obtained from @ref GetId.
* @return filename The name of the file to write to.
* @see GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileName, SetLogFileOn, SetLogStringOn
*/
@ -236,7 +236,7 @@ public:
/**
* Retrieves the current value of the log file switch.
* @retval true Log messages are written to the <B><I>phreeqc.id.log</I></B> (where id is obtained from \ref GetId) file.
* @retval true Log messages are written to the <B><I>phreeqc.id.log</I></B> (where id is obtained from @ref GetId) file.
* @retval false No log messages are written.
* @remarks
* Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
@ -248,7 +248,7 @@ public:
* Retrieves the string buffer containing phreeqc log output.
* @return A null terminated string containing log output.
* @pre
* \ref SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
* @ref SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
* @see GetLogStringLine, GetLogFileOn, GetLogStringLineCount, GetLogStringOn, SetLogFileOn, SetLogStringOn
*/
const char* GetLogString(void)const;
@ -258,7 +258,7 @@ public:
* @param n The zero-based index of the line to retrieve.
* @return A null terminated string containing the given line.
* Returns an empty string if n is out of range.
* @pre \ref SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
* @pre @ref SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
* @see GetLogFileOn, GetLogString, GetLogStringLineCount, GetLogStringOn, SetLogFileOn, SetLogStringOn
*/
const char* GetLogStringLine(int n)const;
@ -266,7 +266,7 @@ public:
/**
* Retrieves the number of lines in the current log string buffer.
* @return The number of lines.
* @pre \ref SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
* @pre @ref SetLogStringOn must have been set to true and enabled through the use of the KNOBS -logfile option in order to receive any log messages.
* @see GetLogFileOn, GetLogString, GetLogStringLine, GetLogStringOn, SetLogFileOn, SetLogStringOn
*/
int GetLogStringLineCount(void)const;
@ -288,7 +288,7 @@ public:
int GetNthSelectedOutputUserNumber(int n)const;
/**
* Retrieves the name of the output file. The default value is <B><I>phreeqc.id.out</I></B>, where id is obtained from \ref GetId.
* Retrieves the name of the output file. The default value is <B><I>phreeqc.id.out</I></B>, where id is obtained from @ref GetId.
* @return filename The name of the file to write phreeqc output to.
* @see GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileName, SetOutputFileOn, SetOutputStringOn
*/
@ -296,7 +296,7 @@ public:
/**
* Retrieves the current value of the output file switch.
* @retval true Output is written to the <B><I>phreeqc.id.out</I></B> (where id is obtained from \ref GetId) file.
* @retval true Output is written to the <B><I>phreeqc.id.out</I></B> (where id is obtained from @ref GetId) file.
* @retval false No output is written.
* @see GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileName, SetOutputFileOn, SetOutputStringOn
*/
@ -306,7 +306,7 @@ public:
* Retrieves the string buffer containing phreeqc output.
* @return A null terminated string containing phreeqc output.
* @pre
* \ref SetOutputStringOn must have been set to true in order to receive output.
* @ref SetOutputStringOn must have been set to true in order to receive output.
* @see GetOutputStringLine, GetOutputFileOn, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
*/
const char* GetOutputString(void)const;
@ -316,7 +316,7 @@ public:
* @param n The zero-based index of the line to retrieve.
* @return A null terminated string containing the given line.
* Returns an empty string if n is out of range.
* @pre \ref SetOutputStringOn must have been set to true.
* @pre @ref SetOutputStringOn must have been set to true.
* @see GetOutputFileOn, GetOutputString, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
*/
const char* GetOutputStringLine(int n)const;
@ -324,7 +324,7 @@ public:
/**
* Retrieves the number of lines in the current output string buffer.
* @return The number of lines.
* @pre \ref SetOutputStringOn must have been set to true.
* @pre @ref SetOutputStringOn must have been set to true.
* @see GetOutputFileOn, GetOutputString, GetOutputStringLine, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn
*/
int GetOutputStringLineCount(void)const;
@ -353,7 +353,7 @@ public:
/**
* Retrieves the name of the selected output file. This file name is used if not specified within <B>SELECTED_OUTPUT</B> input.
* The default value is <B><I>selected_n.id.out</I></B>, where id is obtained from \ref GetId.
* The default value is <B><I>selected_n.id.out</I></B>, where id is obtained from @ref GetId.
* @return filename The name of the file to write to.
* @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileName, SetSelectedOutputFileOn, SetSelectedOutputStringOn
*/
@ -361,7 +361,7 @@ public:
/**
* Retrieves the selected-output file switch.
* @retval true Output is written to the selected-output (<B><I>selected_n.id.out</I></B> if unspecified, where id is obtained from \ref GetId) file.
* @retval true Output is written to the selected-output (<B><I>selected_n.id.out</I></B> if unspecified, where id is obtained from @ref GetId) file.
* @retval false No output is written.
* @see GetSelectedOutputValue, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, SetSelectedOutputFileOn
*/
@ -375,10 +375,10 @@ public:
int GetSelectedOutputRowCount(void)const;
/**
* Retrieves the string buffer containing <b>SELECTED_OUTPUT</b>.
* Retrieves the string buffer containing <b>SELECTED_OUTPUT</b> for the currently selected user number(see @ref SetCurrentSelectedOutputUserNumber).
* @return A null terminated string containing <b>SELECTED_OUTPUT</b>.
* @pre
* \ref SetSelectedOutputStringOn must have been set to true in order to receive <b>SELECTED_OUTPUT</b>.
* @ref SetSelectedOutputStringOn must have been set to true in order to receive <b>SELECTED_OUTPUT</b>.
* @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputStringLine, GetSelectedOutputFileOn, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, GetSelectedOutputString, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
*/
const char* GetSelectedOutputString(void)const;
@ -388,7 +388,7 @@ public:
* @param n The zero-based index of the line to retrieve.
* @return A null terminated string containing the given line.
* Returns an empty string if n is out of range.
* @pre \ref SetSelectedOutputStringOn must have been set to true.
* @pre @ref SetSelectedOutputStringOn must have been set to true.
* @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
*/
const char* GetSelectedOutputStringLine(int n);
@ -396,7 +396,7 @@ public:
/**
* Retrieves the number of lines in the current selected output string buffer.
* @return The number of lines.
* @pre \ref SetSelectedOutputStringOn must have been set to true.
* @pre @ref SetSelectedOutputStringOn must have been set to true.
* @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn
*/
int GetSelectedOutputStringLineCount(void)const;
@ -410,10 +410,10 @@ public:
bool GetSelectedOutputStringOn(void)const;
/**
* Returns the \c VAR associated with the specified row and column.
* Returns the @c VAR associated with the specified row and column.
* @param row The row index.
* @param col The column index.
* @param pVAR Pointer to the \c VAR to receive the requested data.
* @param pVAR Pointer to the @c VAR to receive the requested data.
* @retval VR_OK Success.
* @retval VR_INVALIDROW The given row is out of range.
* @retval VR_INVALIDCOL The given column is out of range.
@ -567,9 +567,9 @@ public:
* Returns the associated data with the specified row and column.
* @param row The row index.
* @param col The column index.
* @param vtype Receives the variable type. See \ref VAR_TYPE.
* @param dvalue Receives the numeric value when (VTYPE=\ref TT_DOUBLE) or (VTYPE=\ref TT_LONG).
* @param svalue Receives the string variable when (VTYPE=\ref TT_STRING). When (VTYPE=\ref TT_DOUBLE) or (VTYPE=\ref TT_LONG) this variable is filled with a string equivalent of DVALUE.
* @param vtype Receives the variable type. See @ref VAR_TYPE.
* @param dvalue Receives the numeric value when (VTYPE=@ref TT_DOUBLE) or (VTYPE=@ref TT_LONG).
* @param svalue Receives the string variable when (VTYPE=@ref TT_STRING). When (VTYPE=@ref TT_DOUBLE) or (VTYPE=@ref TT_LONG) this variable is filled with a string equivalent of DVALUE.
* @param svalue_length The length of the svalue buffer.
* @retval IPQ_OK Success.
* @retval IPQ_INVALIDROW The given row is out of range.
@ -580,12 +580,12 @@ public:
* @remarks
* Row 0 contains the column headings to the selected_ouput.
* @par Examples:
* See \ref GetSelectedOutputValue.
* See @ref GetSelectedOutputValue.
*/
VRESULT GetSelectedOutputValue2(int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length);
/**
* Retrieves the warning messages from the last call to \ref RunAccumulated, \ref RunFile, \ref RunString, \ref LoadDatabase, or \ref LoadDatabaseString.
* Retrieves the warning messages from the last call to @ref RunAccumulated, @ref RunFile, @ref RunString, @ref LoadDatabase, or @ref LoadDatabaseString.
* @return A null terminated string containing warning messages.
* @see GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
*/
@ -636,13 +636,13 @@ public:
int LoadDatabaseString(const char* input);
/**
* Output the accumulated input buffer to stdout. The input buffer can be run with a call to \ref RunAccumulated.
* Output the accumulated input buffer to stdout. The input buffer can be run with a call to @ref RunAccumulated.
* @see AccumulateLine, ClearAccumulatedLines, RunAccumulated
*/
void OutputAccumulatedLines(void);
/**
* Output the error messages normally stored in the <B><I>phreeqc.id.err</I></B> (where id is obtained from \ref GetId)
* Output the error messages normally stored in the <B><I>phreeqc.id.err</I></B> (where id is obtained from @ref GetId)
* file to stdout.
* @see GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, SetErrorFileOn
*/
@ -655,13 +655,13 @@ public:
void OutputWarningString(void);
/**
* Runs the input buffer as defined by calls to \ref AccumulateLine.
* Runs the input buffer as defined by calls to @ref AccumulateLine.
* @return The number of errors encountered.
* @see AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunFile, RunString
* @remarks
* The accumulated input is cleared at the next call to \ref AccumulateLine.
* The accumulated input is cleared at the next call to @ref AccumulateLine.
* @pre
* \ref LoadDatabase/\ref LoadDatabaseString must have been called and returned 0 (zero) errors.
* @ref LoadDatabase/@ref LoadDatabaseString must have been called and returned 0 (zero) errors.
*/
int RunAccumulated(void);
@ -671,7 +671,7 @@ public:
* @return The number of errors encountered during the run.
* @see RunAccumulated, RunString
* @pre
* \ref LoadDatabase/\ref LoadDatabaseString must have been called and returned 0 (zero) errors.
* @ref LoadDatabase/@ref LoadDatabaseString must have been called and returned 0 (zero) errors.
*/
int RunFile(const char* filename);
@ -681,7 +681,7 @@ public:
* @return The number of errors encountered during the run.
* @see RunAccumulated, RunFile
* @pre
* \ref LoadDatabase/\ref LoadDatabaseString must have been called and returned 0 (zero) errors.
* @ref LoadDatabase/@ref LoadDatabaseString must have been called and returned 0 (zero) errors.
*/
int RunString(const char* input);
@ -718,7 +718,7 @@ public:
/**
* Sets the name of the dump file. This file name is used if not specified within <B>DUMP</B> input.
* The default value is <B><I>dump.id.out</I></B>, where id is obtained from \ref GetId.
* The default value is <B><I>dump.id.out</I></B>, where id is obtained from @ref GetId.
* @param filename The name of the file to write <B>DUMP</B> output to.
* @see GetDumpFileName, GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpStringOn
*/
@ -726,7 +726,7 @@ public:
/**
* Sets the dump file switch on or off. This switch controls whether or not phreeqc writes to the <B>DUMP</B> (<B><I>dump.id.out</I></B>
* if unspecified, where id is obtained from \ref GetId) file.
* if unspecified, where id is obtained from @ref GetId) file.
* The initial setting is false.
* @param bValue If true, turns on output to the <B>DUMP</B> file;
* if false, turns off output to the <B>DUMP</B> file.
@ -744,7 +744,7 @@ public:
void SetDumpStringOn(bool bValue);
/**
* Sets the name of the error file. The default value is <B><I>phreeqc.id.err</I></B>, where id is obtained from \ref GetId.
* Sets the name of the error file. The default value is <B><I>phreeqc.id.err</I></B>, where id is obtained from @ref GetId.
* @param filename The name of the file to write error output to.
* @see GetErrorFileName, GetErrorFileOn, GetErrorString, GetErrorStringOn, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn, SetErrorStringOn
*/
@ -752,7 +752,7 @@ public:
/**
* Sets the error file switch on or off. This switch controls whether or not
* error messages are written to the <B><I>phreeqc.id.err</I></B> (where id is obtained from \ref GetId) file.
* error messages are written to the <B><I>phreeqc.id.err</I></B> (where id is obtained from @ref GetId) file.
* The initial setting is false.
* @param bValue If true, writes errors to the error file; if false, no errors are written to the error file.
* @see GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString
@ -768,7 +768,7 @@ public:
void SetErrorStringOn(bool bValue);
/**
* Sets the name of the log file. The default value is <B><I>phreeqc.id.log</I></B>, where id is obtained from \ref GetId.
* Sets the name of the log file. The default value is <B><I>phreeqc.id.log</I></B>, where id is obtained from @ref GetId.
* @param filename The name of the file to write log output to.
* @see GetLogFileName, GetLogFileOn, GetLogString, GetLogStringOn, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, SetLogStringOn
*/
@ -776,7 +776,7 @@ public:
/**
* Sets the log file switch on or off. This switch controls whether or not phreeqc
* writes log messages to the <B><I>phreeqc.id.log</I></B> (where id is obtained from \ref GetId) file. The initial setting is false.
* writes log messages to the <B><I>phreeqc.id.log</I></B> (where id is obtained from @ref GetId) file. The initial setting is false.
* @param bValue If true, turns on output to the log file; if false, no log messages are written to the log file.
* @remarks
* Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
@ -793,7 +793,7 @@ public:
void SetLogStringOn(bool bValue);
/**
* Sets the name of the output file. The default value is <B><I>phreeqc.id.out</I></B>, where id is obtained from \ref GetId.
* Sets the name of the output file. The default value is <B><I>phreeqc.id.out</I></B>, where id is obtained from @ref GetId.
* @param filename The name of the file to write phreeqc output to.
* @see GetOutputFileName, GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, SetOutputStringOn
*/
@ -801,7 +801,7 @@ public:
/**
* Sets the output file switch on or off. This switch controls whether or not phreeqc
* writes to the <B><I>phreeqc.id.out</I></B> file (where id is obtained from \ref GetId). This is the output that is normally generated
* writes to the <B><I>phreeqc.id.out</I></B> file (where id is obtained from @ref GetId). This is the output that is normally generated
* when phreeqc is run. The initial setting is false.
* @param bValue If true, writes output to the output file; if false, no output is written to the output file.
* @see GetOutputFileOn
@ -818,7 +818,7 @@ public:
/**
* Sets the name of the selected output file. This file name is used if not specified within <B>SELECTED_OUTPUT</B> input.
* The default value is <B><I>selected_n.id.out</I></B>, where id is obtained from \ref GetId.
* The default value is <B><I>selected_n.id.out</I></B>, where id is obtained from @ref GetId.
* @param filename The name of the file to write <B>SELECTED_OUTPUT</B> output to.
* @see GetSelectedOutputFileName, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetSelectedOutputStringOn
*/
@ -826,7 +826,7 @@ public:
/**
* Sets the selected-output file switch on or off. This switch controls whether or not phreeqc writes output to
* the <B>SELECTED_OUTPUT</B> (<B><I>selected_n.id.out</I></B> if unspecified, where id is obtained from \ref GetId) file.
* the <B>SELECTED_OUTPUT</B> (<B><I>selected_n.id.out</I></B> if unspecified, where id is obtained from @ref GetId) file.
* The initial setting is false.
* @param bValue If true, writes output to the selected-output file; if false, no output is written to the selected-output file.
* @see GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue
@ -873,6 +873,7 @@ protected:
void update_errors(void);
bool get_sel_out_file_on(int n)const;
std::string sel_file_name(int n_user);
protected:
@ -884,7 +885,8 @@ protected:
bool DatabaseLoaded;
bool ClearAccumulated;
bool UpdateComponents;
bool SelectedOutputFileOn;
std::map< int, bool > SelectedOutputFileOnMap;
bool OutputFileOn;
bool LogFileOn;

View File

@ -112,7 +112,13 @@ GetCurrentSelectedOutputUserNumber(int id)
IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr)
{
return IPhreeqcPtr->GetCurrentSelectedOutputUserNumber();
int n = IPhreeqcPtr->GetCurrentSelectedOutputUserNumber();
switch (n)
{
case VR_INVALIDARG:
return IPQ_INVALIDARG;
}
return n;
}
return IPQ_BADINSTANCE;
}

View File

@ -3440,6 +3440,11 @@ void TestIPhreeqc::TestRunFileMultiPunchOn(void)
IPhreeqc obj;
CPPUNIT_ASSERT_EQUAL(0, obj.LoadDatabase("../database/phreeqc.dat"));
obj.SetCurrentSelectedOutputUserNumber(1);
obj.SetSelectedOutputFileOn(true);
obj.SetCurrentSelectedOutputUserNumber(2);
obj.SetSelectedOutputFileOn(true);
obj.SetCurrentSelectedOutputUserNumber(3);
obj.SetSelectedOutputFileOn(true);
CPPUNIT_ASSERT_EQUAL(0, obj.RunFile("multi_punch"));
@ -3491,8 +3496,16 @@ void TestIPhreeqc::TestRunFileMultiPunchSet(void)
IPhreeqc obj;
CPPUNIT_ASSERT_EQUAL(0, obj.LoadDatabase("../database/phreeqc.dat"));
obj.SetCurrentSelectedOutputUserNumber(1);
obj.SetSelectedOutputFileOn(true);
obj.SetCurrentSelectedOutputUserNumber(2);
obj.SetSelectedOutputFileOn(true);
obj.SetCurrentSelectedOutputUserNumber(3);
obj.SetSelectedOutputFileOn(true);
obj.SetSelectedOutputFileName(called.GetName().c_str());
CPPUNIT_ASSERT_EQUAL(0, obj.RunFile("multi_punch"));
CPPUNIT_ASSERT( called.VerifyMissing() );
@ -3519,7 +3532,14 @@ void TestIPhreeqc::TestRunFileMultiPunchNoSet(void)
CPPUNIT_ASSERT( unset3.RemoveExisting() );
CPPUNIT_ASSERT_EQUAL(0, obj.LoadDatabase("../database/phreeqc.dat"));
obj.SetCurrentSelectedOutputUserNumber(1);
obj.SetSelectedOutputFileOn(true);
obj.SetCurrentSelectedOutputUserNumber(2);
obj.SetSelectedOutputFileOn(true);
obj.SetCurrentSelectedOutputUserNumber(3);
obj.SetSelectedOutputFileOn(true);
obj.SetSelectedOutputFileName(set.GetName().c_str());
CPPUNIT_ASSERT_EQUAL(0, obj.RunFile("multi_punch_no_set"));
@ -3930,7 +3950,7 @@ void TestIPhreeqc::TestMultiPunchCSelectedOutput(void)
CPPUNIT_ASSERT_EQUAL(VR_INVALIDCOL, obj.GetSelectedOutputValue( 0, c, &var)); CPPUNIT_ASSERT_EQUAL(TT_ERROR, var.type); CPPUNIT_ASSERT_EQUAL(VR_INVALIDCOL, var.vresult);
CPPUNIT_ASSERT_EQUAL(VR_INVALIDARG, obj.SetCurrentSelectedOutputUserNumber(-1));
CPPUNIT_ASSERT_EQUAL(VR_INVALIDARG, obj.SetCurrentSelectedOutputUserNumber(0));
CPPUNIT_ASSERT_EQUAL(VR_OK, obj.SetCurrentSelectedOutputUserNumber(0));
}
void TestIPhreeqc::TestGetSelectedOutputCount(void)
@ -3990,6 +4010,12 @@ void TestIPhreeqc::TestGetCurrentSelectedOutputUserNumber(void)
// edge cases
CPPUNIT_ASSERT_EQUAL(VR_INVALIDARG, obj.SetCurrentSelectedOutputUserNumber(-1));
CPPUNIT_ASSERT_EQUAL(3, obj.GetCurrentSelectedOutputUserNumber());
CPPUNIT_ASSERT_EQUAL(VR_INVALIDARG, obj.SetCurrentSelectedOutputUserNumber(0));
CPPUNIT_ASSERT_EQUAL(3, obj.GetCurrentSelectedOutputUserNumber());
CPPUNIT_ASSERT_EQUAL(VR_OK, obj.SetCurrentSelectedOutputUserNumber(0));
CPPUNIT_ASSERT_EQUAL(0, obj.GetCurrentSelectedOutputUserNumber());
// unload database
CPPUNIT_ASSERT_EQUAL(0, obj.LoadDatabase("../database/phreeqc.dat"));
CPPUNIT_ASSERT_EQUAL(1, obj.GetCurrentSelectedOutputUserNumber());
CPPUNIT_ASSERT_EQUAL(0, obj.GetSelectedOutputCount());
}

View File

@ -4287,7 +4287,8 @@ void TestIPhreeqcLib::TestMultiPunchCSelectedOutput(void)
CPPUNIT_ASSERT_EQUAL(IPQ_INVALIDCOL, ::GetSelectedOutputValue(id, 0, c, &var)); CPPUNIT_ASSERT_EQUAL(TT_ERROR, var.type); CPPUNIT_ASSERT_EQUAL(VR_INVALIDCOL, var.vresult);
CPPUNIT_ASSERT_EQUAL(IPQ_INVALIDARG, ::SetCurrentSelectedOutputUserNumber(id, -1));
CPPUNIT_ASSERT_EQUAL(IPQ_INVALIDARG, ::SetCurrentSelectedOutputUserNumber(id, 0));
CPPUNIT_ASSERT_EQUAL(IPQ_OK, ::SetCurrentSelectedOutputUserNumber(id, 0));
CPPUNIT_ASSERT_EQUAL(0, ::GetCurrentSelectedOutputUserNumber(id));
}
void TestIPhreeqcLib::TestGetSelectedOutputCount(void)
@ -4348,6 +4349,10 @@ void TestIPhreeqcLib::TestGetCurrentSelectedOutputUserNumber(void)
// edge cases
CPPUNIT_ASSERT_EQUAL(IPQ_INVALIDARG, ::SetCurrentSelectedOutputUserNumber(id, -1));
CPPUNIT_ASSERT_EQUAL(3, ::GetCurrentSelectedOutputUserNumber(id));
CPPUNIT_ASSERT_EQUAL(IPQ_INVALIDARG, ::SetCurrentSelectedOutputUserNumber(id, 0));
CPPUNIT_ASSERT_EQUAL(3, ::GetCurrentSelectedOutputUserNumber(id));
CPPUNIT_ASSERT_EQUAL(IPQ_OK, ::SetCurrentSelectedOutputUserNumber(id, 0));
CPPUNIT_ASSERT_EQUAL(0, ::GetCurrentSelectedOutputUserNumber(id));
// unload database
CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase(id, "../database/phreeqc.dat"));
CPPUNIT_ASSERT_EQUAL(1, ::GetCurrentSelectedOutputUserNumber(id));
}