Converted phrq_io to pointer rather than an instance.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5667 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2011-09-30 20:05:35 +00:00
parent e89dd5938c
commit d0075d7c4d
2 changed files with 69 additions and 66 deletions

View File

@ -13,6 +13,8 @@
Phreeqc::Phreeqc(void)
{
phrq_io = new PHRQ_io;
phast = FALSE;
s_pTail = NULL;
user_database = NULL;
@ -386,8 +388,8 @@ Phreeqc::~Phreeqc(void)
{
clean_up();
this->phrq_io.close_input_files();
this->phrq_io.close_output_files();
this->phrq_io->close_input_files();
this->phrq_io->close_output_files();
int i;
for (i = 0; i < count_iso_defaults; i++)
@ -409,6 +411,7 @@ Phreeqc::~Phreeqc(void)
free_check_null(default_data_base);
PHRQ_free_all();
delete phrq_io;
}
void Phreeqc::set_phast(int tf)
@ -429,7 +432,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
// solutions
for (i = 0; i < count_solution; i++)
{
cxxSolution entity(solution[i], &phrq_io);
cxxSolution entity(solution[i], phrq_io);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
@ -444,7 +447,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
// pure phases
for (i = 0; i < count_pp_assemblage; i++)
{
cxxPPassemblage entity(&pp_assemblage[i], &phrq_io);
cxxPPassemblage entity(&pp_assemblage[i], phrq_io);
entity.totalize(this);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
@ -452,7 +455,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
// exchangers
for (i = 0; i < count_exchange; i++)
{
cxxExchange entity(&exchange[i], &phrq_io);
cxxExchange entity(&exchange[i], phrq_io);
entity.totalize();
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
@ -460,7 +463,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
// surfaces
for (i = 0; i < count_surface; i++)
{
cxxSurface entity(&surface[i], &phrq_io);
cxxSurface entity(&surface[i], phrq_io);
entity.totalize();
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
@ -468,7 +471,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
// gas phases
for (i = 0; i < count_gas_phase; i++)
{
cxxGasPhase entity(&gas_phase[i], &phrq_io);
cxxGasPhase entity(&gas_phase[i], phrq_io);
entity.totalize(this);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
@ -485,7 +488,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
for (i = 0; i < count_kinetics; i++)
{
calc_dummy_kinetic_reaction_tally(&kinetics[i]);
cxxKinetics entity(&kinetics[i], &phrq_io);
cxxKinetics entity(&kinetics[i], phrq_io);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
@ -1145,9 +1148,9 @@ void Phreeqc::init(void)
count_strings = 0;
#ifdef MULTICHART
chart_handler.Set_io(&phrq_io);
chart_handler.Set_io(phrq_io);
#endif
run_info.Set_io(&phrq_io);
run_info.Set_io(phrq_io);
this->clear_cookie();

View File

@ -94,7 +94,7 @@ read_solution_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -110,7 +110,7 @@ read_solution_raw(void)
parser.get_option(vopts, next_char);
cxxSolution sol(&phrq_io);
cxxSolution sol(phrq_io);
sol.read_raw(parser);
//struct solution *soln_ptr = sol.cxxSolution2solution(PHREEQC_THIS);
struct solution *soln_ptr = cxxSolution2solution(&sol);
@ -188,7 +188,7 @@ read_exchange_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -203,7 +203,7 @@ read_exchange_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxExchange ex(&phrq_io);
cxxExchange ex(phrq_io);
ex.read_raw(parser);
//struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS);
struct exchange *exchange_ptr = cxxExchange2exchange(&ex);
@ -283,7 +283,7 @@ read_surface_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -298,7 +298,7 @@ read_surface_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxSurface ex(&phrq_io);
cxxSurface ex(phrq_io);
ex.read_raw(parser);
//struct surface *surface_ptr = ex.cxxSurface2surface(PHREEQC_THIS);
struct surface *surface_ptr = cxxSurface2surface(&ex);
@ -379,7 +379,7 @@ read_equilibrium_phases_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -394,7 +394,7 @@ read_equilibrium_phases_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxPPassemblage ex(&phrq_io);
cxxPPassemblage ex(phrq_io);
ex.read_raw(parser);
//struct pp_assemblage *pp_assemblage_ptr = ex.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
struct pp_assemblage *pp_assemblage_ptr = cxxPPassemblage2pp_assemblage(&ex);
@ -476,7 +476,7 @@ read_kinetics_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -491,7 +491,7 @@ read_kinetics_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxKinetics ex(&phrq_io);
cxxKinetics ex(phrq_io);
ex.read_raw(parser);
//struct kinetics *kinetics_ptr = ex.cxxKinetics2kinetics(PHREEQC_THIS);
struct kinetics *kinetics_ptr = cxxKinetics2kinetics(&ex);
@ -572,7 +572,7 @@ read_solid_solutions_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -670,7 +670,7 @@ read_gas_phase_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -685,7 +685,7 @@ read_gas_phase_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxGasPhase ex(&phrq_io);
cxxGasPhase ex(phrq_io);
ex.read_raw(parser);
//struct gas_phase *gas_phase_ptr = ex.cxxGasPhase2gas_phase(PHREEQC_THIS);
struct gas_phase *gas_phase_ptr = cxxGasPhase2gas_phase(&ex);
@ -765,7 +765,7 @@ read_reaction_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -861,7 +861,7 @@ read_mix_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
@ -876,7 +876,7 @@ read_mix_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxMix ex(&phrq_io);
cxxMix ex(phrq_io);
ex.read_raw(parser);
//struct mix *mix_ptr = ex.cxxMix2mix(PHREEQC_THIS);
struct mix *mix_ptr = cxxMix2mix(&ex);
@ -957,7 +957,7 @@ read_temperature_raw(void)
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
@ -973,7 +973,7 @@ read_temperature_raw(void)
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxTemperature ex(&phrq_io);
cxxTemperature ex(phrq_io);
ex.read_raw(parser);
//struct temperature *temperature_ptr = ex.cxxTemperature2temperature(PHREEQC_THIS);
struct temperature *temperature_ptr = cxxTemperature2temperature(&ex);
@ -1035,7 +1035,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1053,7 +1053,7 @@ read_dump(void)
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
dumper dmp(parser, &phrq_io);
dumper dmp(parser, phrq_io);
dump_info = dmp;
@ -1087,7 +1087,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1105,7 +1105,7 @@ read_delete(void)
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
StorageBinList deleter(parser, &phrq_io);
StorageBinList deleter(parser, phrq_io);
delete_info = deleter;
@ -1139,7 +1139,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1157,7 +1157,7 @@ read_run_cells(void)
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
runner r(parser, &phrq_io);
runner r(parser, phrq_io);
run_info = r;
@ -1211,7 +1211,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1238,14 +1238,14 @@ read_solution_modify(void)
return (ERROR);
}
cxxSolution sol(solution[n], &phrq_io);
cxxSolution sol(solution[n], phrq_io);
// Clear activities so we can know what was read
sol.clear_master_activity();
sol.read_raw(parser, false);
cxxSolution orig(solution[n], &phrq_io );
cxxSolution orig(solution[n], phrq_io );
sol.modify_activities(PHREEQC_THIS_COMMA orig);
@ -1310,7 +1310,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1337,7 +1337,7 @@ read_equilibrium_phases_modify(void)
}
// read entity
cxxPPassemblage entity(&(pp_assemblage[n]), &phrq_io);
cxxPPassemblage entity(&(pp_assemblage[n]), phrq_io);
entity.read_raw(parser, false);
// save entity
@ -1404,7 +1404,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1431,7 +1431,7 @@ read_exchange_modify(void)
}
// read entity
cxxExchange entity(&(exchange[n]), &phrq_io);
cxxExchange entity(&(exchange[n]), phrq_io);
entity.read_raw(parser, false);
// save entity
@ -1513,7 +1513,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1540,7 +1540,7 @@ read_surface_modify(void)
}
// read entity
cxxSurface entity(&(surface[n]), &phrq_io);
cxxSurface entity(&(surface[n]), phrq_io);
entity.read_raw(parser, false);
// save entity
@ -1603,7 +1603,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1692,7 +1692,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1719,7 +1719,7 @@ read_gas_phase_modify(void)
}
// read entity
cxxGasPhase entity(&(gas_phase[n]), &phrq_io);
cxxGasPhase entity(&(gas_phase[n]), phrq_io);
entity.read_raw(parser, false);
// save entity
//struct gas_phase *entity_ptr = entity.cxxGasPhase2gas_phase(PHREEQC_THIS);
@ -1781,7 +1781,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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -1808,7 +1808,7 @@ read_kinetics_modify(void)
}
// read entity
cxxKinetics entity(&(kinetics[n]), &phrq_io);
cxxKinetics entity(&(kinetics[n]), phrq_io);
entity.read_raw(parser, false);
// save entity
@ -1870,7 +1870,7 @@ read_reaction_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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
@ -2466,7 +2466,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_solution; i++)
{
cxxSolution cxxsoln(solution[i], &phrq_io);
cxxSolution cxxsoln(solution[i], phrq_io);
cxxsoln.dump_raw(os,0);
}
}
@ -2477,7 +2477,7 @@ dump_ostream(std::ostream& os)
{
if (solution_bsearch(*it, &n, FALSE) != NULL)
{
cxxSolution cxxsoln(solution[n], &phrq_io);
cxxSolution cxxsoln(solution[n], phrq_io);
cxxsoln.dump_raw(os,0);
}
}
@ -2491,7 +2491,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_pp_assemblage; i++)
{
cxxPPassemblage cxxentity(&pp_assemblage[i], &phrq_io);
cxxPPassemblage cxxentity(&pp_assemblage[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2503,7 +2503,7 @@ dump_ostream(std::ostream& os)
if (pp_assemblage_bsearch(*it, &n) != NULL)
{
cxxPPassemblage cxxentity(&pp_assemblage[n], &phrq_io);
cxxPPassemblage cxxentity(&pp_assemblage[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2517,7 +2517,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_exchange; i++)
{
cxxExchange cxxentity(&exchange[i], &phrq_io);
cxxExchange cxxentity(&exchange[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2529,7 +2529,7 @@ dump_ostream(std::ostream& os)
if (exchange_bsearch(*it, &n) != NULL)
{
cxxExchange cxxentity(&exchange[n], &phrq_io);
cxxExchange cxxentity(&exchange[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2543,7 +2543,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_surface; i++)
{
cxxSurface cxxentity(&surface[i], &phrq_io);
cxxSurface cxxentity(&surface[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2555,7 +2555,7 @@ dump_ostream(std::ostream& os)
if (surface_bsearch(*it, &n) != NULL)
{
cxxSurface cxxentity(&surface[n], &phrq_io);
cxxSurface cxxentity(&surface[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2595,7 +2595,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_gas_phase; i++)
{
cxxGasPhase cxxentity(&gas_phase[i], &phrq_io);
cxxGasPhase cxxentity(&gas_phase[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2607,7 +2607,7 @@ dump_ostream(std::ostream& os)
if (gas_phase_bsearch(*it, &n) != NULL)
{
cxxGasPhase cxxentity(&gas_phase[n], &phrq_io);
cxxGasPhase cxxentity(&gas_phase[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2621,7 +2621,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_kinetics; i++)
{
cxxKinetics cxxentity(&kinetics[i], &phrq_io);
cxxKinetics cxxentity(&kinetics[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2633,7 +2633,7 @@ dump_ostream(std::ostream& os)
if (kinetics_bsearch(*it, &n) != NULL)
{
cxxKinetics cxxentity(&kinetics[n], &phrq_io);
cxxKinetics cxxentity(&kinetics[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2647,7 +2647,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_mix; i++)
{
cxxMix cxxentity(&mix[i], &phrq_io);
cxxMix cxxentity(&mix[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2659,7 +2659,7 @@ dump_ostream(std::ostream& os)
if (mix_bsearch(*it, &n) != NULL)
{
cxxMix cxxentity(&mix[n], &phrq_io);
cxxMix cxxentity(&mix[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2699,7 +2699,7 @@ dump_ostream(std::ostream& os)
{
for (i = 0; i < count_temperature; i++)
{
cxxTemperature cxxentity(&temperature[i], &phrq_io);
cxxTemperature cxxentity(&temperature[i], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2711,7 +2711,7 @@ dump_ostream(std::ostream& os)
if (temperature_bsearch(*it, &n) != NULL)
{
cxxTemperature cxxentity(&temperature[n], &phrq_io);
cxxTemperature cxxentity(&temperature[n], phrq_io);
cxxentity.dump_raw(os,0);
}
}
@ -2754,7 +2754,7 @@ read_user_graph_handler(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, &phrq_io);
CParser parser(iss_in, oss_out, oss_err, phrq_io);
//For testing, need to read line to get started
std::vector < std::string > vopts;