cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_state.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2017 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ParseState save or recover previous state of the code */
4 #include "cddefines.h"
5 #include "state.h"
6 #include "parser.h"
7 
8 /*ParseState save or recover previous state of the code */
9 void ParseState(Parser &p)
10 {
11  string chFilename;
12 
13  DEBUG_ENTRY( "ParseState()" );
14 
15  /*
16  * get file name for this save output.
17  * GetQuote does the following -
18  * first copy original version of file name into chLabel,
19  * string does include null termination.
20  * set filename in OrgCard and second parameter to spaces so
21  * that not picked up below as keyword
22  * last parameter says to abort if no quote found
23  */
24  if (p.GetQuote( chFilename ))
25  p.StringError();
26 
27  /* option to print all contents of arrays - BIG PRINTOUT! */
28  if( p.nMatch("PRIN") )
29  state.lgState_print = true;
30 
31  if( p.nMatch(" GET") )
32  {
33 # if 0
34  state.ioGET_STATE = open_data( chFilename.c_str(), "rb", AS_LOCAL_ONLY );
35 # endif
36  state.lgGet_state = true;
37  strcpy( state.chGetFilename , chFilename.c_str() );
38  }
39  else if( p.nMatch(" PUT") )
40  {
41 # if 0
42  state.ioPUT_STATE = open_data( chFilename.c_str() , "wb" );
43 # endif
44  state.lgPut_state = true;
45  strcpy( state.chPutFilename , chFilename.c_str() );
46  /* look for keyword ALL - says want to save state for all iterations,
47  * default is last iteration */
48  if( p.nMatch(" ALL") )
49  {
50  state.lgPutAll = true;
51  }
52  else
53  {
54  state.lgPutAll = false;
55  }
56  }
57 
58  else
59  {
60  fprintf( ioQQQ, " The STATE command has two keywords, GET and PUT. One must appear - I did not see it.\n Sorry.\n" );
62  }
63  return;
64 }
void ParseState(Parser &p)
Definition: parse_state.cpp:9
bool nMatch(const char *chKey) const
Definition: parser.h:140
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
Definition: cpu.cpp:751
bool lgPut_state
Definition: state.h:29
int GetQuote(string &chLabel)
Definition: parser.cpp:184
FILE * ioQQQ
Definition: cddefines.cpp:7
Definition: parser.h:42
NORETURN void StringError() const
Definition: parser.cpp:174
char chPutFilename[INPUT_LINE_LENGTH]
Definition: state.h:24
bool lgPutAll
Definition: state.h:33
bool lgState_print
Definition: state.h:36
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:484
t_state state
Definition: state.cpp:18
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:729
bool lgGet_state
Definition: state.h:29
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1217
char chGetFilename[INPUT_LINE_LENGTH]
Definition: state.h:24