1 |
greg |
2.4 |
/* RCSid $Id: eplus_idf.h,v 2.3 2014/02/09 02:18:16 greg Exp $ */ |
2 |
greg |
2.1 |
/* |
3 |
|
|
* eplus_idf.h |
4 |
|
|
* |
5 |
|
|
* EnergyPlus Input Data File i/o declarations |
6 |
|
|
* |
7 |
|
|
* Created by Greg Ward on 1/31/14. |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
#ifndef _RAD_EPLUS_IDF_H_ |
11 |
|
|
#define _RAD_EPLUS_IDF_H_ |
12 |
|
|
|
13 |
|
|
#include "lookup.h" |
14 |
|
|
|
15 |
|
|
#ifdef __cplusplus |
16 |
|
|
extern "C" { |
17 |
|
|
#endif |
18 |
|
|
|
19 |
|
|
#define IDF_MAXLINE 512 /* maximum line length */ |
20 |
greg |
2.2 |
#define IDF_MAXARGL 104 /* maximum argument length */ |
21 |
greg |
2.1 |
|
22 |
|
|
/* Input Data File parameter argument list */ |
23 |
|
|
typedef struct s_idf_field { |
24 |
|
|
struct s_idf_field *next; /* next in parameter list */ |
25 |
|
|
char *rem; /* string following argument */ |
26 |
|
|
char arg[2]; /* argument (extends struct) */ |
27 |
|
|
} IDF_FIELD; |
28 |
|
|
|
29 |
|
|
/* Input Data File parameter */ |
30 |
|
|
typedef struct s_idf_parameter { |
31 |
|
|
const char *pname; /* parameter name (type) */ |
32 |
|
|
struct s_idf_parameter *pnext; /* next parameter same type */ |
33 |
|
|
struct s_idf_parameter *dnext; /* next parameter in IDF */ |
34 |
|
|
IDF_FIELD *flist; /* field list */ |
35 |
|
|
char rem[1]; /* comment (extends struct) */ |
36 |
|
|
} IDF_PARAMETER; |
37 |
|
|
|
38 |
|
|
/* Input Data File w/ dictionary */ |
39 |
|
|
typedef struct { |
40 |
|
|
char *hrem; /* header remarks */ |
41 |
|
|
IDF_PARAMETER *pfirst; /* first parameter in file */ |
42 |
|
|
IDF_PARAMETER *plast; /* last parameter loaded */ |
43 |
greg |
2.3 |
LUTAB ptab; /* parameter hash table */ |
44 |
greg |
2.1 |
} IDF_LOADED; |
45 |
|
|
|
46 |
greg |
2.3 |
/* Create a new parameter with empty field list (comment & prev optional) */ |
47 |
greg |
2.1 |
extern IDF_PARAMETER *idf_newparam(IDF_LOADED *idf, const char *pname, |
48 |
greg |
2.3 |
const char *comm, IDF_PARAMETER *prev); |
49 |
greg |
2.1 |
|
50 |
|
|
/* Add a field to the given parameter and follow with the given text */ |
51 |
|
|
extern int idf_addfield(IDF_PARAMETER *param, const char *fval, |
52 |
|
|
const char *comm); |
53 |
|
|
|
54 |
greg |
2.3 |
/* Retrieve the indexed field from parameter (first field index is 1) */ |
55 |
|
|
extern IDF_FIELD *idf_getfield(IDF_PARAMETER *param, int fn); |
56 |
|
|
|
57 |
greg |
2.4 |
/* Delete the specified parameter from the IDF */ |
58 |
greg |
2.1 |
extern int idf_delparam(IDF_LOADED *idf, IDF_PARAMETER *param); |
59 |
|
|
|
60 |
greg |
2.4 |
/* Move the specified parameter to the given position in the IDF */ |
61 |
|
|
extern int idf_movparam(IDF_LOADED *idf, IDF_PARAMETER *param, |
62 |
|
|
IDF_PARAMETER *prev); |
63 |
|
|
|
64 |
greg |
2.1 |
/* Get a named parameter list */ |
65 |
|
|
extern IDF_PARAMETER *idf_getparam(IDF_LOADED *idf, const char *pname); |
66 |
|
|
|
67 |
|
|
/* Read a parameter and fields from an open file and add to end of list */ |
68 |
|
|
extern IDF_PARAMETER *idf_readparam(IDF_LOADED *idf, FILE *fp); |
69 |
|
|
|
70 |
|
|
/* Initialize an IDF struct */ |
71 |
|
|
extern IDF_LOADED *idf_create(const char *hdrcomm); |
72 |
|
|
|
73 |
greg |
2.4 |
/* Add comment(s) to header */ |
74 |
|
|
extern int idf_add2hdr(IDF_LOADED *idf, const char *hdrcomm); |
75 |
|
|
|
76 |
greg |
2.1 |
/* Load an Input Data File */ |
77 |
|
|
extern IDF_LOADED *idf_load(const char *fname); |
78 |
|
|
|
79 |
|
|
/* Write a parameter and fields to an open file */ |
80 |
greg |
2.4 |
int idf_writeparam(IDF_PARAMETER *param, FILE *fp, |
81 |
|
|
int incl_comm); |
82 |
greg |
2.1 |
|
83 |
|
|
/* Write out an Input Data File */ |
84 |
greg |
2.4 |
extern int idf_write(IDF_LOADED *idf, const char *fname, |
85 |
|
|
int incl_comm); |
86 |
greg |
2.1 |
|
87 |
|
|
/* Free a loaded IDF */ |
88 |
|
|
extern void idf_free(IDF_LOADED *idf); |
89 |
|
|
|
90 |
|
|
#ifdef __cplusplus |
91 |
|
|
} |
92 |
|
|
#endif |
93 |
|
|
#endif /* ! _RAD_EPLUS_IDF_H_ */ |