diff --git a/IPhreeqc.cpp b/IPhreeqc.cpp index 6c14abb4..bd272336 100644 --- a/IPhreeqc.cpp +++ b/IPhreeqc.cpp @@ -169,6 +169,11 @@ size_t IPhreeqc::GetComponentCount(void) return this->Components.size(); } +int IPhreeqc::GetCurrentSelectedOutputUserNumber(void)const +{ + return this->CurrentSelectedOutputUserNumber; +} + const char* IPhreeqc::GetDumpFileName(void)const { return this->DumpFileName.c_str(); @@ -295,6 +300,21 @@ bool IPhreeqc::GetLogStringOn(void)const return this->LogStringOn; } +int IPhreeqc::GetNthSelectedOutputUserNumber(int n)const +{ + int nth = VR_INVALIDARG; + std::map< int, SelectedOutput >::const_iterator ci = this->PhreeqcPtr->SelectedOutput_map.begin(); + for (int i = 0; ci != this->PhreeqcPtr->SelectedOutput_map.end(); ++ci, ++i) + { + if (i == n) + { + nth = (*ci).first; + break; + } + } + return nth; +} + const char* IPhreeqc::GetOutputFileName(void)const { return this->OutputFileName.c_str(); @@ -345,6 +365,11 @@ int IPhreeqc::GetSelectedOutputColumnCount(void)const return 0; } +int IPhreeqc::GetSelectedOutputCount(void)const +{ + return this->PhreeqcPtr->SelectedOutput_map.size(); +} + const char* IPhreeqc::GetSelectedOutputFileName(void)const { static const char empty[] = ""; @@ -784,9 +809,14 @@ void IPhreeqc::SetBasicFortranCallback(double (*fcn)(double *x1, double *x2, cha this->PhreeqcPtr->register_fortran_basic_callback(fcn); } -void IPhreeqc::SetCurrentSelectedOutputUserNumber(int n) +VRESULT IPhreeqc::SetCurrentSelectedOutputUserNumber(int n) { - this->CurrentSelectedOutputUserNumber = n; + if (this->PhreeqcPtr->SelectedOutput_map.find(n) != this->PhreeqcPtr->SelectedOutput_map.end()) + { + this->CurrentSelectedOutputUserNumber = n; + return VR_OK; + } + return VR_INVALIDARG; } void IPhreeqc::SetDumpFileName(const char *filename) diff --git a/IPhreeqc.h b/IPhreeqc.h index 3720f378..708945fb 100644 --- a/IPhreeqc.h +++ b/IPhreeqc.h @@ -69,7 +69,7 @@ extern "C" { * Internally used to create an error condition. * @param id The instance id returned from \ref CreateIPhreeqc. * @param error_msg The error message to display. - * @returns The current error count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). + * @return The current error count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). * @see GetErrorString, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString * @par Fortran90 Interface: * @htmlonly @@ -92,7 +92,7 @@ extern "C" { * Internally used to create a warning condition. * @param id The instance id returned from \ref CreateIPhreeqc. * @param warn_msg The warning message to display. - * @returns The current warning count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). + * @return The current warning count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). * @see GetWarningString, GetWarningStringLine, GetWarningStringLineCount, OutputWarningString * @par Fortran90 Interface: * @htmlonly @@ -242,6 +242,25 @@ extern "C" { */ IPQ_DLL_EXPORT int GetComponentCount(int id); +/** + * Sets the currently active SELECTED_OUTPUT user number for use in subsequent calls to GetSelectedOutputXXX routines. + * The initial setting after calling \ref CreateIPhreeqc is 1. + * @param id The instance id returned from \ref CreateIPhreeqc. + * @return The current active SELECTED_OUTPUT user number. + * @see GetNthSelectedOutputUserNumber, GetSelectedOutputCount, SetCurrentSelectedOutputUserNumber + * @par Fortran90 Interface: + * @htmlonly + * + *
+ *  FUNCTION GetCurrentSelectedOutputUserNumber(ID)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    INTEGER(KIND=4)               :: GetCurrentSelectedOutputUserNumber
+ *  END FUNCTION GetCurrentSelectedOutputUserNumber
+ *  
+ *
+ * @endhtmlonly + */ + IPQ_DLL_EXPORT int GetCurrentSelectedOutputUserNumber(int id); /** * Retrieves the name of the dump file. This file name is used if not specified within DUMP input. @@ -493,7 +512,6 @@ extern "C" { */ IPQ_DLL_EXPORT int GetErrorStringOn(int id); - /** * Retrieves the name of the log file. The default name is phreeqc.id.log. * @param id The instance id returned from \ref CreateIPhreeqc. @@ -624,6 +642,27 @@ extern "C" { IPQ_DLL_EXPORT int GetLogStringOn(int id); +/** + * Retrieves the nth user number of the currently defined SELECTED_OUTPUT keyword blocks. + * @param id The instance id returned from \ref CreateIPhreeqc. + * @return The nth defined user number; a negative value indicates an error occured. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputCount, SetCurrentSelectedOutputUserNumber + * @par Fortran90 Interface: + * @htmlonly + * (Note: N is one-based for the Fortran interface.) + * + *
+ *  FUNCTION GetNthSelectedOutputUserNumber(ID)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    INTEGER(KIND=4),  INTENT(IN)  :: N
+ *    INTEGER(KIND=4)               :: GetNthSelectedOutputUserNumber
+ *  END FUNCTION GetNthSelectedOutputUserNumber
+ *  
+ *
+ * @endhtmlonly + */ + IPQ_DLL_EXPORT int GetNthSelectedOutputUserNumber(int id, int n); + /** * Retrieves the name of the output file. The default name is phreeqc.id.out. * @param id The instance id returned from \ref CreateIPhreeqc. @@ -768,6 +807,25 @@ extern "C" { */ IPQ_DLL_EXPORT int GetSelectedOutputColumnCount(int id); +/** + * Retrieves the count of SELECTED_OUTPUT blocks that are currently defined. + * @param id The instance id returned from \ref CreateIPhreeqc. + * @return The number of SELECTED_OUTPUT blocks. + * @see GetCurrentSelectedOutputUserNumber, GetNthSelectedOutputUserNumber, SetCurrentSelectedOutputUserNumber + * @par Fortran90 Interface: + * @htmlonly + * + *
+ *  FUNCTION GetSelectedOutputCount(ID)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    INTEGER(KIND=4)               :: GetSelectedOutputCount
+ *  END FUNCTION GetSelectedOutputCount
+ *  
+ *
+ * @endhtmlonly + */ + IPQ_DLL_EXPORT int GetSelectedOutputCount(int id); + /** * Retrieves the name of the selected output file. This file name is used if not specified within SELECTED_OUTPUT input. @@ -1573,6 +1631,30 @@ Headings IPQ_DLL_EXPORT IPQ_RESULT SetBasicFortranCallback(int id, double (*fcn)(double *x1, double *x2, char *str, int l)); +/** + * Sets the currently active SELECTED_OUTPUT user number for use in subsequent calls to GetSelectedOutputXXX routines. + * The initial setting after calling \ref CreateIPhreeqc is 1. + * @param id The instance id returned from \ref CreateIPhreeqc. + * @param n The user number as specified in the SELECTED_OUTPUT block. + * @retval IPQ_OK Success. + * @retval IPQ_BADINSTANCE The given id is invalid. + * @retval IPQ_INVALIDARG The given user number is invalid. + * @see GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue + * @par Fortran90 Interface: + * @htmlonly + * + *
+ *  FUNCTION SetCurrentSelectedOutputUserNumber(ID,N)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    INTEGER(KIND=4),  INTENT(IN)  :: N
+ *    INTEGER(KIND=4)               :: SetCurrentSelectedOutputUserNumber
+ *  END FUNCTION SetCurrentSelectedOutputUserNumber
+ *  
+ *
+ * @endhtmlonly + */ + IPQ_DLL_EXPORT IPQ_RESULT SetCurrentSelectedOutputUserNumber(int id, int n); + /** * Sets the name of the dump file. This file name is used if not specified within DUMP input. * The default value is dump.id.out. diff --git a/IPhreeqc.hpp b/IPhreeqc.hpp index da0f48c1..fdfd894d 100644 --- a/IPhreeqc.hpp +++ b/IPhreeqc.hpp @@ -47,9 +47,9 @@ class IPQ_DLL_EXPORT IPhreeqc : public PHRQ_io public: /** * Constructor. - * \anchor IPhreeqc_cpp - * @par Example: - * \include IPhreeqc.cpp + * \anchor IPhreeqc_cpp + * @par Example: + * \include IPhreeqc.cpp */ IPhreeqc(void); @@ -65,7 +65,7 @@ public: * @param line The line(s) to add for input to phreeqc. * @retval VR_OK Success * @retval VR_OUTOFMEMORY Out of memory - * @see ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated + * @see ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated */ VRESULT AccumulateLine(const char *line); @@ -73,8 +73,8 @@ public: * Appends the given error message and increments the error count. * Internally used to create an error condition. * @param error_msg The error message to display. - * @returns The current error count. - * @see GetErrorString, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString + * @return The current error count. + * @see GetErrorString, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString */ size_t AddError(const char* error_msg); @@ -82,8 +82,8 @@ public: * Appends the given warning message and increments the warning count. * Internally used to create a warning condition. * @param warning_msg The warning message to display. - * @returns The current warning count. - * @see GetWarningString, GetWarningStringLine, GetWarningStringLineCount, OutputWarningString + * @return The current warning count. + * @see GetWarningString, GetWarningStringLine, GetWarningStringLineCount, OutputWarningString */ size_t AddWarning(const char* warning_msg); @@ -96,7 +96,7 @@ public: /** * Retrieve the accumulated input string. The accumulated input string can be run * with \ref RunAccumulated. - * @returns The accumulated input string. + * @return The accumulated input string. * @see AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated */ const std::string& GetAccumulatedLines(void); @@ -117,6 +117,12 @@ public: */ size_t GetComponentCount(void); + /** + * Retrieves the currently active SELECTED_OUTPUT user number. + * @return The current active SELECTED_OUTPUT user number. + * @see GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber + */ + int GetCurrentSelectedOutputUserNumber(void)const; /** * Retrieves the name of the dump file. This file name is used if not specified within DUMP input. @@ -128,15 +134,15 @@ public: /** * Retrieves the current value of the dump file switch. - * @retval true Output is written to the DUMP (dump.id.out if unspecified, where id is obtained from \ref GetId) file. - * @retval false No output is written. + * @retval true Output is written to the DUMP (dump.id.out if unspecified, where id is obtained from \ref GetId) file. + * @retval false No output is written. * @see GetDumpStringLine, GetDumpStringLineCount, GetDumpStringOn, GetDumpString, SetDumpFileOn, SetDumpStringOn */ bool GetDumpFileOn(void)const; /** * Retrieves the string buffer containing DUMP output. - * @return A null terminated string containing DUMP output. + * @return A null terminated string containing DUMP output. * @pre * \ref SetDumpStringOn must have been set to true in order to receive DUMP output. * @see GetDumpStringLine, GetDumpFileOn, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn @@ -148,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); @@ -156,15 +162,15 @@ 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; /** * Retrieves the current value of the dump string switch. - * @retval true Output defined by the DUMP keyword is stored. - * @retval false No output is stored. + * @retval true Output defined by the DUMP keyword is stored. + * @retval false No output is stored. * @see GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, SetDumpStringOn */ bool GetDumpStringOn(void)const; @@ -178,22 +184,22 @@ public: /** * Retrieves the current value of the error file switch. - * @retval true Errors are written to the phreeqc.id.err (where id is obtained from \ref GetId) file. - * @retval false No errors are written. + * @retval true Errors are written to the phreeqc.id.err (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. - * @return A null terminated string containing error messages. + * @return A null terminated string containing error messages. * @see GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString, SetErrorFileOn */ const char* GetErrorString(void); /** * Retrieves the given error line. - * @return A null terminated string containing the given line of the error string buffer. + * @return A null terminated string containing the given line of the error string buffer. * @param n The zero-based index of the line to retrieve. * @see GetErrorStringLineCount, OutputErrorString */ @@ -201,15 +207,15 @@ public: /** * Retrieves the number of lines in the current error string buffer. - * @return The number of lines. + * @return The number of lines. * @see GetErrorStringLine, OutputErrorString */ int GetErrorStringLineCount(void)const; /** * Retrieves the current value of the error string switch. - * @retval true Error output is stored. - * @retval false No error output is stored. + * @retval true Error output is stored. + * @retval false No error output is stored. * @see GetErrorFileOn, GetErrorString, GetErrorStringLine, GetErrorStringLineCount, SetErrorFileOn, SetErrorStringOn */ bool GetErrorStringOn(void)const; @@ -217,7 +223,7 @@ public: /** * Retrieves the id of this object. Each instance receives an id which is incremented for each instance * starting with the value zero. - * @return The id. + * @return The id. */ int GetId(void)const; @@ -230,17 +236,17 @@ public: /** * Retrieves the current value of the log file switch. - * @retval true Log messages are written to the phreeqc.id.log (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. + * @retval true Log messages are written to the phreeqc.id.log (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. * @see SetLogFileOn */ bool GetLogFileOn(void)const; /** * Retrieves the string buffer containing phreeqc log output. - * @return A null terminated string containing 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. * @see GetLogStringLine, GetLogFileOn, GetLogStringLineCount, GetLogStringOn, SetLogFileOn, SetLogStringOn @@ -252,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; @@ -260,19 +266,27 @@ 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; /** * Retrieves the current value of the log string switch. - * @retval true Log output is stored. - * @retval false No log output is stored. + * @retval true Log output is stored. + * @retval false No log output is stored. * @see GetLogFileOn, GetLogString, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, SetLogStringOn */ bool GetLogStringOn(void)const; + /** + * Retrieves the nth user number of the currently defined SELECTED_OUTPUT blocks. + * @param n The zero-based index of the SELECTED_OUTPUT user number to retrieve. + * @return The nth defined user number; a negative value indicates an error occured. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputCount, SetCurrentSelectedOutputUserNumber + */ + int GetNthSelectedOutputUserNumber(int n)const; + /** * Retrieves the name of the output file. The default value is phreeqc.id.out, where id is obtained from \ref GetId. * @return filename The name of the file to write phreeqc output to. @@ -282,15 +296,15 @@ public: /** * Retrieves the current value of the output file switch. - * @retval true Output is written to the phreeqc.id.out (where id is obtained from \ref GetId) file. - * @retval false No output is written. + * @retval true Output is written to the phreeqc.id.out (where id is obtained from \ref GetId) file. + * @retval false No output is written. * @see GetOutputFileOn, GetOutputString, GetOutputStringOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileName, SetOutputFileOn, SetOutputStringOn */ bool GetOutputFileOn(void)const; /** * Retrieves the string buffer containing phreeqc output. - * @return A null terminated string 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. * @see GetOutputStringLine, GetOutputFileOn, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn @@ -302,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; @@ -310,56 +324,62 @@ 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; /** * Retrieves the current value of the output string switch. - * @retval true Phreeqc output is stored. - * @retval false No phreeqc output is stored. + * @retval true Phreeqc output is stored. + * @retval false No phreeqc output is stored. * @see GetOutputFileOn, GetOutputString, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, SetOutputStringOn */ bool GetOutputStringOn(void)const; /** * Retrieves the number of columns in the selected-output buffer. - * @return The number of columns. - * @see GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber + * @return The number of columns. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputRowCount, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber */ int GetSelectedOutputColumnCount(void)const; /** + * Retrieves the count of SELECTED_OUTPUT blocks that are currently defined. + * @return The number of SELECTED_OUTPUT blocks. + * @see GetCurrentSelectedOutputUserNumber, GetNthSelectedOutputUserNumber, SetCurrentSelectedOutputUserNumber + */ + int GetSelectedOutputCount(void)const; + /** * Retrieves the name of the selected output file. This file name is used if not specified within SELECTED_OUTPUT input. * The default value is selected.id.out, where id is obtained from \ref GetId. * @return filename The name of the file to write to. - * @see GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileName, SetSelectedOutputFileOn, SetSelectedOutputStringOn + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileName, SetSelectedOutputFileOn, SetSelectedOutputStringOn */ const char* GetSelectedOutputFileName(void)const; /** * Retrieves the selected-output file switch. - * @retval true Output is written to the selected-output (selected.id.out if unspecified, where id is obtained from \ref GetId) file. - * @retval false No output is written. + * @retval true Output is written to the selected-output (selected.id.out if unspecified, where id is obtained from \ref GetId) file. + * @retval false No output is written. * @see GetSelectedOutputValue, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, SetSelectedOutputFileOn */ bool GetSelectedOutputFileOn(void)const; /** * Retrieves the number of rows in the selected-output buffer. - * @return The number of rows. - * @see GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn + * @return The number of rows. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputValue, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn */ int GetSelectedOutputRowCount(void)const; /** * Retrieves the string buffer containing SELECTED_OUTPUT. - * @return A null terminated string containing SELECTED_OUTPUT. + * @return A null terminated string containing SELECTED_OUTPUT. * @pre * \ref SetSelectedOutputStringOn must have been set to true in order to receive SELECTED_OUTPUT. - * @see GetSelectedOutputStringLine, GetSelectedOutputFileOn, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, GetSelectedOutputString, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputStringLine, GetSelectedOutputFileOn, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, GetSelectedOutputString, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn */ const char* GetSelectedOutputString(void)const; @@ -368,23 +388,23 @@ 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. - * @see GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn + * @pre \ref SetSelectedOutputStringOn must have been set to true. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn */ const char* GetSelectedOutputStringLine(int n); /** * 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. - * @see GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn + * @pre \ref SetSelectedOutputStringOn must have been set to true. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringOn, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn, SetSelectedOutputStringOn */ int GetSelectedOutputStringLineCount(void)const; /** * Retrieves the current value of the selected output string switch. - * @retval true Output defined by the SELECTED_OUTPUT keyword is stored. - * @retval false No output is stored. + * @retval true Output defined by the SELECTED_OUTPUT keyword is stored. + * @retval false No output is stored. * @see GetSelectedOutputFileOn, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetSelectedOutputFileOn, SetSelectedOutputStringOn */ bool GetSelectedOutputStringOn(void)const; @@ -399,7 +419,7 @@ public: * @retval VR_INVALIDCOL The given column is out of range. * @retval VR_OUTOFMEMORY Memory could not be allocated. * @retval VR_BADINSTANCE The given id is invalid. - * @see GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue2, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue2, SetCurrentSelectedOutputUserNumber, SetSelectedOutputFileOn * @remarks * Row 0 contains the column headings to the selected_ouput. * @par Examples: @@ -566,22 +586,22 @@ public: /** * 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. + * @return A null terminated string containing warning messages. * @see GetWarningStringLine, GetWarningStringLineCount, OutputWarningString */ const char* GetWarningString(void); /** - * Retrieves the given warning line. + * Retrieves the given warning line. * @param n The zero-based index of the line to retrieve. - * @return A null terminated string containing the given warning line message. + * @return A null terminated string containing the given warning line message. * @see GetWarningStringLineCount, OutputWarningString */ const char* GetWarningStringLine(int n); /** * Retrieves the number of lines in the current warning string buffer. - * @return The number of lines. + * @return The number of lines. * @see GetWarningStringLine, GetWarningString, OutputWarningString */ int GetWarningStringLineCount(void)const; @@ -601,7 +621,7 @@ public: * @return The number of errors encountered. * @see LoadDatabaseString * @remarks - * All previous definitions are cleared. + * All previous definitions are cleared. */ int LoadDatabase(const char* filename); @@ -611,12 +631,12 @@ public: * @return The number of errors encountered. * @see LoadDatabaseString * @remarks - * All previous definitions are cleared. + * All previous definitions are cleared. */ 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); @@ -655,6 +675,16 @@ public: */ int RunFile(const char* filename); + /** + * Runs the specified string as input to phreeqc. + * @param input String containing phreeqc input. + * @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. + */ + int RunString(const char* input); + /** * Sets a C callback function for Basic programs. The syntax for the Basic command is * 10 result = CALLBACK(x1, x2, string$) @@ -676,14 +706,14 @@ public: void SetBasicFortranCallback(double (*fcn)(double *x1, double *x2, char *str, int l)); /** - * Runs the specified string as input to phreeqc. - * @param input String containing phreeqc input. - * @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. + * Sets the currently active SELECTED_OUTPUT user number for use in subsequent calls to GetSelectedOutputXXX routines. + * The initial setting is 1. + * @param n The user number as specified in the SELECTED_OUTPUT block. + * @retval VR_OK Success + * @retval VR_INVALIDARG The given user number has not been defined. + * @see GetCurrentSelectedOutputUserNumber, GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue */ - int RunString(const char* input); + VRESULT SetCurrentSelectedOutputUserNumber(int n); /** * Sets the name of the dump file. This file name is used if not specified within DUMP input. @@ -747,8 +777,8 @@ public: * Sets the log file switch on or off. This switch controls whether or not phreeqc * writes log messages to the phreeqc.id.log (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. + * @remarks + * Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages. * @see GetLogFileOn */ void SetLogFileOn(bool bValue); @@ -811,17 +841,6 @@ public: */ void SetSelectedOutputStringOn(bool bValue); - - /** - * Sets the given user number for use in subsequent calls to GetSelectedOutputXXX routines. - * The initial setting is 1. - * @param n The user number as specified in the SELECTED_OUTPUT block. - * @see GetSelectedOutputColumnCount, GetSelectedOutputFileName, GetSelectedOutputRowCount, GetSelectedOutputString, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, GetSelectedOutputValue - */ - void SetCurrentSelectedOutputUserNumber(int n); - - - public: // overrides virtual void error_msg(const char *str, bool stop=false); diff --git a/IPhreeqcLib.cpp b/IPhreeqcLib.cpp index 795a9f35..fa77c7f7 100644 --- a/IPhreeqcLib.cpp +++ b/IPhreeqcLib.cpp @@ -106,6 +106,17 @@ GetComponentCount(int id) return IPQ_BADINSTANCE; } +int +GetCurrentSelectedOutputUserNumber(int id) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + return IPhreeqcPtr->GetCurrentSelectedOutputUserNumber(); + } + return IPQ_BADINSTANCE; +} + const char* GetDumpFileName(int id) { @@ -355,6 +366,22 @@ GetLogStringOn(int id) return IPQ_BADINSTANCE; } +int +GetNthSelectedOutputUserNumber(int id, int n) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + int nth = IPhreeqcPtr->GetNthSelectedOutputUserNumber(n); + switch (nth) + { + case VR_INVALIDARG: return IPQ_INVALIDARG; + } + return nth; + } + return IPQ_BADINSTANCE; +} + const char* GetOutputFileName(int id) { @@ -449,6 +476,17 @@ GetSelectedOutputColumnCount(int id) return IPQ_BADINSTANCE; } +int +GetSelectedOutputCount(int id) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + return IPhreeqcPtr->GetSelectedOutputCount(); + } + return IPQ_BADINSTANCE; +} + const char* GetSelectedOutputFileName(int id) { @@ -549,7 +587,7 @@ GetSelectedOutputValue(int id, int row, int col, VAR* pVAR) IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); if (IPhreeqcPtr) { - switch(IPhreeqcPtr->GetSelectedOutputValue(row, col, pVAR)) + switch (IPhreeqcPtr->GetSelectedOutputValue(row, col, pVAR)) { case VR_OK: return IPQ_OK; case VR_OUTOFMEMORY: return IPQ_OUTOFMEMORY; @@ -570,7 +608,7 @@ GetSelectedOutputValue2(int id, int row, int col, int *vtype, double* dvalue, ch IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); if (IPhreeqcPtr) { - switch(IPhreeqcPtr->GetSelectedOutputValue2(row, col, vtype, dvalue, svalue, svalue_length)) + switch (IPhreeqcPtr->GetSelectedOutputValue2(row, col, vtype, dvalue, svalue, svalue_length)) { case VR_OK: return IPQ_OK; case VR_OUTOFMEMORY: return IPQ_OUTOFMEMORY; @@ -737,6 +775,23 @@ SetBasicFortranCallback(int id, double (*fcn)(double *x1, double *x2, char *str, } return IPQ_BADINSTANCE; } + +IPQ_RESULT +SetCurrentSelectedOutputUserNumber(int id, int n) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + switch (IPhreeqcPtr->SetCurrentSelectedOutputUserNumber(n)) + { + case VR_INVALIDARG: return IPQ_INVALIDARG; + case VR_OK: return IPQ_OK; + default: assert(false); + } + } + return IPQ_BADINSTANCE; +} + IPQ_RESULT SetDumpFileName(int id, const char* filename) {