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