From dd058e3bec3f8975979777ee24b8769dd94cdb46 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 25 Aug 2020 12:17:54 -0600 Subject: [PATCH 1/3] implemented Get/SetErrorOn --- IPhreeqc.cpp | 15 ++++++++++++++ IPhreeqc.f.inc | 2 ++ IPhreeqc.f90.inc | 17 ++++++++++++++++ IPhreeqc.h | 44 ++++++++++++++++++++++++++++++++++++++++ IPhreeqc.hpp | 19 ++++++++++++++++- IPhreeqcF.f | 21 +++++++++++++++++++ IPhreeqcLib.cpp | 30 +++++++++++++++++++++++++++ IPhreeqc_interface.F90 | 36 ++++++++++++++++++++++++++++++++ IPhreeqc_interface_F.cpp | 12 +++++++++++ IPhreeqc_interface_F.h | 4 ++++ fimpl.h | 8 ++++++++ fwrap.cpp | 12 +++++++++++ fwrap.h | 4 ++++ 13 files changed, 223 insertions(+), 1 deletion(-) diff --git a/IPhreeqc.cpp b/IPhreeqc.cpp index b24c4cb2..426465f5 100644 --- a/IPhreeqc.cpp +++ b/IPhreeqc.cpp @@ -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; diff --git a/IPhreeqc.f.inc b/IPhreeqc.f.inc index 97ead48c..ebe942f8 100644 --- a/IPhreeqc.f.inc +++ b/IPhreeqc.f.inc @@ -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 diff --git a/IPhreeqc.f90.inc b/IPhreeqc.f90.inc index 1d6d2ade..77cc6a35 100644 --- a/IPhreeqc.f90.inc +++ b/IPhreeqc.f90.inc @@ -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 diff --git a/IPhreeqc.h b/IPhreeqc.h index cf60f878..93adac90 100644 --- a/IPhreeqc.h +++ b/IPhreeqc.h @@ -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 + * + *
+ *  FUNCTION GetErrorOn(ID)
+ *    INTEGER(KIND=4),  INTENT(IN)  :: ID
+ *    LOGICAL(KIND=4)               :: GetErrorOn
+ *  END FUNCTION GetErrorOn
+ *  
+ *
+ * @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 + * + *
+ *  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
+ *  
+ *
+ * @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 diff --git a/IPhreeqc.hpp b/IPhreeqc.hpp index c6111f30..ce668b40 100644 --- a/IPhreeqc.hpp +++ b/IPhreeqc.hpp @@ -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 phreeqc.id.err (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. diff --git a/IPhreeqcF.f b/IPhreeqcF.f index c5586dc6..856700ba 100644 --- a/IPhreeqcF.f +++ b/IPhreeqcF.f @@ -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 diff --git a/IPhreeqcLib.cpp b/IPhreeqcLib.cpp index 2cd59d89..b57755ab 100644 --- a/IPhreeqcLib.cpp +++ b/IPhreeqcLib.cpp @@ -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) { diff --git a/IPhreeqc_interface.F90 b/IPhreeqc_interface.F90 index 96ac3cf7..6c726c83 100644 --- a/IPhreeqc_interface.F90 +++ b/IPhreeqc_interface.F90 @@ -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 diff --git a/IPhreeqc_interface_F.cpp b/IPhreeqc_interface_F.cpp index 8e406e82..ab1125de 100644 --- a/IPhreeqc_interface_F.cpp +++ b/IPhreeqc_interface_F.cpp @@ -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) { diff --git a/IPhreeqc_interface_F.h b/IPhreeqc_interface_F.h index 660dcd38..d1c3e2a3 100644 --- a/IPhreeqc_interface_F.h +++ b/IPhreeqc_interface_F.h @@ -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); diff --git a/fimpl.h b/fimpl.h index e01095f6..de9eb214 100644 --- a/fimpl.h +++ b/fimpl.h @@ -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); diff --git a/fwrap.cpp b/fwrap.cpp index ae23e5dd..2c096f93 100644 --- a/fwrap.cpp +++ b/fwrap.cpp @@ -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) { diff --git a/fwrap.h b/fwrap.h index 0f2740f5..c95758d0 100644 --- a/fwrap.h +++ b/fwrap.h @@ -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); From 2760ad0c366410305860278b6a924cb53e23670d Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 25 Aug 2020 12:27:15 -0600 Subject: [PATCH 2/3] added googletest and fixed some minor bugs --- CSelectedOutput.hxx | 8 ++++++- phreeqcpp/common/PHRQ_io.h | 46 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/CSelectedOutput.hxx b/CSelectedOutput.hxx index fd1ab794..e5d20ef3 100644 --- a/CSelectedOutput.hxx +++ b/CSelectedOutput.hxx @@ -15,7 +15,13 @@ #include #include "CVar.hxx" -class CSelectedOutput +#if defined(_WINDLL) +#define IPQ_DLL_EXPORT __declspec(dllexport) +#else +#define IPQ_DLL_EXPORT +#endif + +class IPQ_DLL_EXPORT CSelectedOutput { public: CSelectedOutput(void); diff --git a/phreeqcpp/common/PHRQ_io.h b/phreeqcpp/common/PHRQ_io.h index 8c469248..f020b2eb 100644 --- a/phreeqcpp/common/PHRQ_io.h +++ b/phreeqcpp/common/PHRQ_io.h @@ -44,8 +44,8 @@ public: static void safe_close(std::ostream **stream_ptr); static void safe_close(FILE **file_ptr); void close_ostreams(void); - void Set_io_error_count(int i) {this->io_error_count = i;}; - int Get_io_error_count(void) {return this->io_error_count;}; + void Set_io_error_count(int i) {this->io_error_count = i;}; + int Get_io_error_count(void)const {return this->io_error_count;}; // istreams @@ -65,7 +65,7 @@ public: void Set_output_ostream(std::ostream * out) {this->output_ostream = out;}; std::ostream *Get_output_ostream(void) {return this->output_ostream;}; void Set_output_on(bool tf) {this->output_on = tf;}; - bool Get_output_on(void) {return this->output_on;}; + bool Get_output_on(void)const {return this->output_on;}; // log_ostream virtual bool log_open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out); @@ -75,7 +75,7 @@ public: void Set_log_ostream(std::ostream * out) {this->log_ostream = out;} std::ostream *Get_log_ostream(void) {return this->log_ostream;} void Set_log_on(bool tf) {this->log_on = tf;} - bool Get_log_on(void) {return this->log_on;} + bool Get_log_on(void)const {return this->log_on;} // punch_ostream virtual bool punch_open(const char *file_name, std::ios_base::openmode mode = std::ios_base::out, int n_user = 1); @@ -94,19 +94,19 @@ public: void error_close(void); virtual void error_msg(const char * str, bool stop=false); void Set_error_ostream(std::ostream * out) {this->error_ostream = out;} - std::ostream *Get_error_ostream(void) {return this->error_ostream;} + std::ostream *Get_error_ostream(void)const {return this->error_ostream;} void Set_error_on(bool tf) {this->error_on = tf;} - bool Get_error_on(void) {return this->error_on;} + bool Get_error_on(void)const {return this->error_on;} virtual void warning_msg(const char *err_str); #else virtual bool error_open(const char *file_name, const char * mode = "w"); void error_flush(void); void error_close(void); virtual void error_msg(const char * str, bool stop=false); - void Set_error_file(FILE * out) {this->error_file = out;} - FILE *Get_error_file(void) {return this->error_file;} + void Set_error_file(FILE * out) {this->error_file = out;} + FILE *Get_error_file(void)const {return this->error_file;} void Set_error_on(bool tf) {this->error_on = tf;} - bool Get_error_on(void) {return this->error_on;} + bool Get_error_on(void)const {return this->error_on;} virtual void warning_msg(const char *err_str); #endif @@ -118,7 +118,7 @@ public: void Set_dump_ostream(std::ostream * out) {this->dump_ostream = out;}; std::ostream *Get_dump_ostream(void) {return this->dump_ostream;}; void Set_dump_on(bool tf) {this->dump_on = tf;}; - bool Get_dump_on(void) {return this->dump_on;}; + bool Get_dump_on(void)const {return this->dump_on;}; // fpunchf virtual void fpunchf(const char *name, const char *format, double d); @@ -130,17 +130,17 @@ public: virtual void screen_msg(const char * str); void Set_screen_on(bool tf) {this->screen_on = tf;}; - bool Get_screen_on(void) {return this->screen_on;}; + bool Get_screen_on(void)const {return this->screen_on;}; // input methods virtual int getc(void); virtual LINE_TYPE get_line(void); virtual LINE_TYPE get_logical_line(void); bool check_key(std::string::iterator begin, std::string::iterator end); - std::string & Get_m_line() {return m_line;} - std::string & Get_m_line_save() {return m_line_save;} - std::string & Get_accumulated() {return accumulated;} - LINE_TYPE Get_m_line_type() {return m_line_type;}; + std::string & Get_m_line() {return m_line;} + std::string & Get_m_line_save() {return m_line_save;} + std::string & Get_accumulated() {return accumulated;} + LINE_TYPE Get_m_line_type()const {return m_line_type;}; void Set_accumulate(bool tf) { if (tf) @@ -149,7 +149,7 @@ public: } this->accumulate = tf; } - Keywords::KEYWORDS Get_m_next_keyword() const {return m_next_keyword;} + Keywords::KEYWORDS Get_m_next_keyword() const {return m_next_keyword;} // echo enum ECHO_OPTION @@ -158,16 +158,16 @@ public: ECHO_OUTPUT }; virtual void echo_msg(const char * str); - void Set_echo_on(bool tf) {this->echo_on = tf;}; - bool Get_echo_on(void) {return this->echo_on;}; - void Set_echo_destination(ECHO_OPTION eo) {this->echo_destination = eo;}; - ECHO_OPTION Get_echo_destination(void) {return this->echo_destination;}; + void Set_echo_on(bool tf) {this->echo_on = tf;}; + bool Get_echo_on(void)const {return this->echo_on;}; + void Set_echo_destination(ECHO_OPTION eo) {this->echo_destination = eo;}; + ECHO_OPTION Get_echo_destination(void)const {return this->echo_destination;}; // data protected: - std::ostream *output_ostream; - std::ostream *log_ostream; - std::ostream *punch_ostream; + std::ostream *output_ostream; + std::ostream *log_ostream; + std::ostream *punch_ostream; #ifdef ERROR_OSTREAM std::ostream *error_ostream; #else From 0b0fced395d40a23a1eb8514688a812c13e4db02 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 15 Sep 2020 20:29:41 -0600 Subject: [PATCH 3/3] added src/phreeqcpp/common/PHRQ_exports.h --- CSelectedOutput.hxx | 6 +----- IPhreeqc.hpp | 6 +----- Makefile.am | 1 + Var.h | 6 +----- phreeqcpp/Makefile.am | 1 + phreeqcpp/NameDouble.h | 6 +----- phreeqcpp/common/PHRQ_base.h | 6 +----- phreeqcpp/common/PHRQ_exports.h | 14 ++++++++++++++ phreeqcpp/common/PHRQ_io.h | 6 +----- 9 files changed, 22 insertions(+), 30 deletions(-) create mode 100644 phreeqcpp/common/PHRQ_exports.h diff --git a/CSelectedOutput.hxx b/CSelectedOutput.hxx index e5d20ef3..c15e1240 100644 --- a/CSelectedOutput.hxx +++ b/CSelectedOutput.hxx @@ -15,11 +15,7 @@ #include #include "CVar.hxx" -#if defined(_WINDLL) -#define IPQ_DLL_EXPORT __declspec(dllexport) -#else -#define IPQ_DLL_EXPORT -#endif +#include "PHRQ_exports.h" class IPQ_DLL_EXPORT CSelectedOutput { diff --git a/IPhreeqc.hpp b/IPhreeqc.hpp index ce668b40..22bdf150 100644 --- a/IPhreeqc.hpp +++ b/IPhreeqc.hpp @@ -14,11 +14,7 @@ #include "Var.h" /* VRESULT */ #include "PHRQ_io.h" -#if defined(_WINDLL) -#define IPQ_DLL_EXPORT __declspec(dllexport) -#else -#define IPQ_DLL_EXPORT -#endif +#include "PHRQ_exports.h" class Phreeqc; class IErrorReporter; diff --git a/Makefile.am b/Makefile.am index 9ca76526..bd994e65 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,6 +48,7 @@ libiphreeqc_la_SOURCES=\ phreeqcpp/common/Parser.h\ phreeqcpp/common/PHRQ_base.cxx\ phreeqcpp/common/PHRQ_base.h\ + phreeqcpp/common/PHRQ_exports.h\ phreeqcpp/common/PHRQ_io.cpp\ phreeqcpp/common/PHRQ_io.h\ phreeqcpp/common/phrqtype.h\ diff --git a/Var.h b/Var.h index 39ae1e71..0169bd16 100644 --- a/Var.h +++ b/Var.h @@ -6,11 +6,7 @@ #ifndef __VAR_H_INC #define __VAR_H_INC -#if defined(_WINDLL) -#define IPQ_DLL_EXPORT __declspec(dllexport) -#else -#define IPQ_DLL_EXPORT -#endif +#include "PHRQ_exports.h" #if defined(R_SO) || defined(NO_NAMELESS_UNION) #define VAR_UNION_NAME u diff --git a/phreeqcpp/Makefile.am b/phreeqcpp/Makefile.am index b7651924..a568ea8c 100644 --- a/phreeqcpp/Makefile.am +++ b/phreeqcpp/Makefile.am @@ -24,6 +24,7 @@ phreeqc_SOURCES=\ common/Parser.h\ common/PHRQ_base.cxx\ common/PHRQ_base.h\ + common/PHRQ_exports.h\ common/PHRQ_io.cpp\ common/PHRQ_io.h\ common/phrqtype.h\ diff --git a/phreeqcpp/NameDouble.h b/phreeqcpp/NameDouble.h index 7df7e53b..9c7c12ba 100644 --- a/phreeqcpp/NameDouble.h +++ b/phreeqcpp/NameDouble.h @@ -1,11 +1,7 @@ #if !defined(NAMEDOUBLE_H_INCLUDED) #define NAMEDOUBLE_H_INCLUDED -#if defined(_WINDLL) -#define IPQ_DLL_EXPORT __declspec(dllexport) -#else -#define IPQ_DLL_EXPORT -#endif +#include "PHRQ_exports.h" #include // assert #include // std::map diff --git a/phreeqcpp/common/PHRQ_base.h b/phreeqcpp/common/PHRQ_base.h index 037d0881..26ac25d6 100644 --- a/phreeqcpp/common/PHRQ_base.h +++ b/phreeqcpp/common/PHRQ_base.h @@ -3,11 +3,7 @@ #include -#if defined(_WINDLL) -#define IPQ_DLL_EXPORT __declspec(dllexport) -#else -#define IPQ_DLL_EXPORT -#endif +#include "PHRQ_exports.h" class PHRQ_io; class IPQ_DLL_EXPORT PHRQ_base diff --git a/phreeqcpp/common/PHRQ_exports.h b/phreeqcpp/common/PHRQ_exports.h new file mode 100644 index 00000000..d936a60c --- /dev/null +++ b/phreeqcpp/common/PHRQ_exports.h @@ -0,0 +1,14 @@ +#ifndef INC_PHRQ_EXPORTS_H +#define INC_PHRQ_EXPORTS_H + +#if defined(_WINDLL) +# ifdef IPhreeqc_EXPORTS +# define IPQ_DLL_EXPORT __declspec(dllexport) +# else +# define IPQ_DLL_EXPORT __declspec(dllimport) +# endif +#else +# define IPQ_DLL_EXPORT +#endif + +#endif // INC_PHRQ_EXPORTS_H diff --git a/phreeqcpp/common/PHRQ_io.h b/phreeqcpp/common/PHRQ_io.h index f020b2eb..25bfec8a 100644 --- a/phreeqcpp/common/PHRQ_io.h +++ b/phreeqcpp/common/PHRQ_io.h @@ -1,11 +1,7 @@ #ifndef _PHRQIO_H #define _PHRQIO_H -#if defined(_WINDLL) -#define IPQ_DLL_EXPORT __declspec(dllexport) -#else -#define IPQ_DLL_EXPORT -#endif +#include "PHRQ_exports.h" #include #include