From 298a715b8b90db90b27bb7952dbcfd198abb6bba Mon Sep 17 00:00:00 2001 From: Scott R Charlton Date: Tue, 4 May 2010 23:36:21 +0000 Subject: [PATCH] Renamed GetLastErrorString to GetErrorString git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@4339 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- include/IPhreeqc.f90.inc | 16 ++++++------ include/IPhreeqc.h | 56 ++++++++++++++++++++++++---------------- include/IPhreeqc.hpp | 25 +++++++++++++----- include/Var.h | 30 ++++++++++----------- src/IPhreeqc.cpp | 36 +++++++++++++------------- src/IPhreeqcF.f | 12 ++++----- src/IPhreeqcLib.cpp | 24 ++++++++--------- src/fwrap.cpp | 16 ++++++------ src/fwrap.h | 8 +++--- src/fwrap2.cpp | 8 +++--- src/fwrap3.cpp | 8 +++--- tests/test_c.c | 16 ++++++------ tests/test_cxx.cxx | 6 ++--- tests/test_f.f | 6 ++--- tests/test_f90.f90 | 6 ++--- unit/GNUmakefile | 2 +- unit/TestIPhreeqc.cpp | 22 ++++++++-------- unit/TestIPhreeqc.h | 14 +++++----- unit/TestIPhreeqcLib.cpp | 28 ++++++++++---------- unit/TestIPhreeqcLib.h | 4 +-- 20 files changed, 184 insertions(+), 159 deletions(-) diff --git a/include/IPhreeqc.f90.inc b/include/IPhreeqc.f90.inc index 9e9dffd4..5656a10d 100644 --- a/include/IPhreeqc.f90.inc +++ b/include/IPhreeqc.f90.inc @@ -58,9 +58,9 @@ INTERFACE SUBROUTINE GetDumpLine(ID,N,LINE) - INTEGER(KIND=4), INTENT(IN) :: ID - INTEGER(KIND=4), INTENT(IN) :: N - CHARACTER(LEN=*), INTENT(OUT) :: LINE + INTEGER(KIND=4), INTENT(IN) :: ID + INTEGER(KIND=4), INTENT(IN) :: N + CHARACTER(LEN=*), INTENT(OUT) :: LINE END SUBROUTINE END INTERFACE @@ -100,10 +100,10 @@ !!! TODO GetErrorOn - !!! GetLastErrorString not implemented + !!! GetErrorString not implemented - !!! GetLastWarningString not implemented + !!! GetWarningString not implemented !!! TODO GetLogOn @@ -180,13 +180,13 @@ INTERFACE - SUBROUTINE OutputLastError(ID) + SUBROUTINE OutputError(ID) INTEGER(KIND=4), INTENT(IN) :: ID - END SUBROUTINE OutputLastError + END SUBROUTINE OutputError END INTERFACE - !!! TODO OutputLastWarning + !!! TODO OutputWarning INTERFACE diff --git a/include/IPhreeqc.h b/include/IPhreeqc.h index e2ea232f..2eeb8efc 100644 --- a/include/IPhreeqc.h +++ b/include/IPhreeqc.h @@ -63,7 +63,8 @@ extern "C" { /** * Create a new IPhreeqc instance. - * @return A non-negative value if successful; otherwise returns a negative value. + * @return A non-negative value if successful; otherwise a negative value indicates an error occured (see \ref IPQ_RESULT). + * @see DestroyIPhreeqc * @par Fortran90 Interface: * @htmlonly * @@ -81,6 +82,7 @@ extern "C" { /** * Release an IPhreeqc instance from memory. * @param id The instance id returned from CreateIPhreeqc. + * @see CreateIPhreeqc * @par Fortran90 Interface: * @htmlonly * @@ -100,6 +102,7 @@ extern "C" { * Retrieves the given component. * @param id The instance id returned from CreateIPhreeqc. * @param n The zero-based index of the component to retrieve. + * @see GetComponentCount * @par Fortran90 Interface: * @htmlonly * @@ -119,6 +122,7 @@ extern "C" { /** * Retrieves the number of components in the current simulation. * @param id The instance id returned from CreateIPhreeqc. + * @see GetComponent * @par Fortran90 Interface: * @htmlonly * @@ -138,14 +142,15 @@ extern "C" { * Retrieves the given dump line. * @param id The instance id returned from CreateIPhreeqc. * @param n The zero-based index of the line to retrieve. + * @see GetDumpLineCount, SetDumpStringOn * @par Fortran90 Interface: * @htmlonly * *
- *  SUBROUTINE GetComponent(ID,N,COMP)
+ *  SUBROUTINE GetDumpLine(ID,N,LINE)
  *    INTEGER(KIND=4),   INTENT(IN)   :: ID
  *    INTEGER(KIND=4),   INTENT(IN)   :: N     ! one-based index
- *    CHARACTER(LEN=*),  INTENT(OUT)  :: COMP
+ *    CHARACTER(LEN=*),  INTENT(OUT)  :: LINE
  *  END SUBROUTINE GetComponent
  *  
*
@@ -157,6 +162,7 @@ extern "C" { /** * Retrieves the number of lines in the current dump string buffer. * @param id The instance id returned from CreateIPhreeqc. + * @see GetDumpLineCount, SetDumpStringOn * @par Fortran90 Interface: * @htmlonly * @@ -175,6 +181,7 @@ extern "C" { /** * Retrieves the current value of the dump flag. * @param id The instance id returned from CreateIPhreeqc. + * @see SetDumpOn * @par Fortran90 Interface: * @htmlonly * @@ -191,8 +198,11 @@ extern "C" { /** - * TODO + * Retrieves the string buffer containing DUMP output. * @param id The instance id returned from CreateIPhreeqc. + * @remarks + * The dump string flag must be set to true in order to recieve DUMP output. + * @see SetDumpStringOn * @par Fortran90 Interface: * @htmlonly * Not implemented. @@ -204,7 +214,6 @@ extern "C" { /** * Retrieves the current value of the dump string flag. * @param id The instance id returned from CreateIPhreeqc. - * @param dump_string_on If non-zero captures as a string the output defined by the DUMP keyword. * @par Fortran90 Interface: * @htmlonly * @@ -221,9 +230,10 @@ extern "C" { /** - * TODO + * Retrieves the given error line. * @param id The instance id returned from CreateIPhreeqc. * @param n The zero-based index of the line to retrieve. + * @see GetErrorLineCount * @par Fortran90 Interface: * @htmlonly * @@ -259,9 +269,9 @@ extern "C" { /** - * Sets the error flag on or off. + * Retrieves the current value of the error flag. * @param id The instance id returned from CreateIPhreeqc. - * @param error_on If non-zero turns on output to the phreeqc.err file. + * @see SetErrorOn * @par Fortran90 Interface: * @htmlonly * @@ -286,7 +296,7 @@ extern "C" { * Not implemented. * @endhtmlonly */ - DLL_EXPORT const char* GetLastErrorString(int id); + DLL_EXPORT const char* GetErrorString(int id); /** @@ -298,7 +308,7 @@ extern "C" { * Not implemented. * @endhtmlonly */ - DLL_EXPORT const char* GetLastWarningString(int id); + DLL_EXPORT const char* GetWarningString(int id); /** @@ -629,8 +639,8 @@ Headings /** * Load the specified string as a database into phreeqc. * @param id The instance id returned from CreateIPhreeqc. - * @param input String containing data to be used as the phreeqc database. - * @return The number of errors encountered. + * @param input String containing data to be used as the phreeqc database. + * @return The number of errors encountered. * @remarks * Any previous database definitions are cleared. * @par Fortran90 Interface: @@ -656,14 +666,14 @@ Headings * @htmlonly * *
- *  SUBROUTINE OutputLastError
+ *  SUBROUTINE OutputError
  *    INTEGER(KIND=4),  INTENT(IN)  :: ID
- *  END SUBROUTINE OutputLastError
+ *  END SUBROUTINE OutputError
  *  
*
* @endhtmlonly */ - DLL_EXPORT void OutputLastError(int id); + DLL_EXPORT void OutputError(int id); /** @@ -673,14 +683,14 @@ Headings * @htmlonly * *
- *  SUBROUTINE OutputLastError
+ *  SUBROUTINE OutputWarning
  *    INTEGER(KIND=4),  INTENT(IN)  :: ID
- *  END SUBROUTINE OutputLastError
+ *  END SUBROUTINE OutputWarning
  *  
*
* @endhtmlonly */ - DLL_EXPORT void OutputLastWarning(int id); + DLL_EXPORT void OutputWarning(int id); /** @@ -704,7 +714,7 @@ Headings /** * Runs the accumulated input sent to AccumulateLine. * @param id The instance id returned from CreateIPhreeqc. - * @return The number of errors encountered. + * @return The number of errors encountered. * @remarks * The accumulated input is cleared upon completion. * @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors. @@ -750,7 +760,7 @@ Headings * @param id The instance id returned from CreateIPhreeqc. * @param input String containing phreeqc input. * @return The number of errors encountered during the run. - * @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors. + * @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors. * @par Fortran90 Interface: * @htmlonly * @@ -775,10 +785,10 @@ Headings * @htmlonly * *
- *  FUNCTION SetDumpStringOn(ID,DUMP_ON)
+ *  FUNCTION SetDumpOn(ID,DUMP_ON)
  *    INTEGER(KIND=4),  INTENT(IN)  :: ID
  *    LOGICAL(KIND=4),  INTENT(IN)  :: DUMP_ON
- *  END FUNCTION SetDumpStringOn
+ *  END FUNCTION SetDumpOn
  *  
*
* @endhtmlonly @@ -828,6 +838,8 @@ Headings * Sets the log flag on or off * @param id The instance id returned from CreateIPhreeqc. * @param log_on If non-zero turns on output to the phreeqc.log file. + * @see GetLogOn + * @return IPQ_OK on success * @par Fortran90 Interface: * @htmlonly * diff --git a/include/IPhreeqc.hpp b/include/IPhreeqc.hpp index 6262d67c..5efd7c17 100644 --- a/include/IPhreeqc.hpp +++ b/include/IPhreeqc.hpp @@ -18,10 +18,23 @@ class Phreeqc; class IErrorReporter; class CSelectedOutput; +/** + * @class IPhreeqcStop + * + * @brief This class is derived from std::exception and is thrown + * when an unrecoverable error has occured. + */ class DLL_EXPORT IPhreeqcStop : std::exception { }; +/** + * @class IPhreeqc + * + * @brief Provides an interface to PHREEQC (Version 2)--A Computer + * Program for Speciation, Batch-Reaction, One-Dimensional Transport, + * and Inverse Geochemical Calculations + */ class DLL_EXPORT IPhreeqc { public: @@ -30,8 +43,8 @@ public: public: - const char* GetLastErrorString(void); - const char* GetLastWarningString(void); + const char* GetErrorString(void); + const char* GetWarningString(void); const char* GetDumpString(void); int LoadDatabase(const char* filename); @@ -50,8 +63,8 @@ public: int GetSelectedOutputColumnCount(void)const; VRESULT GetSelectedOutputValue(int row, int col, VAR* pVAR); - void OutputLastError(void); - void OutputLastWarning(void); + void OutputError(void); + void OutputWarning(void); void OutputLines(void); const std::string& GetAccumulatedLines(void); @@ -118,11 +131,11 @@ protected: bool DumpStringOn; IErrorReporter *ErrorReporter; - std::string LastErrorString; + std::string ErrorString; std::vector< std::string > ErrorLines; IErrorReporter *WarningReporter; - std::string LastWarningString; + std::string WarningString; std::vector< std::string > WarningLines; CSelectedOutput *SelectedOutput; diff --git a/include/Var.h b/include/Var.h index 75d67b79..f3d19db5 100644 --- a/include/Var.h +++ b/include/Var.h @@ -6,22 +6,22 @@ /*! \brief Enumeration used to determine the type of data stored in a VAR. */ typedef enum { - TT_EMPTY = 0, - TT_ERROR = 1, - TT_LONG = 2, - TT_DOUBLE = 3, - TT_STRING = 4 + TT_EMPTY = 0, /*!< VAR contains no data */ + TT_ERROR = 1, /*!< vresult is valid */ + TT_LONG = 2, /*!< lVal is valid */ + TT_DOUBLE = 3, /*!< dVal is valid */ + TT_STRING = 4 /*!< sVal is valid */ } VAR_TYPE; /*! \brief Enumeration used to return error codes. */ typedef enum { - VR_OK = 0, - VR_OUTOFMEMORY = -1, - VR_BADVARTYPE = -2, - VR_INVALIDARG = -3, - VR_INVALIDROW = -4, - VR_INVALIDCOL = -5 + VR_OK = 0, /*!< Success */ + VR_OUTOFMEMORY = -1, /*!< Failure, Out of memory */ + VR_BADVARTYPE = -2, /*!< Failure, Invalid VAR type */ + VR_INVALIDARG = -3, /*!< Failure, Invalid argument */ + VR_INVALIDROW = -4, /*!< Failure, Invalid row */ + VR_INVALIDCOL = -5 /*!< Failure, Invalid column */ } VRESULT; /*! \brief Datatype used to store SELECTED_OUTPUT values. @@ -42,12 +42,12 @@ extern "C" { #endif /** Initializes a VAR. - * @param pvar Pointer to the VAR that will be initialized. + * @param pvar Pointer to the VAR that will be initialized. */ void VarInit(VAR* pvar); /** Clears a VAR. - * @param pvar Pointer to the VAR that will be freed and initialized. + * @param pvar Pointer to the VAR that will be freed and initialized. * @retval VR_OK Success. * @retval VR_BADVARTYPE The \c VAR was invalid (probably uninitialized). */ @@ -65,13 +65,13 @@ VRESULT VarCopy(VAR* pvarDest, const VAR* pvarSrc); /** Allocates a new string for use in a VAR and copies the passed string into it. - * @param pSrc Pointer to the VAR that will be initialized. + * @param pSrc Pointer to the VAR that will be initialized. * @return A pointer to the string on success NULL otherwise. */ char* VarAllocString(const char* pSrc); /** Frees a string allocated using VarAllocString. - * @param pSrc Pointer to the string to be freed. + * @param pSrc Pointer to the string to be freed. */ void VarFreeString(char* pSrc); diff --git a/src/IPhreeqc.cpp b/src/IPhreeqc.cpp index 748c8b58..356c7dca 100644 --- a/src/IPhreeqc.cpp +++ b/src/IPhreeqc.cpp @@ -282,14 +282,14 @@ const std::string& IPhreeqc::GetAccumulatedLines(void) return this->StringInput; } -void IPhreeqc::OutputLastError(void) +void IPhreeqc::OutputError(void) { - std::cout << this->GetLastErrorString() << std::endl; + std::cout << this->GetErrorString() << std::endl; } -void IPhreeqc::OutputLastWarning(void) +void IPhreeqc::OutputWarning(void) { - std::cout << this->GetLastWarningString() << std::endl; + std::cout << this->GetWarningString() << std::endl; } void IPhreeqc::OutputLines(void) @@ -392,13 +392,13 @@ void IPhreeqc::UnLoadDatabase(void) // ASSERT(this->ErrorReporter); this->ErrorReporter->Clear(); - this->LastErrorString.clear(); + this->ErrorString.clear(); // clear warning state // ASSERT(this->WarningReporter); this->WarningReporter->Clear(); - this->LastWarningString.clear(); + this->WarningString.clear(); // clear selectedoutput // @@ -652,16 +652,16 @@ void IPhreeqc::AddSelectedOutput(const char* name, const char* format, va_list a } } -const char* IPhreeqc::GetLastErrorString(void) +const char* IPhreeqc::GetErrorString(void) { - this->LastErrorString = ((CErrorReporter*)this->ErrorReporter)->GetOS()->str(); - return this->LastErrorString.c_str(); + this->ErrorString = ((CErrorReporter*)this->ErrorReporter)->GetOS()->str(); + return this->ErrorString.c_str(); } -const char* IPhreeqc::GetLastWarningString(void) +const char* IPhreeqc::GetWarningString(void) { - this->LastWarningString = ((CErrorReporter*)this->WarningReporter)->GetOS()->str(); - return this->LastWarningString.c_str(); + this->WarningString = ((CErrorReporter*)this->WarningReporter)->GetOS()->str(); + return this->WarningString.c_str(); } const char* IPhreeqc::GetDumpString(void) @@ -1253,10 +1253,10 @@ const char* IPhreeqc::GetWarningLine(int n) void IPhreeqc::update_errors(void) { this->ErrorLines.clear(); - this->LastErrorString = ((CErrorReporter*)this->ErrorReporter)->GetOS()->str(); - if (this->LastErrorString.size()) + this->ErrorString = ((CErrorReporter*)this->ErrorReporter)->GetOS()->str(); + if (this->ErrorString.size()) { - std::istringstream iss(this->LastErrorString); + std::istringstream iss(this->ErrorString); std::string line; while (std::getline(iss, line)) { @@ -1265,10 +1265,10 @@ void IPhreeqc::update_errors(void) } this->WarningLines.clear(); - this->LastWarningString = ((CErrorReporter*)this->WarningReporter)->GetOS()->str(); - if (this->LastWarningString.size()) + this->WarningString = ((CErrorReporter*)this->WarningReporter)->GetOS()->str(); + if (this->WarningString.size()) { - std::istringstream iss(this->LastWarningString); + std::istringstream iss(this->WarningString); std::string line; while (std::getline(iss, line)) { diff --git a/src/IPhreeqcF.f b/src/IPhreeqcF.f index 6a296457..553a512b 100644 --- a/src/IPhreeqcF.f +++ b/src/IPhreeqcF.f @@ -40,17 +40,17 @@ UnLoadDatabase = UnLoadDatabaseF(ID) END FUNCTION UnLoadDatabase !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - SUBROUTINE OutputLastError(ID) + SUBROUTINE OutputError(ID) IMPLICIT NONE INTEGER :: ID - CALL OutputLastErrorF(ID) - END SUBROUTINE OutputLastError + CALL OutputErrorF(ID) + END SUBROUTINE OutputError !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - SUBROUTINE OutputLastWarning(ID) + SUBROUTINE OutputWarning(ID) IMPLICIT NONE INTEGER :: ID - CALL OutputLastWarningF(ID) - END SUBROUTINE OutputLastWarning + CALL OutputWarningF(ID) + END SUBROUTINE OutputWarning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FUNCTION AccumulateLine(ID,LINE) IMPLICIT NONE diff --git a/src/IPhreeqcLib.cpp b/src/IPhreeqcLib.cpp index 8ed5252c..de418d78 100644 --- a/src/IPhreeqcLib.cpp +++ b/src/IPhreeqcLib.cpp @@ -64,51 +64,51 @@ UnLoadDatabase(int id) } void -OutputLastError(int id) +OutputError(int id) { - static const char err_msg[] = "OutputLastError: Bad instance.\n"; + static const char err_msg[] = "OutputError: Bad instance.\n"; IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); if (IPhreeqcPtr) { - IPhreeqcPtr->OutputLastError(); + IPhreeqcPtr->OutputError(); return; } std::cout << err_msg << std::endl; } void -OutputLastWarning(int id) +OutputWarning(int id) { - static const char err_msg[] = "OutputLastWarning: Bad instance.\n"; + static const char err_msg[] = "OutputWarning: Bad instance.\n"; IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); if (IPhreeqcPtr) { - IPhreeqcPtr->OutputLastWarning(); + IPhreeqcPtr->OutputWarning(); return; } std::cout << err_msg << std::endl; } const char* -GetLastErrorString(int id) +GetErrorString(int id) { - static const char err_msg[] = "GetLastErrorString: Bad instance.\n"; + static const char err_msg[] = "GetErrorString: Bad instance.\n"; IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); if (IPhreeqcPtr) { - return IPhreeqcPtr->GetLastErrorString(); + return IPhreeqcPtr->GetErrorString(); } return err_msg; } const char* -GetLastWarningString(int id) +GetWarningString(int id) { - static const char err_msg[] = "GetLastWarningString: Bad instance.\n"; + static const char err_msg[] = "GetWarningString: Bad instance.\n"; IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); if (IPhreeqcPtr) { - return IPhreeqcPtr->GetLastWarningString(); + return IPhreeqcPtr->GetWarningString(); } return err_msg; } diff --git a/src/fwrap.cpp b/src/fwrap.cpp index 20025e77..cc248ec4 100644 --- a/src/fwrap.cpp +++ b/src/fwrap.cpp @@ -290,15 +290,15 @@ GetSelectedOutputValueF(int *id, int *row, int *col, int *vtype, double* dvalue, } void -OutputLastErrorF(int *id) +OutputErrorF(int *id) { - ::OutputLastError(*id); + ::OutputError(*id); } void -OutputLastWarningF(int *id) +OutputWarningF(int *id) { - ::OutputLastWarning(*id); + ::OutputWarning(*id); } void @@ -363,13 +363,13 @@ DLL_EXPORT int __stdcall UNLOADDATABASE(int *id) { return UnLoadDatabaseF(id); } -DLL_EXPORT void __stdcall OUTPUTLASTERROR(int *id) +DLL_EXPORT void __stdcall OUTPUTERROR(int *id) { - OutputLastErrorF(id); + OutputErrorF(id); } -DLL_EXPORT void __stdcall OUTPUTLASTWARNING(int *id) +DLL_EXPORT void __stdcall OUTPUTWARNING(int *id) { - OutputLastWarningF(id); + OutputWarningF(id); } DLL_EXPORT int __stdcall ACCUMULATELINE(int *id, char *line, unsigned int len) { diff --git a/src/fwrap.h b/src/fwrap.h index 65f6875d..18caaeaa 100644 --- a/src/fwrap.h +++ b/src/fwrap.h @@ -34,8 +34,8 @@ #define GetWarningLineF FC_FUNC (getwarninglinef, GETWARNINGLINEF) #define GetComponentCountF FC_FUNC (getcomponentcountf, GETCOMPONENTCOUNTF) #define GetComponentF FC_FUNC (getcomponentf, GETCOMPONENTF) -#define OutputLastErrorF FC_FUNC (outputlasterrorf, OUTPUTLASTERRORF) -#define OutputLastWarningF FC_FUNC (outputlastwarningf, OUTPUTLASTWARNINGF) +#define OutputErrorF FC_FUNC (outputerrorf, OUTPUTERRORF) +#define OutputWarningF FC_FUNC (outputwarningf, OUTPUTWARNINGF) #define OutputLinesF FC_FUNC (outputlinesf, OUTPUTLINESF) #endif /* FC_FUNC */ @@ -95,9 +95,9 @@ extern "C" { void GetComponentF(int *id, int* n, char* line, unsigned int line_length); - void OutputLastErrorF(int *id); + void OutputErrorF(int *id); - void OutputLastWarningF(int *id); + void OutputWarningF(int *id); void OutputLinesF(int *id); diff --git a/src/fwrap2.cpp b/src/fwrap2.cpp index 6b3aedde..3c93c98e 100644 --- a/src/fwrap2.cpp +++ b/src/fwrap2.cpp @@ -30,13 +30,13 @@ DLL_EXPORT int UNLOADDATABASE(int *id) { return UnLoadDatabaseF(id); } -DLL_EXPORT void OUTPUTLASTERROR(int *id) +DLL_EXPORT void OUTPUTERROR(int *id) { - OutputLastErrorF(id); + OutputErrorF(id); } -DLL_EXPORT void OUTPUTLASTWARNING(int *id) +DLL_EXPORT void OUTPUTWARNING(int *id) { - OutputLastWarningF(id); + OutputWarningF(id); } DLL_EXPORT int ACCUMULATELINE(int *id, char *line, unsigned int len) { diff --git a/src/fwrap3.cpp b/src/fwrap3.cpp index bf87476b..0409d8dd 100644 --- a/src/fwrap3.cpp +++ b/src/fwrap3.cpp @@ -30,13 +30,13 @@ DLL_EXPORT int unloaddatabase_(int *id) { return UnLoadDatabaseF(id); } -DLL_EXPORT void outputlasterror_(int *id) +DLL_EXPORT void outputerror_(int *id) { - OutputLastErrorF(id); + OutputErrorF(id); } -DLL_EXPORT void outputlastwarning_(int *id) +DLL_EXPORT void outputwarning_(int *id) { - OutputLastWarningF(id); + OutputWarningF(id); } DLL_EXPORT int accumulateline_(int *id, char *line, unsigned int len) { diff --git a/tests/test_c.c b/tests/test_c.c index 3a8683c4..0e58fea5 100644 --- a/tests/test_c.c +++ b/tests/test_c.c @@ -4,30 +4,30 @@ int main(int argc, const char* argv[]) { int id; - + id = CreateIPhreeqc(); if (id < 0) { return 1; } - + if (LoadDatabase(id, "phreeqc.dat") != 0) { - OutputLastError(id); + OutputError(id); return 2; } - + if (RunFile(id, "ex1") != 0) { - OutputLastError(id); + OutputError(id); return 3; } - + if (DestroyIPhreeqc(id) != IPQ_OK) { - OutputLastError(id); + OutputError(id); return 4; } - + return 0; } diff --git a/tests/test_cxx.cxx b/tests/test_cxx.cxx index a8080fd0..43882d0e 100644 --- a/tests/test_cxx.cxx +++ b/tests/test_cxx.cxx @@ -8,13 +8,13 @@ main(int argc, const char* argv[]) if (iphreeqc.LoadDatabase("phreeqc.dat") != 0) { - std::cout << iphreeqc.GetLastErrorString(); + std::cout << iphreeqc.GetErrorString(); return 1; } - + if (iphreeqc.RunFile("ex1") != 0) { - std::cout << iphreeqc.GetLastErrorString(); + std::cout << iphreeqc.GetErrorString(); return 2; } diff --git a/tests/test_f.f b/tests/test_f.f index 66f59ded..16e32ed5 100644 --- a/tests/test_f.f +++ b/tests/test_f.f @@ -10,17 +10,17 @@ ENDIF IF (LoadDatabase(id, "phreeqc.dat").NE.0) THEN - CALL OutputLastError(id) + CALL OutputError(id) STOP ENDIF IF (RunFile(id, "ex1").NE.0) THEN - CALL OutputLastError(id) + CALL OutputError(id) STOP ENDIF IF (DestroyIPhreeqc(id).NE.0) THEN - CALL OutputLastError(id) + CALL OutputError(id) STOP ENDIF diff --git a/tests/test_f90.f90 b/tests/test_f90.f90 index 8145caae..241dc932 100644 --- a/tests/test_f90.f90 +++ b/tests/test_f90.f90 @@ -10,17 +10,17 @@ SUBROUTINE F_MAIN ENDIF IF (LoadDatabase(id, "phreeqc.dat").NE.0) THEN - CALL OutputLastError(id) + CALL OutputError(id) STOP ENDIF IF (RunFile(id, "ex1").NE.0) THEN - CALL OutputLastError(id) + CALL OutputError(id) STOP ENDIF IF (DestroyIPhreeqc(id).NE.0) THEN - CALL OutputLastError(id) + CALL OutputError(id) STOP ENDIF diff --git a/unit/GNUmakefile b/unit/GNUmakefile index 786c0c32..df7d45cb 100644 --- a/unit/GNUmakefile +++ b/unit/GNUmakefile @@ -2,7 +2,7 @@ CPPUNIT = /z/parkplace/home/charlton CC = g++ DEFINES = -DNDEBUG -DSWIG_SHARED_OBJ -DPHREEQC_CPP -DPHREEQC_CLASS -DUSE_PHRQ_ALLOC -DCPPUNIT CFLAGS = -Wall -O3 -CPPFLAGS = $(DEFINES) -I$(CPPUNIT)/include -I../include -I../src -I../src/phreeqcpp -I../src/phreeqcpp/phreeqc +CPPFLAGS = $(DEFINES) -I../include -I../src -I../src/phreeqcpp -I../src/phreeqcpp/phreeqc -I$(CPPUNIT)/include TARGET_ARCH = CXX = g++ CXXFLAGS = -Wall diff --git a/unit/TestIPhreeqc.cpp b/unit/TestIPhreeqc.cpp index 10da2cde..8395c028 100644 --- a/unit/TestIPhreeqc.cpp +++ b/unit/TestIPhreeqc.cpp @@ -128,7 +128,7 @@ void TestIPhreeqc::TestLoadDatabaseMissingFile(void) const char expected[] = "ERROR: LoadDatabase: Unable to open:\"missing.file\".\n"; - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); } @@ -170,7 +170,7 @@ void TestIPhreeqc::TestLoadDatabaseWithErrors(void) "ERROR: e-, primary master species for E-, not defined.\n" "ERROR: Calculations terminating due to input errors.\n"; - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); } #if defined(_WIN32) @@ -232,7 +232,7 @@ void TestIPhreeqc::TestRunWithErrors(void) const char expected[] = "ERROR: Numerical method failed on all combinations of convergence parameters\n"; - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); @@ -263,7 +263,7 @@ void TestIPhreeqc::TestRunFile(void) const char expected[] = "ERROR: Numerical method failed on all combinations of convergence parameters\n"; - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL(std::string(expected), std::string(err)); @@ -1011,7 +1011,7 @@ void TestIPhreeqc::TestAddError(void) // make sure initialized to empty // - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(err) ); // make sure initialized to empty @@ -1021,7 +1021,7 @@ void TestIPhreeqc::TestAddError(void) // check 1 // - err = obj.GetLastErrorString(); + err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); // check increment @@ -1031,7 +1031,7 @@ void TestIPhreeqc::TestAddError(void) // check concatenation // - err = obj.GetLastErrorString(); + err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(expected) + std::string(expected2), std::string(err) ); @@ -1041,7 +1041,7 @@ void TestIPhreeqc::TestAddError(void) // make sure back to empty // - err = obj.GetLastErrorString(); + err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(err) ); } @@ -1050,7 +1050,7 @@ void TestIPhreeqc::TestAccumulateLine(void) // TODO } -void TestIPhreeqc::TestOutputLastError(void) +void TestIPhreeqc::TestOutputError(void) { // TODO } @@ -1074,7 +1074,7 @@ void TestIPhreeqc::TestRunNoDatabaseLoaded(void) const char expected[] = "ERROR: RunAccumulated: No database is loaded\n"; - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); } @@ -1554,7 +1554,7 @@ void TestIPhreeqc::TestDatabaseKeyword() "ERROR: Gas not found in PHASES data base, Amm(g).\n" "ERROR: Calculations terminating due to input errors.\n"; - const char* err = obj.GetLastErrorString(); + const char* err = obj.GetErrorString(); CPPUNIT_ASSERT_EQUAL(std::string(expected), std::string(err)); } diff --git a/unit/TestIPhreeqc.h b/unit/TestIPhreeqc.h index 133642d6..59fb3d06 100644 --- a/unit/TestIPhreeqc.h +++ b/unit/TestIPhreeqc.h @@ -9,18 +9,18 @@ class TestIPhreeqc : public CppUnit::TestFixture CPPUNIT_TEST_SUITE( TestIPhreeqc ); CPPUNIT_TEST( TestLoadDatabase ); CPPUNIT_TEST( TestLoadDatabaseString ); - CPPUNIT_TEST( TestLoadDatabaseMissingFile ); - CPPUNIT_TEST( TestLoadDatabaseWithErrors ); + CPPUNIT_TEST( TestLoadDatabaseMissingFile ); + CPPUNIT_TEST( TestLoadDatabaseWithErrors ); CPPUNIT_TEST( TestRun ); - CPPUNIT_TEST( TestRunWithErrors ); + CPPUNIT_TEST( TestRunWithErrors ); CPPUNIT_TEST( TestRunFile ); CPPUNIT_TEST( TestRunString ); CPPUNIT_TEST( TestGetSelectedOutputRowCount ); CPPUNIT_TEST( TestGetSelectedOutputValue ); CPPUNIT_TEST( TestGetSelectedOutputColumnCount ); CPPUNIT_TEST( TestAddError ); - CPPUNIT_TEST( TestAccumulateLine ); - CPPUNIT_TEST( TestOutputLastError ); + CPPUNIT_TEST( TestAccumulateLine ); + CPPUNIT_TEST( TestOutputError ); CPPUNIT_TEST( TestRunWithCallback ); CPPUNIT_TEST( TestRunNoDatabaseLoaded ); CPPUNIT_TEST( TestCase1 ); @@ -61,12 +61,12 @@ public: void TestGetSelectedOutputColumnCount(void); void TestAddError(void); void TestAccumulateLine(void); - void TestOutputLastError(void); + void TestOutputError(void); void TestRunWithCallback(void); void TestRunNoDatabaseLoaded(void); void TestCase1(void); void TestCase2(void); - void TestPrintSelectedOutputFalse(void); + void TestPrintSelectedOutputFalse(void); void TestOutputOnOff(void); void TestErrorOnOff(void); void TestLogOnOff(void); diff --git a/unit/TestIPhreeqcLib.cpp b/unit/TestIPhreeqcLib.cpp index d8be7ee7..1cf7daf3 100644 --- a/unit/TestIPhreeqcLib.cpp +++ b/unit/TestIPhreeqcLib.cpp @@ -67,7 +67,7 @@ void TestIPhreeqcLib::TestLoadDatabase(void) for (int i = 0; i < 10; ++i) { CPPUNIT_ASSERT_EQUAL(true, ::FileExists("phreeqc.dat")); - CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase(n, "phreeqc.dat")); + CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase(n, "phreeqc.dat")); } if (n >= 0) @@ -173,7 +173,7 @@ void TestIPhreeqcLib::TestLoadDatabaseMissingFile(void) const char expected[] = "ERROR: LoadDatabase: Unable to open:\"missing.file\".\n"; - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); @@ -219,7 +219,7 @@ void TestIPhreeqcLib::TestLoadDatabaseWithErrors(void) "ERROR: e-, primary master species for E-, not defined.\n" "ERROR: Calculations terminating due to input errors.\n"; - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); } @@ -286,7 +286,7 @@ void TestIPhreeqcLib::TestRunWithErrors() const char expected[] = "ERROR: Numerical method failed on all combinations of convergence parameters\n"; - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); @@ -326,7 +326,7 @@ void TestIPhreeqcLib::TestRunFile(void) static const char expected[] = "ERROR: Numerical method failed on all combinations of convergence parameters\n"; - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL(std::string(expected), std::string(err)); @@ -1077,7 +1077,7 @@ void TestIPhreeqcLib::TestGetSelectedOutputValue(void) { CPPUNIT_ASSERT_EQUAL(IPQ_OK, ::DestroyIPhreeqc(n)); } - + #if defined(USE_VAR) ::VarClear(&v); #endif @@ -1189,7 +1189,7 @@ void TestIPhreeqcLib::TestAddError(void) // make sure initialized to empty // - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(err) ); // make sure initialized to empty @@ -1199,7 +1199,7 @@ void TestIPhreeqcLib::TestAddError(void) // check 1 // - err = ::GetLastErrorString(n); + err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); // check increment @@ -1209,7 +1209,7 @@ void TestIPhreeqcLib::TestAddError(void) // check concatenation // - err = ::GetLastErrorString(n); + err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(expected) + std::string(expected2), std::string(err) ); @@ -1219,7 +1219,7 @@ void TestIPhreeqcLib::TestAddError(void) // make sure back to empty // - err = ::GetLastErrorString(n); + err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(""), std::string(err) ); if (n >= 0) @@ -1233,7 +1233,7 @@ void TestIPhreeqcLib::TestAccumulateLine(void) // TODO } -void TestIPhreeqcLib::TestOutputLastError(void) +void TestIPhreeqcLib::TestOutputError(void) { // TODO } @@ -1253,7 +1253,7 @@ void TestIPhreeqcLib::TestRunNoDatabaseLoaded(void) const char expected[] = "ERROR: RunAccumulated: No database is loaded\n"; - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL( std::string(expected), std::string(err) ); @@ -1649,7 +1649,7 @@ void TestIPhreeqcLib::TestDatabaseKeyword() "ERROR: Gas not found in PHASES data base, Amm(g).\n" "ERROR: Calculations terminating due to input errors.\n"; - const char* err = ::GetLastErrorString(n); + const char* err = ::GetErrorString(n); CPPUNIT_ASSERT_EQUAL(std::string(exp_errs), std::string(err)); const char *exp_warn = @@ -1659,7 +1659,7 @@ void TestIPhreeqcLib::TestDatabaseKeyword() "WARNING: Could not find element in database, Amm.\n" " Concentration is set to zero.\n"; - const char* warn = ::GetLastWarningString(n); + const char* warn = ::GetWarningString(n); CPPUNIT_ASSERT_EQUAL(std::string(exp_warn), std::string(warn)); if (n >= 0) diff --git a/unit/TestIPhreeqcLib.h b/unit/TestIPhreeqcLib.h index cd39b600..ecc43897 100644 --- a/unit/TestIPhreeqcLib.h +++ b/unit/TestIPhreeqcLib.h @@ -23,7 +23,7 @@ class TestIPhreeqcLib : public CppUnit::TestFixture CPPUNIT_TEST( TestAddError ); CPPUNIT_TEST( TestAccumulateLine ); CPPUNIT_TEST( TestAddError ); - CPPUNIT_TEST( TestOutputLastError ); + CPPUNIT_TEST( TestOutputError ); CPPUNIT_TEST( TestRunWithCallback ); CPPUNIT_TEST( TestRunNoDatabaseLoaded ); CPPUNIT_TEST( TestCase1 ); @@ -65,7 +65,7 @@ public: void TestGetSelectedOutputColumnCount(void); void TestAddError(void); void TestAccumulateLine(void); - void TestOutputLastError(void); + void TestOutputError(void); void TestRunWithCallback(void); void TestRunNoDatabaseLoaded(void); void TestCase1(void);