Added AddWarning AddError C/Fortran methods

git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@4439 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
Scott R Charlton 2010-05-20 18:49:08 +00:00
parent 1a303e4143
commit d2077ae177
10 changed files with 153 additions and 12 deletions

View File

@ -39,6 +39,10 @@
<param name="Name" value="AddError">
<param name="Local" value="html\IPhreeqc_8h.html#af3f2f3e5a3da135b37bd43e943b3dc38">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="AddWarning">
<param name="Local" value="html\IPhreeqc_8h.html#ae8393fd0ef3939bed93943dcac17a0a1">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="ClearAccumulatedLines">
<param name="Local" value="html\IPhreeqc_8h.html#a9b0cbb3bbc80c9e8b4e43d99e831cb69">

View File

@ -43,6 +43,8 @@ C function prototypes
C
INTEGER(KIND=4) AccumulateLine
INTEGER(KIND=4) AddError
INTEGER(KIND=4) AddWarning
INTEGER(KIND=4) CreateIPhreeqc
INTEGER(KIND=4) DestroyIPhreeqc
INTEGER(KIND=4) GetComponentCount
@ -63,8 +65,8 @@ C
INTEGER(KIND=4) GetWarningStringLineCount
INTEGER(KIND=4) LoadDatabase
INTEGER(KIND=4) LoadDatabaseString
INTEGER(KIND=4) OutputLastError
INTEGER(KIND=4) OutputLastWarning
INTEGER(KIND=4) OutputErrorString
INTEGER(KIND=4) OutputWarningString
INTEGER(KIND=4) OutputAccumulatedLines
INTEGER(KIND=4) RunAccumulated
INTEGER(KIND=4) RunFile

View File

@ -24,6 +24,24 @@
END INTERFACE
INTERFACE
FUNCTION AddError(ID,ERROR_MSG)
INTEGER(KIND=4), INTENT(IN) :: ID
CHARACTER(LEN=*), INTENT(IN) :: ERROR_MSG
INTEGER(KIND=4) :: AddError
END FUNCTION AddError
END INTERFACE
INTERFACE
FUNCTION AddWarning(ID,WARN_MSG)
INTEGER(KIND=4), INTENT(IN) :: ID
CHARACTER(LEN=*), INTENT(IN) :: WARN_MSG
INTEGER(KIND=4) :: AddWarning
END FUNCTION AddWarning
END INTERFACE
INTERFACE
FUNCTION CreateIPhreeqc()
INTEGER(KIND=4) :: CreateIPhreeqc
@ -209,7 +227,11 @@
END INTERFACE
!!! TODO OutputWarningString
INTERFACE
SUBROUTINE OutputWarningString(ID)
INTEGER(KIND=4), INTENT(IN) :: ID
END SUBROUTINE OutputWarningString
END INTERFACE
INTERFACE

View File

@ -60,12 +60,43 @@ extern "C" {
* @returns The current error count if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT).
* @par Fortran90 Interface:
* @htmlonly
* Not implemented.
* <CODE>
* <PRE>
* FUNCTION AddError(ID,ERROR_MSG)
* INTEGER(KIND=4), INTENT(IN) :: ID
* CHARACTER(LEN=*), INTENT(IN) :: ERROR_MSG
* INTEGER(KIND=4) :: AddError
* END FUNCTION AddError
* </PRE>
* </CODE>
* @endhtmlonly
*/
IPQ_DLL_EXPORT int AddError(int id, const char* error_msg);
/**
* Appends the given warning message and increments the warning count.
* Internally used to create a warning condition.
* @param id The instance id returned from \ref CreateIPhreeqc.
* @param error_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).
* @par Fortran90 Interface:
* @htmlonly
* <CODE>
* <PRE>
* FUNCTION AddWarning(ID,WARN_MSG)
* INTEGER(KIND=4), INTENT(IN) :: ID
* CHARACTER(LEN=*), INTENT(IN) :: WARN_MSG
* INTEGER(KIND=4) :: AddWarning
* END FUNCTION AddWarning
* </PRE>
* </CODE>
* @endhtmlonly
*/
IPQ_DLL_EXPORT int AddWarning(int id, const char* warn_msg);
/**
* Clears the accumulated input buffer. Input buffer is accumulated from calls to \ref AccumulateLine.
* @retval IPQ_OK Success.

View File

@ -8,7 +8,23 @@
AccumulateLine = AccumulateLineF(ID,LINE)
END FUNCTION AccumulateLine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! AddError
FUNCTION AddError(ID,ERROR_MSG)
IMPLICIT NONE
INTEGER(KIND=4) :: ID
CHARACTER(LEN=*) :: ERROR_MSG
INTEGER(KIND=4) :: AddError
INTEGER(KIND=4) :: AddErrorF
AddError = AddErrorF(ID,LINE)
END FUNCTION AddError
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION AddWarning(ID,WARN_MSG)
IMPLICIT NONE
INTEGER(KIND=4) :: ID
CHARACTER(LEN=*) :: WARN_MSG
INTEGER(KIND=4) :: AddWarning
INTEGER(KIND=4) :: AddWarningF
AddWarning = AddWarningF(ID,WARN_MSG)
END FUNCTION AddWarning
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION ClearAccumulatedLines(ID)
IMPLICIT NONE

View File

@ -47,7 +47,16 @@ AddError(int id, const char* error_msg)
return IPQ_BADINSTANCE;
}
// TODO AddWarning
int
AddWarning(int id, const char* warn_msg)
{
IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr)
{
return (int)IPhreeqcPtr->AddWarning(warn_msg);
}
return IPQ_BADINSTANCE;
}
IPQ_RESULT
ClearAccumulatedLines(int id)

View File

@ -54,9 +54,41 @@ AccumulateLineF(int *id, char *line, unsigned int line_length)
return n;
}
/*
AddErrorF
*/
int
AddErrorF(int *id, char *error_msg, unsigned int len)
{
int n;
char* cmsg;
cmsg = f2cstring(error_msg, len);
if (!cmsg)
{
::AddError(*id, "AddError: Out of memory.\n");
return IPQ_OUTOFMEMORY;
}
n = ::AddError(*id, cmsg);
free(cmsg);
return n;
}
int
AddWarningF(int *id, char *warn_msg, unsigned int len)
{
int n;
char* cmsg;
cmsg = f2cstring(warn_msg, len);
if (!cmsg)
{
::AddError(*id, "AddWarning: Out of memory.\n");
return IPQ_OUTOFMEMORY;
}
n = ::AddWarning(*id, cmsg);
free(cmsg);
return n;
}
IPQ_RESULT
ClearAccumulatedLinesF(int *id)
@ -379,7 +411,14 @@ IPQ_DLL_EXPORT int __stdcall ACCUMULATELINE(int *id, char *line, unsigned int l
{
return AccumulateLineF(id, line, len);
}
// AddError
IPQ_DLL_EXPORT int __stdcall ADDERROR(int *id, char *error_msg, unsigned int len)
{
return AddErrorF(id, error_msg, len);
}
IPQ_DLL_EXPORT int __stdcall ADDWARNING(int *id, char *warn_msg, unsigned int len)
{
return AddWarningF(id, warn_msg, len);
}
IPQ_DLL_EXPORT int __stdcall CLEARACCUMULATEDLINES(int *id)
{
return ClearAccumulatedLinesF(id);

View File

@ -9,6 +9,8 @@
#if defined(FC_FUNC)
#define AccumulateLineF FC_FUNC (accumulatelinef, ACCUMULATELINEF)
#define AddErrorF FC_FUNC (adderrorf, ADDERRORF)
#define AddWarningF FC_FUNC (addwarningf, ADDWARNINGF)
#define ClearAccumulatedLinesF FC_FUNC (clearaccumulatedlinesf, CLEARACCUMULATEDLINESF)
#define CreateIPhreeqcF FC_FUNC (createiphreeqcf, CREATEIPHREEQCF)
#define DestroyIPhreeqcF FC_FUNC (destroyiphreeqcf, DESTROYIPHREEQCF)
@ -51,6 +53,8 @@ extern "C" {
#endif
IPQ_RESULT AccumulateLineF(int *id, char *line, unsigned int line_length);
int AddErrorF(int *id, char *error_msg, unsigned int len);
int AddWarningF(int *id, char *warn_msg, unsigned int len);
IPQ_RESULT ClearAccumulatedLinesF(int *id);
int CreateIPhreeqcF(void);
int DestroyIPhreeqcF(int *id);

View File

@ -15,7 +15,14 @@ IPQ_DLL_EXPORT int ACCUMULATELINE(int *id, char *line, unsigned int len)
{
return AccumulateLineF(id, line, len);
}
// AddError
IPQ_DLL_EXPORT int ADDERROR(int *id, char *error_msg, unsigned int len)
{
return AddErrorF(id, error_msg, len);
}
IPQ_DLL_EXPORT int ADDWARNING(int *id, char *warn_msg, unsigned int len)
{
return AddWarningF(id, warn_msg, len);
}
IPQ_DLL_EXPORT int CLEARACCUMULATEDLINES(int *id)
{
return ClearAccumulatedLinesF(id);

View File

@ -14,7 +14,14 @@ IPQ_DLL_EXPORT int accumulateline_(int *id, char *line, unsigned int len)
{
return AccumulateLineF(id, line, len);
}
// AddError
IPQ_DLL_EXPORT int adderror(int *id, char *error_msg, unsigned int len)
{
return AddErrorF(id, error_msg, len);
}
IPQ_DLL_EXPORT int addwarning(int *id, char *warn_msg, unsigned int len)
{
return AddWarningF(id, warn_msg, len);
}
IPQ_DLL_EXPORT int clearaccumulatedlines_(int *id)
{
return ClearAccumulatedLinesF(id);