From 13ca055192293f0b6a425828c3e9bfbe62dc67e5 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 25 Aug 2020 12:27:15 -0600 Subject: [PATCH 1/2] added googletest and fixed some minor bugs --- common/PHRQ_io.h | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/common/PHRQ_io.h b/common/PHRQ_io.h index 8c469248..f020b2eb 100644 --- a/common/PHRQ_io.h +++ b/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 07717b1e931b4526f3c33921cd872577599410b6 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 15 Sep 2020 20:29:41 -0600 Subject: [PATCH 2/2] added src/phreeqcpp/common/PHRQ_exports.h --- Makefile.am | 1 + NameDouble.h | 6 +----- common/PHRQ_base.h | 6 +----- common/PHRQ_exports.h | 14 ++++++++++++++ common/PHRQ_io.h | 6 +----- 5 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 common/PHRQ_exports.h diff --git a/Makefile.am b/Makefile.am index b7651924..a568ea8c 100644 --- a/Makefile.am +++ b/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/NameDouble.h b/NameDouble.h index 7df7e53b..9c7c12ba 100644 --- a/NameDouble.h +++ b/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/common/PHRQ_base.h b/common/PHRQ_base.h index 037d0881..26ac25d6 100644 --- a/common/PHRQ_base.h +++ b/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/common/PHRQ_exports.h b/common/PHRQ_exports.h new file mode 100644 index 00000000..d936a60c --- /dev/null +++ b/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/common/PHRQ_io.h b/common/PHRQ_io.h index f020b2eb..25bfec8a 100644 --- a/common/PHRQ_io.h +++ b/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