mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
The tellg and seekg did not work for gz files because the
methods are not implemented. Modified the parser to accumulate lines so that they could be turned into a stream and reread. Modified kinetics, exchange, ppassemblage, ssassemblage, and surface to use the new way to reread lines for component values. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3742 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
e35673205b
commit
ff19c86d65
19
Exchange.cxx
19
Exchange.cxx
@ -356,6 +356,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
cxxExchComp ec;
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
@ -380,6 +381,24 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
std::string str(ec1.get_formula());
|
||||
this->exchComps[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
std::istringstream is(parser.get_accumulated());
|
||||
CParser reread(is);
|
||||
if (this->exchComps.find(ec.get_formula()) != this->exchComps.end())
|
||||
{
|
||||
cxxExchComp & comp = this->exchComps.find(ec.get_formula())->second;
|
||||
comp.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxExchComp ec1;
|
||||
ec1.read_raw(reread, false);
|
||||
std::string str(ec1.get_formula());
|
||||
this->exchComps[str] = ec1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
|
||||
@ -230,9 +230,10 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
|
||||
case 1: // component
|
||||
{
|
||||
cxxPPassemblageComp ppComp;
|
||||
cxxPPassemblageComp ec;
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
@ -258,6 +259,25 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
std::string str(ppComp1.get_name());
|
||||
this->ppAssemblageComps[str] = ppComp1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
std::istringstream is(parser.get_accumulated());
|
||||
CParser reread(is);
|
||||
|
||||
if (this->ppAssemblageComps.find(ec.get_name()) != this->ppAssemblageComps.end())
|
||||
{
|
||||
cxxPPassemblageComp & comp = this->ppAssemblageComps.find(ec.get_name())->second;
|
||||
comp.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxPPassemblageComp ppComp1;
|
||||
ppComp1.read_raw(reread, false);
|
||||
std::string str(ppComp1.get_name());
|
||||
this->ppAssemblageComps[str] = ppComp1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
|
||||
@ -27,6 +27,7 @@ m_next_keyword(KT_NONE)
|
||||
m_line.reserve(80);
|
||||
echo_file = EO_ALL;
|
||||
echo_stream = EO_NONE;
|
||||
accumulate = false;
|
||||
}
|
||||
|
||||
CParser::CParser(std::istream & input, std::ostream & output):m_input_stream(input), m_output_stream(output), m_error_stream(std::cerr),
|
||||
@ -37,6 +38,7 @@ m_next_keyword(KT_NONE)
|
||||
m_line.reserve(80);
|
||||
echo_file = EO_ALL;
|
||||
echo_stream = EO_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),
|
||||
@ -47,6 +49,7 @@ m_next_keyword(KT_NONE)
|
||||
m_line.reserve(80);
|
||||
echo_file = EO_ALL;
|
||||
echo_stream = EO_NONE;
|
||||
accumulate = false;
|
||||
}
|
||||
|
||||
CParser::~CParser()
|
||||
@ -199,6 +202,11 @@ CParser::LINE_TYPE CParser::get_line()
|
||||
}
|
||||
}
|
||||
|
||||
if (this->accumulate)
|
||||
{
|
||||
this->accumulated.append(m_line_save);
|
||||
this->accumulated.append("\n");
|
||||
}
|
||||
//
|
||||
// New line character encountered
|
||||
//
|
||||
|
||||
14
Parser.h
14
Parser.h
@ -151,6 +151,18 @@ class CParser
|
||||
{
|
||||
return m_line;
|
||||
}
|
||||
std::string & get_accumulated()
|
||||
{
|
||||
return accumulated;
|
||||
}
|
||||
void set_accumulate(bool tf)
|
||||
{
|
||||
if (tf)
|
||||
{
|
||||
accumulated.clear();
|
||||
}
|
||||
this->accumulate = tf;
|
||||
}
|
||||
std::istringstream & get_iss()
|
||||
{
|
||||
return m_line_iss;
|
||||
@ -289,6 +301,8 @@ class CParser
|
||||
LINE_TYPE m_line_type;
|
||||
ECHO_OPTION echo_stream;
|
||||
ECHO_OPTION echo_file;
|
||||
std::string accumulated;
|
||||
bool accumulate;
|
||||
};
|
||||
|
||||
// Global functions
|
||||
|
||||
@ -208,6 +208,7 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
|
||||
cxxSSassemblageSS ec;
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
@ -231,7 +232,24 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
|
||||
std::string str(ec1.get_name());
|
||||
this->ssAssemblageSSs[str] = ec1;
|
||||
}
|
||||
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
std::istringstream is(parser.get_accumulated());
|
||||
CParser reread(is);
|
||||
if (this->ssAssemblageSSs.find(ec.get_name()) != this->ssAssemblageSSs.end())
|
||||
{
|
||||
cxxSSassemblageSS & ec1 = this->ssAssemblageSSs.find(ec.get_name())->second;
|
||||
ec1.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxSSassemblageSS ec1;
|
||||
ec1.read_raw(reread, false);
|
||||
std::string str(ec1.get_name());
|
||||
this->ssAssemblageSSs[str] = ec1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
|
||||
38
Surface.cxx
38
Surface.cxx
@ -510,6 +510,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
cxxSurfaceComp ec;
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
@ -533,6 +534,24 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
std::string str(ec1.get_formula());
|
||||
this->surfaceComps[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
std::istringstream is(parser.get_accumulated());
|
||||
CParser reread(is);
|
||||
if (this->surfaceComps.find(ec.get_formula()) != this->surfaceComps.end())
|
||||
{
|
||||
cxxSurfaceComp & comp = this->surfaceComps.find(ec.get_formula())->second;
|
||||
comp.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxSurfaceComp ec1;
|
||||
ec1.read_raw(reread, false);
|
||||
std::string str(ec1.get_formula());
|
||||
this->surfaceComps[str] = ec1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
@ -542,6 +561,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
cxxSurfaceCharge ec;
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
@ -565,6 +585,24 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
std::string str(ec1.get_name());
|
||||
this->surfaceCharges[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
std::istringstream is(parser.get_accumulated());
|
||||
CParser reread(is);
|
||||
if (this->surfaceCharges.find(ec.get_name()) != this->surfaceCharges.end())
|
||||
{
|
||||
cxxSurfaceCharge & comp = this->surfaceCharges.find(ec.get_name())->second;
|
||||
comp.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxSurfaceCharge ec1;
|
||||
ec1.read_raw(reread, false);
|
||||
std::string str(ec1.get_name());
|
||||
this->surfaceCharges[str] = ec1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
|
||||
@ -381,6 +381,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
cxxKineticsComp ec;
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
@ -404,6 +405,25 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
std::string str(ec1.get_rate_name());
|
||||
this->kineticsComps[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
std::istringstream is(parser.get_accumulated());
|
||||
CParser reread(is);
|
||||
|
||||
if (this->kineticsComps.find(ec.get_rate_name()) != this->kineticsComps.end())
|
||||
{
|
||||
cxxKineticsComp & comp = this->kineticsComps.find(ec.get_rate_name())->second;
|
||||
comp.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxKineticsComp ec1;
|
||||
ec1.read_raw(reread, false);
|
||||
std::string str(ec1.get_rate_name());
|
||||
this->kineticsComps[str] = ec1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user