Compiles as class, debug, and Release.

Requires recompilation of the entire solution for some reason.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3878 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2009-12-08 22:12:42 +00:00
parent 9f4eefd214
commit 3131740cfb
27 changed files with 126 additions and 103 deletions

View File

@ -204,7 +204,7 @@ struct exch_comp *
{
struct exch_comp *exch_comp_ptr =
(struct exch_comp *)
PHRQ_malloc((size_t) (el.size() * sizeof(struct exch_comp)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct exch_comp)));
if (exch_comp_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
@ -603,7 +603,7 @@ cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensi
"Can not mix two exchange components with same formula and different related phases, "
<< this->formula;
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return;
}
else if (this->phase_name.size() != 0)
@ -619,7 +619,7 @@ cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensi
"Can not mix two exchange components with same formula and different related kinetics, "
<< this->formula;
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return;
}
else if (this->rate_name.size() != 0)
@ -636,7 +636,7 @@ cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensi
"Can not mix exchange components related to phase with exchange components related to kinetics, "
<< this->formula;
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return;
}
}

View File

@ -209,7 +209,7 @@ cxxExchange::cxxExchange2exchange(PHREEQC_PTR_ARG)
{
struct exchange *exchange_ptr = P_INSTANCE_POINTER exchange_alloc();
exchange_ptr->description = this->get_description();
exchange_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
exchange_ptr->n_user = this->n_user;
exchange_ptr->n_user_end = this->n_user_end;
exchange_ptr->new_def = FALSE;
@ -390,7 +390,7 @@ cxxExchange::read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser, bool check)
ec.read_raw(P_INSTANCE_COMMA parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is);
CParser reread(P_INSTANCE_COMMA is);
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->exchComps.find(ec.get_formula()) != this->exchComps.end())

View File

@ -109,7 +109,7 @@ cxxNumKeyword()
std::ostringstream oss;
oss << "Can not mix two gas_phases with differing types.";
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return;
}
@ -135,7 +135,7 @@ cxxGasPhase::cxxGasPhaseComp2gas_comp(PHREEQC_PTR_ARG)
int n;
gas_comp_ptr =
(struct gas_comp *)
PHRQ_malloc((size_t)
P_INSTANCE_POINTER PHRQ_malloc((size_t)
(this->gasPhaseComps.size() *
sizeof(struct gas_comp)));
if (gas_comp_ptr == NULL)
@ -163,7 +163,7 @@ cxxGasPhase::cxxGasPhase2gas_phase(PHREEQC_PTR_ARG)
{
struct gas_phase *gas_phase_ptr = P_INSTANCE_POINTER gas_phase_alloc();
gas_phase_ptr->description = this->get_description();
gas_phase_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
gas_phase_ptr->n_user = this->n_user;
gas_phase_ptr->n_user_end = this->n_user_end;
gas_phase_ptr->new_def = FALSE;

View File

@ -131,7 +131,7 @@ cxxISolution::ConvertUnits(PHREEQC_PTR_ARG)
oss << "Could not find gfw, " << iter->second.
get_description();
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
}
}
/*
@ -772,7 +772,7 @@ cxxISolution::ORCH_write_chemistry_alkalinity(std::ostream & chemistry_dat)
oss <<
"pH can not be adjusted to charge balance or phase equilibrium when specifying C or C(4) and Alkalinty.";
error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
}
chemistry_dat << "@solve (pH, 1e-6, lin, 1, Alkalinity, 7)" <<
std::endl;

View File

@ -48,7 +48,7 @@ struct conc *cxxISolutionComp::concarray(std::map <char *, double, CHARSTAR_LESS
// returns list of conc structures
{
struct conc *c;
c = (struct conc *) PHRQ_malloc((size_t) ((totals.size() + 1) * sizeof(struct conc)));
c = (struct conc *) P_INSTANCE_POINTER PHRQ_malloc((size_t) ((totals.size() + 1) * sizeof(struct conc)));
if (c == NULL) malloc_error();
int i = 0;
for (std::map <char *, double, CHARSTAR_LESS>::const_iterator it = totals.begin(); it != totals.end(); ++it) {
@ -78,7 +78,7 @@ cxxISolutionComp::cxxISolutionComp2conc(PHREEQC_PTR_ARG_COMMA const std::map < s
{
struct conc *c;
c = (struct conc *)
PHRQ_malloc((size_t) ((totals.size() + 1) * sizeof(struct conc)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((totals.size() + 1) * sizeof(struct conc)));
if (c == NULL)
P_INSTANCE_POINTER malloc_error();
int i = 0;

View File

@ -67,7 +67,7 @@ struct kinetics_comp *
{
struct kinetics_comp *kinetics_comp_ptr =
(struct kinetics_comp *)
PHRQ_malloc((size_t) (el.size() * sizeof(struct kinetics_comp)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct kinetics_comp)));
if (kinetics_comp_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
@ -98,7 +98,7 @@ struct kinetics_comp *
if ((*it).second.d_params.size() > 0)
{
kinetics_comp_ptr[i].d_params = (double *)
PHRQ_malloc((size_t) ((*it).second.d_params.size() * sizeof(double)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((*it).second.d_params.size() * sizeof(double)));
if (kinetics_comp_ptr[i].d_params == NULL)
P_INSTANCE_POINTER malloc_error();
std::copy((*it).second.d_params.begin(), (*it).second.d_params.end(),

View File

@ -141,7 +141,7 @@ cxxNameDouble::elt_list(PHREEQC_PTR_ARG)
assert(this->type == cxxNameDouble::ND_ELT_MOLES);
struct elt_list *elt_list_ptr =
(struct elt_list *)
PHRQ_malloc((size_t) ((this->size() + 1) * sizeof(struct elt_list)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((this->size() + 1) * sizeof(struct elt_list)));
if (elt_list_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
int i = 0;
@ -172,7 +172,7 @@ cxxNameDouble::master_activity(PHREEQC_PTR_ARG) const
{
master_activity_ptr =
(struct master_activity *)
PHRQ_malloc((size_t)
P_INSTANCE_POINTER PHRQ_malloc((size_t)
(((*this).size() +
1) * sizeof(struct master_activity)));
if (master_activity_ptr == NULL)
@ -193,7 +193,7 @@ cxxNameDouble::master_activity(PHREEQC_PTR_ARG) const
{
master_activity_ptr =
(struct master_activity *)
PHRQ_malloc((size_t)
P_INSTANCE_POINTER PHRQ_malloc((size_t)
(((*this).size()) *
sizeof(struct master_activity)));
if (master_activity_ptr == NULL)
@ -224,7 +224,7 @@ cxxNameDouble::conc(PHREEQC_PTR_ARG) const
struct conc *c;
assert(this->type == cxxNameDouble::ND_ELT_MOLES);
c = (struct conc *)
PHRQ_malloc((size_t) (((*this).size() + 1) * sizeof(struct conc)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (((*this).size() + 1) * sizeof(struct conc)));
if (c == NULL)
P_INSTANCE_POINTER malloc_error();
int i = 0;
@ -256,7 +256,7 @@ cxxNameDouble::name_coef(PHREEQC_PTR_ARG) const
assert(this->type == cxxNameDouble::ND_NAME_COEF);
struct name_coef *name_coef_ptr =
(struct name_coef *)
PHRQ_malloc((size_t) ((this->size()) * sizeof(struct name_coef)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((this->size()) * sizeof(struct name_coef)));
if (name_coef_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
int i = 0;

View File

@ -6,19 +6,22 @@
#include <string> // std::string
class CParser;
extern char *string_duplicate(const char *);
//extern char *string_duplicate(const char *);
class cxxNumKeyword
{
public:
cxxNumKeyword();
virtual ~ cxxNumKeyword();
char *get_description() const
const std::string &get_description() const
{
return string_duplicate(this->description.c_str());
return this->description;
}
//char *get_description() const
//{
// return string_duplicate(this->description.c_str());
//}
void set_description(std::string str)
{
this->description = str;

View File

@ -88,7 +88,7 @@ cxxPPassemblage::cxxPPassemblage2pp_assemblage(PHREEQC_PTR_ARG)
{
struct pp_assemblage *pp_assemblage_ptr = P_INSTANCE_POINTER pp_assemblage_alloc();
pp_assemblage_ptr->description = this->get_description();
pp_assemblage_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
pp_assemblage_ptr->n_user = this->n_user;
pp_assemblage_ptr->n_user_end = this->n_user_end;
pp_assemblage_ptr->new_def = FALSE;
@ -268,7 +268,7 @@ cxxPPassemblage::read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser, bool check)
ec.read_raw(parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is);
CParser reread(P_INSTANCE_COMMA is);
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->ppAssemblageComps.find(ec.get_name()) != this->ppAssemblageComps.end())

View File

@ -74,7 +74,7 @@ cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(PHREEQC_PTR_ARG_COMMA std::m
{
struct pure_phase *pure_phase_ptr =
(struct pure_phase *)
PHRQ_malloc((size_t) (el.size() * sizeof(struct pure_phase)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct pure_phase)));
if (pure_phase_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
@ -497,7 +497,7 @@ cxxPPassemblageComp::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblageComp & addee
"Can not mix two Equilibrium_phases with differing add_formulae., "
<< this->name;
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return;
}
//double si;

View File

@ -5,21 +5,24 @@
#pragma warning(disable : 4786) // disable truncation warning (Only used by debugger)
#endif
#include "Parser.h"
#include "Utils.h"
#include "output.h"
#include <algorithm> // std::transform
#include <map> // std::map
#include <cassert> // assert
#include <iostream> // std::cout std::cerr
#include "Utils.h"
#if defined (PHREEQC_CLASS)
#include "Phreeqc.h"
#endif
#include "Parser.h"
#include "output.h"
extern char *string_hsave(const char *str);
//extern char *string_hsave(const char *str);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CParser::CParser(std::istream & input):m_input_stream(input), m_output_stream(std::cout), m_error_stream(std::cerr),
CParser::CParser(PHREEQC_PTR_ARG_COMMA std::istream & input):m_input_stream(input), m_output_stream(std::cout), m_error_stream(std::cerr),
m_input_error(0),
m_next_keyword(KT_NONE)
{
@ -30,7 +33,7 @@ m_next_keyword(KT_NONE)
accumulate = false;
}
CParser::CParser(std::istream & input, std::ostream & output):m_input_stream(input), m_output_stream(output), m_error_stream(std::cerr),
CParser::CParser(PHREEQC_PTR_ARG_COMMA std::istream & input, std::ostream & output):m_input_stream(input), m_output_stream(output), m_error_stream(std::cerr),
m_input_error(0),
m_next_keyword(KT_NONE)
{
@ -41,7 +44,7 @@ m_next_keyword(KT_NONE)
accumulate = false;
}
CParser::CParser(std::istream & input, std::ostream & output, std::ostream & error):m_input_stream(input), m_output_stream(output), m_error_stream(error),
CParser::CParser(PHREEQC_PTR_ARG_COMMA std::istream & input, std::ostream & output, std::ostream & error):m_input_stream(input), m_output_stream(output), m_error_stream(error),
m_input_error(0),
m_next_keyword(KT_NONE)
{
@ -112,7 +115,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
{
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
output_msg(OUTPUT_MESSAGE, "%s", msg.str().c_str());
PHREEQC_COOKIE output_msg(PHREEQC_NAME_SPACE OUTPUT_MESSAGE, "%s", msg.str().c_str());
}
break;
case EO_KEYWORDS:
@ -120,7 +123,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
{
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
output_msg(OUTPUT_MESSAGE, "%s", msg.str().c_str());
PHREEQC_COOKIE output_msg(PHREEQC_NAME_SPACE OUTPUT_MESSAGE, "%s", msg.str().c_str());
}
break;
@ -129,7 +132,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
{
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
output_msg(OUTPUT_MESSAGE, "%s", msg.str().c_str());
PHREEQC_COOKIE output_msg(PHREEQC_NAME_SPACE OUTPUT_MESSAGE, "%s", msg.str().c_str());
}
break;
}
@ -870,7 +873,7 @@ CParser::get_option(const std::vector < std::string > &opt_list,
int
CParser::error_msg(const char *err_str, ONERROR_TYPE ot)
{
::error_msg(err_str, (int) ot);
ERROR_MESSAGE_QUALIFIER error_msg(err_str, (int) ot);
m_error_stream << "ERROR: " << err_str << "\n";
m_error_stream.flush();
@ -1323,3 +1326,9 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
}
return (j);
}
int CParser::
incr_input_error()
{
++ ERROR_MESSAGE_QUALIFIER input_error;
return ++m_input_error;
}

View File

@ -1,20 +1,31 @@
#if !defined(PARSER_H_INCLUDED)
#define PARSER_H_INCLUDED
extern int input_error;
#include <string> // std::string
#include <map> // std::map
#include <vector> // std::vector
#include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream
#include <istream> // std::istream
#include "Phreeqc_class.h"
#if defined (PHREEQC_CLASS)
class Phreeqc;
#define PHREEQC_NAME_SPACE Phreeqc::
#define PHREEQC_COOKIE this->p_instance->
#define ERROR_MESSAGE_QUALIFIER this->p_instance->
#else
#define PHREEQC_NAME_SPACE ::
#define PHREEQC_COOKIE
#define ERROR_MESSAGE_QUALIFIER ::
extern int input_error;
#endif
class CParser
{
public:
CParser(std::istream & input);
CParser(std::istream & input, std::ostream & output);
CParser(std::istream & input, std::ostream & output,
CParser(PHREEQC_PTR_ARG_COMMA std::istream & input);
CParser(PHREEQC_PTR_ARG_COMMA std::istream & input, std::ostream & output);
CParser(PHREEQC_PTR_ARG_COMMA std::istream & input, std::ostream & output,
std::ostream & error);
virtual ~ CParser();
@ -166,11 +177,7 @@ class CParser
{
return m_line_iss;
}
int incr_input_error()
{
++::input_error;
return ++m_input_error;
}
int incr_input_error();
std::ostream & get_output()
{
return m_output_stream;
@ -302,7 +309,9 @@ class CParser
ECHO_OPTION echo_file;
std::string accumulated;
bool accumulate;
//int const &input_error_parser;
#if defined(PHREEQC_CLASS)
Phreeqc * p_instance;
#endif
};
// Global functions

View File

@ -83,11 +83,11 @@ cxxReaction::cxxReaction2irrev(PHREEQC_PTR_ARG)
//
{
struct irrev *irrev_ptr;
irrev_ptr = (struct irrev *) PHRQ_malloc(sizeof(struct irrev));
irrev_ptr = (struct irrev *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct irrev));
if (irrev_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
irrev_ptr->description = this->get_description();
irrev_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
irrev_ptr->n_user = this->n_user;
irrev_ptr->n_user_end = this->n_user_end;
@ -108,7 +108,7 @@ cxxReaction::cxxReaction2irrev(PHREEQC_PTR_ARG)
{
irrev_ptr->steps =
(double *)
PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
if (irrev_ptr->steps == NULL)
P_INSTANCE_POINTER malloc_error();
std::copy(this->steps.begin(), this->steps.end(), irrev_ptr->steps);

View File

@ -86,7 +86,7 @@ read_solution_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -179,7 +179,7 @@ read_exchange_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -273,7 +273,7 @@ read_surface_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -368,7 +368,7 @@ read_equilibrium_phases_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -464,7 +464,7 @@ read_kinetics_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -559,7 +559,7 @@ read_solid_solutions_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -656,7 +656,7 @@ read_gas_phase_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -750,7 +750,7 @@ read_reaction_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -845,7 +845,7 @@ read_mix_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -940,7 +940,7 @@ read_temperature_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
if (pr.echo_input == FALSE)
@ -1017,7 +1017,7 @@ read_dump(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1069,7 +1069,7 @@ read_delete(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1121,7 +1121,7 @@ read_run_cells(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1191,7 +1191,7 @@ read_solution_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1278,7 +1278,7 @@ read_equilibrium_phases_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1366,7 +1366,7 @@ read_exchange_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1454,7 +1454,7 @@ read_surface_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1541,7 +1541,7 @@ read_solid_solutions_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1627,7 +1627,7 @@ read_gas_phase_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started
@ -1713,7 +1713,7 @@ read_kinetics_modify(void)
return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err);
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
assert(!reading_database());
//For testing, need to read line to get started

View File

@ -86,7 +86,7 @@ cxxSSassemblage::cxxSSassemblage2s_s_assemblage(PHREEQC_PTR_ARG)
{
struct s_s_assemblage *s_s_assemblage_ptr = P_INSTANCE_POINTER s_s_assemblage_alloc();
s_s_assemblage_ptr->description = this->get_description();
s_s_assemblage_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
s_s_assemblage_ptr->n_user = this->n_user;
s_s_assemblage_ptr->n_user_end = this->n_user_end;
s_s_assemblage_ptr->new_def = FALSE;
@ -243,7 +243,7 @@ cxxSSassemblage::read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser, bool check)
ec.read_raw(P_INSTANCE_COMMA parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is);
CParser reread(P_INSTANCE_COMMA is);
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->ssAssemblageSSs.find(ec.get_name()) != this->ssAssemblageSSs.end())

View File

@ -87,7 +87,7 @@ cxxSSassemblageSS::cxxSSassemblageSS2s_s(PHREEQC_PTR_ARG_COMMA std::map < std::s
// generate s_s structures
//
struct s_s *s_s_ptr =
(struct s_s *) PHRQ_malloc((size_t) (el.size() * sizeof(struct s_s)));
(struct s_s *) P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct s_s)));
if (s_s_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
int j = 0;
@ -129,7 +129,7 @@ cxxSSassemblageSS::cxxSSassemblageSS2s_s(PHREEQC_PTR_ARG_COMMA std::map < std::s
int n;
struct s_s_comp *s_s_comp_ptr =
(struct s_s_comp *)
PHRQ_malloc((size_t)
P_INSTANCE_POINTER PHRQ_malloc((size_t)
((*it).second.comps.size() * sizeof(struct s_s_comp)));
if (s_s_comp_ptr == NULL)
P_INSTANCE_POINTER malloc_error();

View File

@ -122,7 +122,7 @@ cxxNumKeyword()
sprintf(P_INSTANCE_POINTER error_string,
"Solution %d not found in mix_cxxSolutions.", it->first);
P_INSTANCE_POINTER error_msg(P_INSTANCE_POINTER error_string, CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
}
else
{
@ -284,7 +284,7 @@ cxxSolution::cxxSolution2solution(PHREEQC_PTR_ARG)
struct solution *solution_ptr = P_INSTANCE_POINTER solution_alloc();
solution_ptr->description = this->get_description();
solution_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
solution_ptr->n_user = this->n_user;
solution_ptr->n_user_end = this->n_user_end;
solution_ptr->new_def = FALSE;
@ -1389,7 +1389,7 @@ cxxSolution::mpi_send(int task_number)
/* int count_isotopes; */
/* struct isotope *isotopes; */
if (input_error > 0)
if (P_INSTANCE_POINTER input_error > 0)
{
std::string errstr("Stopping due to errors\n");
error_msg(errstr.c_str(), STOP);
@ -1405,7 +1405,7 @@ cxxSolution::mpi_send(int task_number)
MPI_Pack_size((int) doubles.size(), MPI_DOUBLE, MPI_COMM_WORLD,
&member_size);
max_size += member_size + 10;
buffer = PHRQ_malloc(max_size);
buffer = P_INSTANCE_POINTER PHRQ_malloc(max_size);
if (buffer == NULL)
malloc_error();
/*
@ -1453,7 +1453,7 @@ cxxSolution::mpi_recv(int task_number)
MPI_Recv(&max_size, 1, MPI_INT, task_number, 0, MPI_COMM_WORLD,
&mpi_status);
void *buffer = PHRQ_malloc(max_size);
void *buffer = P_INSTANCE_POINTER PHRQ_malloc(max_size);
if (buffer == NULL)
malloc_error();
/*

View File

@ -49,7 +49,7 @@ cxxSolutionIsotope::list2isotope(PHREEQC_PTR_ARG_COMMA std::list < cxxSolutionIs
{
iso =
(struct isotope *)
PHRQ_malloc((size_t) ((isolist.size()) * sizeof(struct isotope)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((isolist.size()) * sizeof(struct isotope)));
if (iso == NULL)
P_INSTANCE_POINTER malloc_error();
int i = 0;

View File

@ -96,7 +96,7 @@ cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope(PHREEQC_PTR_ARG)
{
iso =
(struct isotope *)
PHRQ_malloc((size_t) ((this->size()) * sizeof(struct isotope)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((this->size()) * sizeof(struct isotope)));
if (iso == NULL)
P_INSTANCE_POINTER malloc_error();
int i = 0;

View File

@ -1050,7 +1050,7 @@ cxxStorageBin::mix_cxxSolutions(cxxMix & mixmap)
sprintf(error_string,
"Solution %d not found in mix_cxxSolutions.", it->first);
error_msg(error_string, CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return (NULL);
}
intensive = it->second / extensive;
@ -1066,7 +1066,7 @@ cxxStorageBin::cxxStorageBin2system(PHREEQC_PTR_ARG_COMMA int n)
//
{
struct system *system_ptr =
(struct system *) PHRQ_malloc(sizeof(struct system));
(struct system *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct system));
if (system_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
@ -1249,7 +1249,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
MPI_Pack_size((int) doubles.size(), MPI_DOUBLE, MPI_COMM_WORLD,
&member_size);
max_size += member_size + 10;
void *buffer = PHRQ_malloc(max_size);
void *buffer = P_INSTANCE_POINTER PHRQ_malloc(max_size);
if (buffer == NULL)
malloc_error();
@ -1303,7 +1303,7 @@ cxxStorageBin::mpi_recv(int task_number)
MPI_Recv(&max_size, 1, MPI_INT, task_number, 0, MPI_COMM_WORLD,
&mpi_status);
void *buffer = PHRQ_malloc(max_size);
void *buffer = P_INSTANCE_POINTER PHRQ_malloc(max_size);
if (buffer == NULL)
malloc_error();
/*
@ -1447,7 +1447,7 @@ cxxStorageBin::mix_cxxExchange(cxxMix & mixmap)
sprintf(error_string, "Exchange %d not found in mix_cxxExchange.",
it_mix->first);
error_msg(error_string, CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return (NULL);
}
new_exch_ptr->set_pitzer_exchange_gammas(old_exch_ptr->
@ -1468,7 +1468,7 @@ cxxStorageBin::mix_cxxExchange(cxxMix & mixmap)
sprintf(error_string, "Exchange %d not found in mix_cxxExchange.",
it_mix->first);
error_msg(error_string, CONTINUE);
input_error++;
P_INSTANCE_POINTER input_error++;
return (NULL);
}
// Add exchange components to vector ec_vector

View File

@ -150,7 +150,7 @@ cxxSurface::cxxSurface2surface(PHREEQC_PTR_ARG)
{
struct surface *surface_ptr = P_INSTANCE_POINTER surface_alloc();
surface_ptr->description = this->get_description();
surface_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
surface_ptr->n_user = this->n_user;
surface_ptr->n_user_end = this->n_user_end;
surface_ptr->new_def = FALSE;
@ -542,7 +542,7 @@ cxxSurface::read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser, bool check)
ec.read_raw(P_INSTANCE_COMMA parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is);
CParser reread(P_INSTANCE_COMMA is);
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->surfaceComps.find(ec.get_formula()) != this->surfaceComps.end())
@ -595,7 +595,7 @@ cxxSurface::read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser, bool check)
ec.read_raw(P_INSTANCE_COMMA parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is);
CParser reread(P_INSTANCE_COMMA is);
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->surfaceCharges.find(ec.get_name()) != this->surfaceCharges.end())

View File

@ -91,7 +91,7 @@ cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(PHREEQC_PTR_ARG_COMMA std::map
{
struct surface_charge *surf_charge_ptr =
(struct surface_charge *)
PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_charge)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_charge)));
if (surf_charge_ptr == NULL)
P_INSTANCE_POINTER malloc_error();

View File

@ -110,7 +110,7 @@ struct surface_comp *
{
struct surface_comp *surf_comp_ptr =
(struct surface_comp *)
PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_comp)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_comp)));
if (surf_comp_ptr == NULL)
P_INSTANCE_POINTER malloc_error();

View File

@ -84,7 +84,7 @@ cxxTemperature::cxxTemperature2temperature(PHREEQC_PTR_ARG)
if (temperature_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
temperature_ptr->description = this->get_description();
temperature_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
temperature_ptr->n_user = this->n_user;
temperature_ptr->n_user_end = this->n_user_end;
@ -94,7 +94,7 @@ cxxTemperature::cxxTemperature2temperature(PHREEQC_PTR_ARG)
{
temperature_ptr->t =
(double *)
PHRQ_malloc((size_t) (this->temps.size() * sizeof(double)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (this->temps.size() * sizeof(double)));
if (temperature_ptr->t == NULL)
P_INSTANCE_POINTER malloc_error();
std::copy(this->temps.begin(), this->temps.end(), temperature_ptr->t);

View File

@ -115,7 +115,7 @@ cxxKinetics::cxxKinetics2kinetics(PHREEQC_PTR_ARG)
{
struct kinetics *kinetics_ptr = P_INSTANCE_POINTER kinetics_alloc();
kinetics_ptr->description = this->get_description();
kinetics_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
kinetics_ptr->n_user = this->n_user;
kinetics_ptr->n_user_end = this->n_user_end;
kinetics_ptr->step_divide = this->step_divide;
@ -142,7 +142,7 @@ cxxKinetics::cxxKinetics2kinetics(PHREEQC_PTR_ARG)
{
kinetics_ptr->steps =
(double *)
PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
P_INSTANCE_POINTER PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
if (kinetics_ptr->steps == NULL)
P_INSTANCE_POINTER malloc_error();
std::copy(this->steps.begin(), this->steps.end(),
@ -417,7 +417,7 @@ cxxKinetics::read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser, bool check)
ec.read_raw(P_INSTANCE_COMMA parser, false);
parser.set_accumulate(false);
std::istringstream is(parser.get_accumulated());
CParser reread(is);
CParser reread(P_INSTANCE_COMMA is);
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);

View File

@ -67,11 +67,11 @@ cxxMix::cxxMix2mix(PHREEQC_PTR_ARG)
//
{
struct mix *mix_ptr;
mix_ptr = (struct mix *) PHRQ_malloc(sizeof(struct mix));
mix_ptr = (struct mix *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct mix));
if (mix_ptr == NULL)
P_INSTANCE_POINTER malloc_error();
mix_ptr->description = this->get_description();
mix_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
mix_ptr->n_user = this->n_user;
mix_ptr->n_user_end = this->n_user_end;
@ -82,7 +82,7 @@ cxxMix::cxxMix2mix(PHREEQC_PTR_ARG)
int i = 0;
mix_ptr->comps =
(struct mix_comp *)
PHRQ_malloc((size_t)
P_INSTANCE_POINTER PHRQ_malloc((size_t)
(this->mixComps.size() * sizeof(struct mix_comp)));
if (mix_ptr->comps == NULL)
P_INSTANCE_POINTER malloc_error();

View File

@ -8,6 +8,7 @@
#define PHREEQC_PTR_ARG_COMMA
#define PHREEQC_THIS
#define PHREEQC_THIS_COMMA
#define PHREEQC_NAME_SPACE ::
#else
#define P_INSTANCE p_instance
#define P_INSTANCE_COMMA p_instance,
@ -16,6 +17,7 @@
#define PHREEQC_PTR_ARG_COMMA Phreeqc *p_instance,
#define PHREEQC_THIS this
#define PHREEQC_THIS_COMMA this,
#define PHREEQC_NAME_SPACE Phreeqc::
#endif
#endif /* _INC_PHREEQC_CLASS_H */
//#include "Phreeqc_class.h"