IPhreeqc 2.18

IPhreeqc.hpp

Go to the documentation of this file.
00001 
00005 #ifndef INC_IPHREEQC_HPP
00006 #define INC_IPHREEQC_HPP
00007 
00008 #include <exception>
00009 #include <list>
00010 #include <vector>
00011 #include <cstdarg>
00012 #include "IPhreeqcCallbacks.h"      /* PFN_PRERUN_CALLBACK, PFN_POSTRUN_CALLBACK, PFN_CATCH_CALLBACK */
00013 #include "Var.h"                    /* VRESULT */
00014 
00015 #if defined(_WINDLL)
00016 #define IPQ_DLL_EXPORT __declspec(dllexport)
00017 #else
00018 #define IPQ_DLL_EXPORT
00019 #endif
00020 
00021 class Phreeqc;
00022 class IErrorReporter;
00023 class CSelectedOutput;
00024 
00031 class IPQ_DLL_EXPORT IPhreeqcStop : std::exception
00032 {
00033 };
00034 
00042 class IPQ_DLL_EXPORT IPhreeqc
00043 {
00044 public:
00051         IPhreeqc(void);
00052 
00056         ~IPhreeqc(void);
00057 
00058 public:
00059 
00067         VRESULT                  AccumulateLine(const char *line);
00068 
00076         size_t                   AddError(const char* error_msg);
00077 
00085         size_t                   AddWarning(const char* warning_msg);
00086 
00091         void                     ClearAccumulatedLines(void);
00092 
00099         const std::string&       GetAccumulatedLines(void);
00100 
00108         const char*              GetComponent(int n);
00109 
00115         size_t                   GetComponentCount(void);
00116 
00123         bool                     GetDumpFileOn(void)const;
00124 
00132         const char*              GetDumpString(void);
00133 
00142         const char*              GetDumpStringLine(int n);
00143 
00150         int                      GetDumpStringLineCount(void)const;
00151 
00158         bool                     GetDumpStringOn(void)const;
00159 
00166         bool                     GetErrorFileOn(void)const;
00167 
00173         const char*              GetErrorString(void);
00174 
00181         const char*              GetErrorStringLine(int n);
00182 
00188         int                      GetErrorStringLineCount(void)const;
00189 
00198         bool                     GetLogFileOn(void)const;
00199 
00206         bool                     GetOutputFileOn(void)const;
00207 
00213         int                      GetSelectedOutputColumnCount(void)const;
00214 
00221         bool                     GetSelectedOutputFileOn(void)const;
00222 
00228         int                      GetSelectedOutputRowCount(void)const;
00229 
00382         VRESULT                  GetSelectedOutputValue(int row, int col, VAR* pVAR);
00383 
00389         const char*              GetWarningString(void);
00390 
00397         const char*              GetWarningStringLine(int n);
00398 
00404         int                      GetWarningStringLineCount(void)const;
00405 
00411         std::list< std::string > ListComponents(void);
00412 
00423         int                      LoadDatabase(const char* filename);
00424 
00433         int                      LoadDatabaseString(const char* input);
00434 
00439         void                     OutputAccumulatedLines(void);
00440 
00445         void                     OutputErrorString(void);
00446 
00451         void                     OutputWarningString(void);
00452 
00462         int                      RunAccumulated(void);
00463 
00472         int                      RunFile(const char* filename);
00473 
00482         int                      RunString(const char* input);
00483 
00491         void                     SetDumpFileOn(bool bValue);
00492 
00500         void                     SetDumpStringOn(bool bValue);
00501 
00508         void                     SetErrorFileOn(bool bValue);
00509 
00518         void                     SetLogFileOn(bool bValue);
00519 
00527         void                     SetOutputFileOn(bool bValue);
00528 
00535         void                     SetSelectedOutputFileOn(bool bValue);
00536 
00537 protected:
00538         static int handler(const int action, const int type, const char *err_str, const int stop, void *cookie, const char *format, va_list args);
00539         int output_handler(const int type, const char *err_str, const int stop, void *cookie, const char *format, va_list args);
00540         int open_handler(const int type, const char *file_name);
00541 
00542         static int module_handler(const int action, const int type, const char *err_str, const int stop, void *cookie, const char *format, va_list args);
00543         int module_isopen_handler(const int type);
00544         int module_open_handler(const int type, const char *file_name);
00545 
00546         int output_isopen(const int type);
00547 
00548         int EndRow(void);
00549         void AddSelectedOutput(const char* name, const char* format, va_list argptr);
00550         void UnLoadDatabase(void);
00551 
00552         void check_database(const char* sz_routine);
00553         void open_output_files(const char* sz_routine);
00554         void do_run(const char* sz_routine, std::istream* pis, FILE* fp, PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie);
00555 
00556         void update_errors(void);
00557 
00558 protected:
00559         bool                       DatabaseLoaded;
00560         bool                       ClearAccumulated;
00561         bool                       UpdateComponents;
00562         bool                       SelectedOutputOn;
00563         bool                       OutputOn;
00564         bool                       LogOn;
00565         bool                       ErrorOn;
00566         bool                       DumpOn;
00567         bool                       DumpStringOn;
00568 
00569 #if defined(_MSC_VER)
00570 /* disable warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' */
00571 #pragma warning(disable:4251)
00572 #endif
00573 
00574         IErrorReporter            *ErrorReporter;
00575         std::string                ErrorString;
00576         std::vector< std::string > ErrorLines;
00577 
00578         IErrorReporter            *WarningReporter;
00579         std::string                WarningString;
00580         std::vector< std::string > WarningLines;
00581 
00582         CSelectedOutput           *SelectedOutput;
00583         std::string                PunchFileName;
00584         std::string                StringInput;
00585 
00586         std::string                DumpString;
00587         std::vector< std::string > DumpLines;
00588 
00589         std::list< std::string >   Components;
00590 
00591 #if defined(_MSC_VER)
00592 /* reset warning C4251 */
00593 #pragma warning(default:4251)
00594 #endif
00595 
00596 private:
00597         Phreeqc* PhreeqcPtr;
00598 
00599 #if defined(CPPUNIT)
00600         friend class TestIPhreeqc;
00601         friend class TestSelectedOutput;
00602 #endif
00603 
00604 private:
00608         IPhreeqc(const IPhreeqc&);
00609 
00613         IPhreeqc& operator=(const IPhreeqc&);
00614 };
00615 
00616 #endif // INC_IPHREEQC_HPP