From 957551d0a7a95b7cb67333b7b1a7f27d00abcb08 Mon Sep 17 00:00:00 2001 From: David L Parkhurst Date: Wed, 8 Mar 2006 14:54:34 +0000 Subject: [PATCH] Updates git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@837 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- Solution.cxx | 27 +++++++++++++++++++---- StorageBin.cxx | 60 +++++++++++++------------------------------------- StorageBin.h | 9 ++++---- 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/Solution.cxx b/Solution.cxx index 1b0f71c6..e1b6a5b0 100644 --- a/Solution.cxx +++ b/Solution.cxx @@ -14,6 +14,7 @@ #include // assert #include // std::sort + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -1118,11 +1119,29 @@ void test_classes(void) } #endif { + // get all c storage + cxxStorageBin cstorage(cxxStorageBin::SB_GLOBAL); + //std::ostringstream oss; + //cstorage.dump_raw(oss, 0); + //write it out + std::fstream myfile; + myfile.open("tfile", std::ios_base::out); + cstorage.dump_raw(myfile, 0); + myfile.close(); + } + { + // empty storage bin cxxStorageBin cstorage; + // fstream + std::fstream myfile; + myfile.open("tfile", std::ios_base::in); + // ostream std::ostringstream oss; - cstorage.dump_raw(oss, 0); - std::cerr << oss.str(); - //char string[200]; - //strcpy_s(string, "abc"); + // parser + CParser cparser(myfile, oss, std::cerr); + cstorage.read_raw(cparser); + //std::cerr << oss.str(); + + // read it back } } diff --git a/StorageBin.cxx b/StorageBin.cxx index a6c1c5b5..aa366801 100644 --- a/StorageBin.cxx +++ b/StorageBin.cxx @@ -18,8 +18,11 @@ ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// - cxxStorageBin::cxxStorageBin() +{ +} + +cxxStorageBin::cxxStorageBin(cxxStorageBin::SB_CONSTRUCTOR flag) // // default constructor for cxxStorageBin // pull data out of c storage @@ -120,63 +123,30 @@ void cxxStorageBin::dump_raw(std::ostream& s_oss, unsigned int indent)const // Solutions Utilities::dump_raw(Solutions, s_oss, indent); - //for (std::map::const_iterator it = this->Solutions.begin(); it != this->Solutions.end(); ++it) { - //it->second.dump_raw(s_oss, indent); - //} // Exchange Utilities::dump_raw(Exchangers, s_oss, indent); - /* - for (std::map::const_iterator it = this->Exchangers.begin(); it != this->Exchangers.end(); ++it) { - it->second.dump_raw(s_oss, indent); - - } - */ // Gas Phases Utilities::dump_raw(GasPhases, s_oss, indent); - /* - for (std::map::const_iterator it = this->GasPhases.begin(); it != this->GasPhases.end(); ++it) { - it->second.dump_raw(s_oss, indent); - } - */ + // Kinetics Utilities::dump_raw(Kinetics, s_oss, indent); - /* - for (std::map::const_iterator it = this->Kinetics.begin(); it != this->Kinetics.end(); ++it) { - it->second.dump_raw(s_oss, indent); - } - */ // PPassemblage Utilities::dump_raw(PPassemblages, s_oss, indent); - /* - for (std::map::const_iterator it = this->PPassemblages.begin(); it != this->PPassemblages.end(); ++it) { - it->second.dump_raw(s_oss, indent); - } - */ // SSassemblage Utilities::dump_raw(SSassemblages, s_oss, indent); - /* - for (std::map::const_iterator it = this->SSassemblages.begin(); it != this->SSassemblages.end(); ++it) { - it->second.dump_raw(s_oss, indent); - } - */ // Surface Utilities::dump_raw(Surfaces, s_oss, indent); - /* - for (std::map::const_iterator it = this->Surfaces.begin(); it != this->Surfaces.end(); ++it) { - it->second.dump_raw(s_oss, indent); - } - */ } void cxxStorageBin::read_raw(CParser& parser) { CParser::LINE_TYPE i; - while ((i = parser.check_line("Subroutine Read", false, true, true, true)) != CParser::LT_KEYWORD) + while ((i = parser.check_line("StorageBin read_raw", false, true, true, true)) != CParser::LT_KEYWORD) { if (i == CParser::LT_EOF) return; // CParser::LT_EOF; } @@ -189,15 +159,15 @@ void cxxStorageBin::read_raw(CParser& parser) case CParser::KT_NONE: goto END_OF_SIMULATION_INPUT; break; - /* - 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 - */ + /* + 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 + */ case CParser::KT_SOLUTION_RAW: { cxxSolution entity; diff --git a/StorageBin.h b/StorageBin.h index 0eb7a539..343bebe3 100644 --- a/StorageBin.h +++ b/StorageBin.h @@ -20,15 +20,16 @@ #include // std::list #include // std::vector -template -bool exists (std::map b, int i){ - return (b.find(i) != b.end());} - class cxxStorageBin { public: + enum SB_CONSTRUCTOR { + SB_GLOBAL = 1 + }; + cxxStorageBin(); + cxxStorageBin(SB_CONSTRUCTOR flag); ~cxxStorageBin(); //void dump_xml(std::ostream& os, unsigned int indent = 0)const;