Working on saving state.

I think there is a compiler bug with map iterators in template definitions.



git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@796 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2006-02-27 21:17:46 +00:00
parent c42d985558
commit 2fe8f7d44e
5 changed files with 64 additions and 10 deletions

View File

@ -158,6 +158,7 @@ COMMON_CXXOBJS = \
ISolutionComp.o \
SSassemblage.o \
SSassemblageSS.o \
StorageBin.o \
Surface.o \
SurfCharge.o \
SurfComp.o \
@ -178,6 +179,9 @@ ${PROGRAM} : ${OBJECT_FILES}
#
# CXX files
#
EntityMap.o: ../EntityMap.cxx ../Utils.h ../EntityMap.h \
../phreeqc/global.h ../phreeqc/phrqtype.h ../char_star.h ../Parser.h \
../char_star.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h
Exchange.o: ../Exchange.cxx ../Utils.h ../Exchange.h ../NumKeyword.h \
../Parser.h ../char_star.h ../phreeqc/global.h ../phreeqc/phrqtype.h \
../char_star.h ../ExchComp.h ../NameDouble.h ../char_star.h ../Parser.h \
@ -281,6 +285,9 @@ SSassemblageSS.o: ../SSassemblageSS.cxx ../Utils.h ../SSassemblageSS.h \
../NameDouble.h ../phreeqc/global.h ../phreeqc/phrqtype.h \
../char_star.h ../Parser.h ../char_star.h ../char_star.h \
../NameDouble.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h
StorageBin.o: ../StorageBin.cxx ../Utils.h ../StorageBin.h \
../phreeqc/global.h ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h \
../phreeqc/phrqproto.h
Surface.o: ../Surface.cxx ../Utils.h ../Surface.h ../NumKeyword.h \
../Parser.h ../char_star.h ../phreeqc/global.h ../phreeqc/phrqtype.h \
../char_star.h ../SurfComp.h ../NameDouble.h ../char_star.h ../Parser.h \

View File

@ -233,9 +233,13 @@ bool CParser::check_key(std::string::iterator begin, std::string::iterator end)
static std::map<std::string, KEY_TYPE> s_keyword_map;
if (s_keyword_map.size() == 0)
{
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("solution", KT_SOLUTION));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("solution_raw", KT_SOLUTION_RAW));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("end", KT_END));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("exchange_raw", KT_EXCHANGE_RAW));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("gas_phase_raw", KT_GASPHASE_RAW));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("kinetics_raw", KT_KINETICS_RAW));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("equilibrium_phases_raw", KT_PPASSEMBLAGE_RAW));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("solid_solutions_raw", KT_SSASSEMBLAGE_RAW));
s_keyword_map.insert(std::map<std::string, KEY_TYPE>::value_type("surface_raw", KT_SURFACE_RAW));
}
std::string lowercase;

View File

@ -43,8 +43,14 @@ public:
KT_NONE = -1,
KT_END = 0,
KT_EOF = 1,
KT_SOLUTION = 4,
KT_SOLUTION_RAW = 5
KT_SOLUTION_RAW = 5,
KT_EXCHANGE_RAW = 6,
KT_GASPHASE_RAW = 7,
KT_KINETICS_RAW = 8,
KT_PPASSEMBLAGE_RAW = 9,
KT_SSASSEMBLAGE_RAW = 10,
KT_SURFACE_RAW = 11
};
enum OPT_TYPE {

View File

@ -809,6 +809,8 @@ cxxSolution& cxxSolution::read(CParser& parser)
#include "Reaction.h"
#include "Mix.h"
#include "Temperature.h"
#include "StorageBin.h"
#include "NumKeyword.h"
#include <iostream> // std::cout std::cerr
//#include <strstream>
#include <sstream>
@ -816,8 +818,22 @@ cxxSolution& cxxSolution::read(CParser& parser)
void test_classes(void)
{
int i;
bool b(true);
i = (int) b;
/*
std::map<int, cxxSolution> Solutions;
cxxSolution soln(solution[0]);
Solutions[solution[0]->n_user] = soln;
bool b = Utilities::exists(Solutions, 1);
*/
/*
cxxEntityMap x;
cxxSolution soln(solution[0]);
cxxNumKeyword nk;
x[solution[0]->n_user] = soln;
*/
for (i=0; i < count_solution; i++) {
if (solution[i]->new_def == TRUE) {
cxxISolution sol(solution[i]);

21
Utils.h
View File

@ -2,6 +2,11 @@
#define UTILITIES_H_INCLUDED
#include <string>
#include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream
#include <istream> // std::istream
#include <map> // std::map
#include "char_star.h"
namespace Utilities {
@ -26,6 +31,22 @@ namespace Utilities {
void error_msg(const std::string&, const int stopflag);
// operations on maps of entities (Solution, Exchange, ...)
template<class T>
bool exists (std::map<int, T> b, int i){
return (b.find(i) != b.end());}
/*
template<class T>
void dump_raw ( std::map<int, T> b, std::ostream& s_oss, unsigned int indent )
{
std :: map < int, T > :: iterator it;
for (it = b.begin(); it != b.end(); ++it) {
it->second.dump_raw(s_oss, indent);
}
return;
}
*/
}
#endif // UTILITIES_H_INCLUDED