implemented Get/SetErrorOn

This commit is contained in:
Charlton, Scott R 2020-08-25 12:17:54 -06:00
parent 24d69a0557
commit e221f73ce7
13 changed files with 223 additions and 1 deletions

View File

@ -213,9 +213,19 @@ bool IPhreeqc::GetErrorFileOn(void)const
return this->ErrorFileOn;
}
bool IPhreeqc::GetErrorOn(void)const
{
return this->Get_error_on();
}
const char* IPhreeqc::GetErrorString(void)
{
static const char err_msg[] = "GetErrorString: ErrorStringOn not set.\n";
static const char err_msg2[] = "GetErrorString: ErrorOn not set.\n";
if (!this->error_on)
{
return err_msg2;
}
if (!this->ErrorStringOn)
{
return err_msg;
@ -973,6 +983,11 @@ void IPhreeqc::SetErrorFileOn(bool bValue)
this->ErrorFileOn = bValue;
}
void IPhreeqc::SetErrorOn(bool bValue)
{
this->Set_error_on(bValue);
}
void IPhreeqc::SetErrorStringOn(bool bValue)
{
this->ErrorStringOn = bValue;

View File

@ -54,6 +54,7 @@
INTEGER(KIND=4) GetDumpStringLineCount
LOGICAL(KIND=4) GetDumpStringOn
LOGICAL(KIND=4) GetErrorFileOn
LOGICAL(KIND=4) GetErrorOn
INTEGER(KIND=4) GetErrorStringLine
INTEGER(KIND=4) GetErrorStringLineCount
LOGICAL(KIND=4) GetLogFileOn
@ -78,6 +79,7 @@
INTEGER(KIND=4) SetDumpFileOn
INTEGER(KIND=4) SetDumpStringOn
INTEGER(KIND=4) SetErrorFileOn
INTEGER(KIND=4) SetErrorOn
INTEGER(KIND=4) SetErrorStringOn
INTEGER(KIND=4) SetLogFileName
INTEGER(KIND=4) SetLogFileOn

View File

@ -147,6 +147,14 @@
END INTERFACE
INTERFACE
FUNCTION GetErrorOn(ID)
INTEGER(KIND=4), INTENT(IN) :: ID
LOGICAL(KIND=4) :: GetErrorOn
END FUNCTION GetErrorOn
END INTERFACE
INTERFACE
SUBROUTINE GetErrorStringLine(ID,N,LINE)
INTEGER(KIND=4), INTENT(IN) :: ID
@ -496,6 +504,15 @@
END INTERFACE
INTERFACE
FUNCTION SetErrorOn(ID,ERR_ON)
INTEGER(KIND=4), INTENT(IN) :: ID
LOGICAL(KIND=4), INTENT(IN) :: ERR_ON
INTEGER(KIND=4) :: SetErrorOn
END FUNCTION SetErrorOn
END INTERFACE
INTERFACE
FUNCTION SetErrorStringOn(ID,ERR_STRING_ON)
INTEGER(KIND=4), INTENT(IN) :: ID

View File

@ -433,6 +433,25 @@ extern "C" {
*/
IPQ_DLL_EXPORT int GetErrorFileOn(int id);
/**
* Retrieves the current value of the error on switch.
* @param id The instance id returned from @ref CreateIPhreeqc.
* @return Non-zero if errors are generated, 0 (zero) otherwise.
* @see SetErrorOn
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION GetErrorOn(ID)
* INTEGER(KIND=4), INTENT(IN) :: ID
* LOGICAL(KIND=4) :: GetErrorOn
* END FUNCTION GetErrorOn
* </PRE>
* </CODE>
* @endhtmlonly
*/
IPQ_DLL_EXPORT int GetErrorOn(int id);
/**
* Retrieves the error messages from the last call to @ref RunAccumulated, @ref RunFile, @ref RunString, @ref LoadDatabase, or @ref LoadDatabaseString.
@ -1852,6 +1871,31 @@ Headings
*/
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOn(int id, int error_on);
/**
* Sets the error switch on or off. This switch controls whether or not
* error messages are generated and displayed. The initial setting after calling
* @ref CreateIPhreeqc is on.
* @param id The instance id returned from @ref CreateIPhreeqc.
* @param error_on If non-zero, writes errors to the error file and error string; if zero, no errors are written to the error file or stored in the error string.
* @retval IPQ_OK Success.
* @retval IPQ_BADINSTANCE The given id is invalid.
* @see GetErrorOn, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION SetErrorOn(ID,ERR_ON)
* INTEGER(KIND=4), INTENT(IN) :: ID
* LOGICAL(KIND=4), INTENT(IN) :: ERR_ON
* INTEGER(KIND=4) :: SetErrorOn
* END FUNCTION SetErrorOn
* </PRE>
* </CODE>
* @endhtmlonly
*/
IPQ_DLL_EXPORT IPQ_RESULT SetErrorOn(int id, int error_on);
/**
* Sets the error string switch on or off. This switch controls whether or not the data normally sent
* to the error file are stored in a buffer for retrieval. The initial setting after calling

View File

@ -193,6 +193,14 @@ public:
*/
bool GetErrorFileOn(void)const;
/**
* Retrieves the current value of the error switch.
* @retval true Error messages are sent to the error file and to the string buffer
* @retval false No errors are sent.
* @see SetErrorOn
*/
bool GetErrorOn(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.
@ -768,12 +776,21 @@ 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.
* The initial setting is false.
* The initial setting is true.
* @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
*/
void SetErrorFileOn(bool bValue);
/**
* Sets the error switch on or off. This switch controls whether
* error messages are are generated and displayed.
* The initial setting is true.
* @param bValue If true, error messages are sent to the error file and error string buffer; if false, no error messages are generated.
* @see GetErrorOn, GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString
*/
void SetErrorOn(bool bValue);
/**
* Sets the error string switch on or off. This switch controls whether or not the data normally sent
* to the error file are stored in a buffer for retrieval. The initial setting is true.

View File

@ -145,6 +145,18 @@
GetErrorFileOn = .TRUE.
ENDIF
END FUNCTION GetErrorFileOn
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION GetErrorOn(ID)
IMPLICIT NONE
INTEGER(KIND=4) :: ID
LOGICAL(KIND=4) :: GetErrorOn
INTEGER(KIND=4) :: GetErrorOnF
IF (GetErrorOnF(ID).EQ.0) THEN
GetErrorOn = .FALSE.
ELSE
GetErrorOn = .TRUE.
ENDIF
END FUNCTION GetErrorOn
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! GetErrorString
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -536,6 +548,15 @@
INTEGER(KIND=4) :: SetErrorFileOnF
SetErrorFileOn = SetErrorFileOnF(ID,ERROR_ON)
END FUNCTION SetErrorFileOn
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION SetErrorOn(ID,ERROR_ON)
IMPLICIT NONE
INTEGER(KIND=4) :: ID
LOGICAL(KIND=4) :: ERROR_ON
INTEGER(KIND=4) :: SetErrorOn
INTEGER(KIND=4) :: SetErrorOnF
SetErrorOn = SetErrorOnF(ID,ERROR_ON)
END FUNCTION SetErrorOn
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION SetErrorStringOn(ID,ERROR_STRING_ON)
IMPLICIT NONE

View File

@ -236,6 +236,24 @@ GetErrorFileOn(int id)
return IPQ_BADINSTANCE;
}
int
GetErrorOn(int id)
{
IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr)
{
if (IPhreeqcPtr->GetErrorOn())
{
return 1;
}
else
{
return 0;
}
}
return IPQ_BADINSTANCE;
}
const char*
GetErrorString(int id)
{
@ -884,6 +902,18 @@ SetErrorFileOn(int id, int value)
return IPQ_BADINSTANCE;
}
IPQ_RESULT
SetErrorOn(int id, int value)
{
IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr)
{
IPhreeqcPtr->SetErrorOn(value != 0);
return IPQ_OK;
}
return IPQ_BADINSTANCE;
}
IPQ_RESULT
SetErrorStringOn(int id, int value)
{

View File

@ -289,6 +289,22 @@ LOGICAL FUNCTION GetErrorFileOn(id)
return
END FUNCTION GetErrorFileOn
LOGICAL FUNCTION GetErrorOn(id)
USE ISO_C_BINDING
IMPLICIT NONE
INTERFACE
INTEGER(KIND=C_INT) FUNCTION GetErrorOnF(id) &
BIND(C, NAME='GetErrorOnF')
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER(KIND=C_INT), INTENT(in) :: id
END FUNCTION GetErrorOnF
END INTERFACE
INTEGER, INTENT(in) :: id
GetErrorOn = (GetErrorOnF(id) .ne. 0)
return
END FUNCTION GetErrorOn
INTEGER FUNCTION GetErrorStringLineCount(id)
USE ISO_C_BINDING
IMPLICIT NONE
@ -1049,6 +1065,26 @@ INTEGER FUNCTION SetErrorFileOn(id, error_file_on)
return
END FUNCTION SetErrorFileOn
INTEGER FUNCTION SetErrorOn(id, error_on)
USE ISO_C_BINDING
IMPLICIT NONE
INTERFACE
INTEGER(KIND=C_INT) FUNCTION SetErrorOnF(id, error_on) &
BIND(C, NAME='SetErrorOnF')
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER(KIND=C_INT), INTENT(in) :: id, error_on
END FUNCTION SetErrorOnF
END INTERFACE
INTEGER, INTENT(in) :: id
LOGICAL, INTENT(in) :: error_on
INTEGER :: tf = 0
tf = 0
if (error_on) tf = 1
SetErrorOn = SetErrorOnF(id, tf)
return
END FUNCTION SetErrorOn
INTEGER FUNCTION SetErrorStringOn(id, error_string_on)
USE ISO_C_BINDING
IMPLICIT NONE

View File

@ -145,6 +145,12 @@ GetErrorFileOnF(int *id)
return ::GetErrorFileOn(*id);
}
int
GetErrorOnF(int *id)
{
return ::GetErrorOn(*id);
}
/*
GetErrorStringF
*/
@ -457,6 +463,12 @@ SetErrorFileOnF(int *id, int* error_file_on)
return ::SetErrorFileOn(*id, *error_file_on);
}
IPQ_RESULT
SetErrorOnF(int *id, int* error_on)
{
return ::SetErrorOn(*id, *error_on);
}
IPQ_RESULT
SetErrorStringOnF(int *id, int* error_string_on)
{

View File

@ -25,6 +25,7 @@
#define GetDumpStringOnF FC_FUNC (getdumpstringonf, GETDUMPSTRINGONF)
#define GetErrorFileNameF FC_FUNC (geterrorfilenamef, GETERRORFILENAMEF)
#define GetErrorFileOnF FC_FUNC (geterrorfileonf, GETERRORFILEONF)
#define GetErrorOnF FC_FUNC (geterroronf, GETERRORONF)
#define GetErrorStringLineF FC_FUNC (geterrorstringlinef, GETERRORSTRINGLINEF)
#define GetErrorStringLineCountF FC_FUNC (geterrorstringlinecountf, GETERRORSTRINGLINECOUNTF)
#define GetErrorStringOnF FC_FUNC (geterrorstringonf, GETERRORSTRINGONF)
@ -66,6 +67,7 @@
#define SetDumpStringOnF FC_FUNC (setdumpstringonf, SETDUMPSTRINGONF)
#define SetErrorFileNameF FC_FUNC (seterrorfilenamef, SETERRORFILENAMEF)
#define SetErrorFileOnF FC_FUNC (seterrorfileonf, SETERRORFILEONF)
#define SetErrorOnF FC_FUNC (seterroronf, SETERRORONF)
#define SetErrorStringOnF FC_FUNC (seterrorstringonf, SETERRORSTRINGONF)
#define SetLogFileNameF FC_FUNC (setlogfilenamef, SETLOGFILENAMEF)
#define SetLogFileOnF FC_FUNC (setlogfileonf, SETLOGFILEONF)
@ -99,6 +101,7 @@ extern "C" {
IPQ_DLL_EXPORT int GetDumpStringOnF(int *id);
IPQ_DLL_EXPORT void GetErrorFileNameF(int *id, char* filename, int* filename_length);
IPQ_DLL_EXPORT int GetErrorFileOnF(int *id);
IPQ_DLL_EXPORT int GetErrorOnF(int *id);
IPQ_DLL_EXPORT void GetErrorStringLineF(int *id, int* n, char* line, int* line_length);
IPQ_DLL_EXPORT int GetErrorStringLineCountF(int *id);
IPQ_DLL_EXPORT int GetErrorStringOnF(int *id);
@ -144,6 +147,7 @@ extern "C" {
IPQ_DLL_EXPORT IPQ_RESULT SetDumpStringOnF(int *id, int* dump_string_on);
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileNameF(int *id, char* fname);
IPQ_DLL_EXPORT IPQ_RESULT SetErrorFileOnF(int *id, int* error_file_on);
IPQ_DLL_EXPORT IPQ_RESULT SetErrorOnF(int *id, int* error_on);
IPQ_DLL_EXPORT IPQ_RESULT SetErrorStringOnF(int *id, int* error_string_on);
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileNameF(int *id, char* fname);
IPQ_DLL_EXPORT IPQ_RESULT SetLogFileOnF(int *id, int* log_file_on);

View File

@ -63,6 +63,10 @@ IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(geterrorfileon, GETERRORFILEON, geterr
{
return GetErrorFileOnF(id);
}
IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(geterroron, GETERRORON, geterroron_, GETERRORON_)(int *id)
{
return GetErrorOnF(id);
}
// GetErrorString
IPQ_DLL_EXPORT void IPQ_DECL IPQ_CASE_UND(geterrorstringline, GETERRORSTRINGLINE, geterrorstringline_, GETERRORSTRINGLINE_)(int *id, int *n, char* line, size_t line_length)
{
@ -232,6 +236,10 @@ IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(seterrorfileon, SETERRORFILEON, seterr
{
return SetErrorFileOnF(id, error_on);
}
IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(seterroron, SETERRORON, seterroron_, SETERRORON_)(int *id, int *error_on)
{
return SetErrorOnF(id, error_on);
}
IPQ_DLL_EXPORT int IPQ_DECL IPQ_CASE_UND(seterrorstringon, SETERRORSTRINGON, seterrorstringon_, SETERRORSTRINGON_)(int *id, int *error_string_on)
{
return SetErrorStringOnF(id, error_string_on);

View File

@ -174,6 +174,12 @@ GetErrorFileOnF(int *id)
return ::GetErrorFileOn(*id);
}
int
GetErrorOnF(int *id)
{
return ::GetErrorOn(*id);
}
/*
GetErrorStringF
*/
@ -539,6 +545,12 @@ SetErrorFileOnF(int *id, int* error_file_on)
return ::SetErrorFileOn(*id, *error_file_on);
}
IPQ_RESULT
SetErrorOnF(int *id, int* error_on)
{
return ::SetErrorOn(*id, *error_on);
}
IPQ_RESULT
SetErrorStringOnF(int *id, int* error_string_on)
{

View File

@ -25,6 +25,7 @@
#define GetDumpStringOnF FC_FUNC (getdumpstringonf, GETDUMPSTRINGONF)
#define GetErrorFileNameF FC_FUNC (geterrorfilenamef, GETERRORFILENAMEF)
#define GetErrorFileOnF FC_FUNC (geterrorfileonf, GETERRORFILEONF)
#define GetErrorOnF FC_FUNC (geterroronf, GETERRORONF)
#define GetErrorStringLineF FC_FUNC (geterrorstringlinef, GETERRORSTRINGLINEF)
#define GetErrorStringLineCountF FC_FUNC (geterrorstringlinecountf, GETERRORSTRINGLINECOUNTF)
#define GetErrorStringOnF FC_FUNC (geterrorstringonf, GETERRORSTRINGONF)
@ -66,6 +67,7 @@
#define SetDumpStringOnF FC_FUNC (setdumpstringonf, SETDUMPSTRINGONF)
#define SetErrorFileNameF FC_FUNC (seterrorfilenamef, SETERRORFILENAMEF)
#define SetErrorFileOnF FC_FUNC (seterrorfileonf, SETERRORFILEONF)
#define SetErrorOnF FC_FUNC (seterroronf, SETERRORONF)
#define SetErrorStringOnF FC_FUNC (seterrorstringonf, SETERRORSTRINGONF)
#define SetLogFileNameF FC_FUNC (setlogfilenamef, SETLOGFILENAMEF)
#define SetLogFileOnF FC_FUNC (setlogfileonf, SETLOGFILEONF)
@ -98,6 +100,7 @@ extern "C" {
int GetDumpStringOnF(int *id);
void GetErrorFileNameF(int *id, char* filename, size_t filename_length);
int GetErrorFileOnF(int *id);
int GetErrorOnF(int *id);
void GetErrorStringLineF(int *id, int* n, char* line, size_t line_length);
int GetErrorStringLineCountF(int *id);
int GetErrorStringOnF(int *id);
@ -139,6 +142,7 @@ extern "C" {
IPQ_RESULT SetDumpStringOnF(int *id, int* dump_string_on);
IPQ_RESULT SetErrorFileNameF(int *id, char* fname, size_t fname_length);
IPQ_RESULT SetErrorFileOnF(int *id, int* error_file_on);
IPQ_RESULT SetErrorOnF(int *id, int* error_on);
IPQ_RESULT SetErrorStringOnF(int *id, int* error_string_on);
IPQ_RESULT SetLogFileNameF(int *id, char* fname, size_t fname_length);
IPQ_RESULT SetLogFileOnF(int *id, int* log_file_on);