cloudy
trunk
source
parse_state.cpp
Go to the documentation of this file.
1
/* This file is part of Cloudy and is copyright (C)1978-2013 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 "
parse.h
"
6
#include "
state.h
"
7
#include "
parser.h
"
8
9
/*ParseState save or recover previous state of the code */
10
void
ParseState
(
Parser
&p)
11
{
12
char
chFilename[
INPUT_LINE_LENGTH
];
13
14
DEBUG_ENTRY
(
"ParseState()"
);
15
16
/*
17
* get file name for this save output.
18
* GetQuote does the following -
19
* first copy original version of file name into chLabel,
20
* string does include null termination.
21
* set filename in OrgCard and second parameter to spaces so
22
* that not picked up below as keyword
23
* last parameter says to abort if no quote found
24
*/
25
p.
GetQuote
( chFilename ,
true
);
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,
"rb"
,
AS_LOCAL_ONLY
);
35
# endif
36
state
.
lgGet_state
=
true
;
37
strcpy(
state
.
chGetFilename
, chFilename );
38
}
39
else
if
( p.
nMatch
(
" PUT"
) )
40
{
41
# if 0
42
state
.ioPUT_STATE =
open_data
( chFilename ,
"wb"
,
AS_LOCAL_ONLY
);
43
# endif
44
state
.
lgPut_state
=
true
;
45
strcpy(
state
.
chPutFilename
, chFilename );
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"
);
61
cdEXIT
(
EXIT_FAILURE
);
62
}
63
return
;
64
}
Parser::nMatch
bool nMatch(const char *chKey) const
Definition:
parser.h:135
open_data
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
Definition:
cpu.cpp:625
ioQQQ
FILE * ioQQQ
Definition:
cddefines.cpp:7
ParseState
void ParseState(Parser &p)
Definition:
parse_state.cpp:10
AS_LOCAL_ONLY
@ AS_LOCAL_ONLY
Definition:
cpu.h:208
Parser::GetQuote
int GetQuote(char *chLabel, bool lgABORT)
Definition:
parser.h:209
t_state::lgGet_state
bool lgGet_state
Definition:
state.h:20
parse.h
EXIT_FAILURE
#define EXIT_FAILURE
Definition:
cddefines.h:140
Parser
Definition:
parser.h:31
cddefines.h
t_state::lgPut_state
bool lgPut_state
Definition:
state.h:21
t_state::chGetFilename
char chGetFilename[INPUT_LINE_LENGTH]
Definition:
state.h:16
cdEXIT
#define cdEXIT(FAIL)
Definition:
cddefines.h:434
state
t_state state
Definition:
state.cpp:19
INPUT_LINE_LENGTH
const int INPUT_LINE_LENGTH
Definition:
cddefines.h:254
parser.h
t_state::lgState_print
bool lgState_print
Definition:
state.h:27
t_state::chPutFilename
char chPutFilename[INPUT_LINE_LENGTH]
Definition:
state.h:15
state.h
t_state::lgPutAll
bool lgPutAll
Definition:
state.h:24
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition:
cddefines.h:684
Generated by
1.8.17