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