New class

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3735 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2009-11-02 15:25:39 +00:00
parent 259c0839f0
commit b3b22f3fd5
2 changed files with 151 additions and 0 deletions

128
runner.cpp Normal file
View File

@ -0,0 +1,128 @@
#include "runner.h"
runner::runner(void)
{
this->time_step = 0;
this->start_time = 0;
}
runner::runner(CParser & parser)
{
this->time_step = 0;
this->start_time = 0;
this->Read(parser);
}
runner::~runner(void)
{
}
bool runner::Read(CParser & parser)
{
bool return_value(true);
static std::vector < std::string > vopts;
if (vopts.empty())
{
vopts.reserve(20);
vopts.push_back("cell");
vopts.push_back("cells");
vopts.push_back("start_time");
vopts.push_back("time_step");
}
std::istream::pos_type ptr;
std::istream::pos_type next_char;
std::string token;
int opt_save;
bool useLastLine(false);
this->Get_cells().Set_defined(true);
opt_save = CParser::OPT_DEFAULT;
StorageBinListItem item;
for (;;)
{
int opt;
opt = parser.get_option(vopts, next_char);
if (opt == CParser::OPT_DEFAULT)
{
opt = opt_save;
}
else
{
opt_save = opt;
}
// Read dump entity list of numbers or number ranges for line, store in item
if (opt >= 0 && opt <= 1)
{
}
// Process other identifiers
std::set < int >::iterator it;
switch (opt)
{
case CParser::OPT_EOF:
break;
case CParser::OPT_KEYWORD:
break;
case 0:
case 1:
for (;;)
{
CParser::TOKEN_TYPE j = parser.copy_token(token, next_char);
if (j == CParser::TT_DIGIT)
{
item.Augment(token);
}
else if (j == CParser::TT_EMPTY)
{
item.Augment(token);
break;
}
else
{
parser.error_msg("Expected single number or range of numbers.",
CParser::OT_CONTINUE);
}
}
break;
case 2: //start_time
if (!(parser.get_iss() >> this->start_time))
{
parser.error_msg("Expected start_time for RUN_CELLS.",
CParser::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
}
break;
case 3: //time_step
if (!(parser.get_iss() >> this->time_step))
{
parser.error_msg("Expected time_step for RUN_CELLS.",
CParser::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
}
break;
default:
case CParser::OPT_DEFAULT:
case CParser::OPT_ERROR:
opt = CParser::OPT_EOF;
parser.error_msg("Unknown input reading RUN_CELLS definition.",
CParser::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
useLastLine = false;
return_value = false;
break;
}
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
break;
}
if (item.Get_numbers().size() > 0)
{
this->cells = item;
}
return(return_value);
}

23
runner.h Normal file
View File

@ -0,0 +1,23 @@
#if !defined(RUNNER_H_INCLUDED)
#define RUNNER_H_INCLUDED
#include <set> // std::set
#include <string> // std::string
#include "Parser.h"
#include "StorageBinList.h"
class runner
{
public:
runner(void);
runner(CParser & parser);
virtual ~runner(void);
bool Read(CParser & parser);
StorageBinListItem & Get_cells(void) { return(this->cells); };
double Get_time_step() { return(this->time_step); };
double Get_start_time() { return(this->start_time); };
protected:
double time_step;
double start_time;
StorageBinListItem cells;
};
#endif // !defined(RUNNER_H_INCLUDED)