FORS Pipeline Reference Manual  5.0.9
fors_paf.h
1 /* $Id: fors_paf.h,v 1.2 2010-09-14 07:49:30 cizzo Exp $
2  *
3  * This file is part of the FORS Library
4  * Copyright (C) 2002-2010 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: cizzo $
23  * $Date: 2010-09-14 07:49:30 $
24  * $Revision: 1.2 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifndef FORS_PAF_H
29 #define FORS_PAF_H
30 
31 #include <sys/types.h>
32 
33 #include <cpl.h>
34 
35 
36 CPL_BEGIN_DECLS
37 
38 /*
39  * Maximum length of a parameter file record, i.e. maximum number of
40  * characters per line of a parameter file on disk. This does not include
41  * a trailing 0.
42  */
43 
44 #define PAF_RECORD_MAX (256)
45 
46 
47 /*
48  * PAF value types
49  */
50 
51 enum _FORS_PAF_TYPE_ {
52  PAF_TYPE_NONE,
53  PAF_TYPE_BOOL,
54  PAF_TYPE_INT,
55  PAF_TYPE_DOUBLE,
56  PAF_TYPE_STRING
57 };
58 
59 typedef enum _FORS_PAF_TYPE_ ForsPAFType;
60 
61 /*
62  * PAF object
63  */
64 
65 typedef struct _FORS_PAF_ ForsPAF;
66 
67 /*
68  * Create, copy and destroy operations
69  */
70 
71 ForsPAF *newForsPAF(const char *, const char *, const char *,
72  const char *);
73 void deleteForsPAF(ForsPAF *);
74 
75 /*
76  * Nonmodifying operations
77  */
78 
79 int forsPAFIsEmpty(const ForsPAF *);
80 size_t forsPAFGetSize(const ForsPAF *);
81 int forsPAFContains(const ForsPAF *, const char *);
82 size_t forsPAFCount(const ForsPAF *, const char *);
83 
84 /*
85  * Header operations
86  */
87 
88 ForsPAFType forsPAFType(const ForsPAF *, const char *);
89 
90 const char *forsPAFGetName(const ForsPAF *);
91 const char *forsPAFGetTag(const ForsPAF *);
92 const char *forsPAFGetId(const ForsPAF *);
93 const char *forsPAFGetDescription(const ForsPAF *);
94 
95 int forsPAFSetName(ForsPAF *, const char *);
96 int forsPAFSetTag(ForsPAF *, const char *);
97 int forsPAFSetId(ForsPAF *, const char *);
98 int forsPAFSetDescription(ForsPAF *, const char *);
99 
100 int forsPAFSetHeader(ForsPAF *, const char *, const char *, const char *,
101  const char *);
102 
103 /*
104  * Element access
105  */
106 
107 int forsPAFGetValueBool(const ForsPAF *, const char *);
108 int forsPAFGetValueInt(const ForsPAF *, const char *);
109 double forsPAFGetValueDouble(const ForsPAF *, const char *);
110 const char *forsPAFGetValueString(const ForsPAF *, const char *);
111 const char *forsPAFGetComment(const ForsPAF *, const char *);
112 
113 int forsPAFSetValueBool(ForsPAF *, const char *, int);
114 int forsPAFSetValueInt(ForsPAF *, const char *, int);
115 int forsPAFSetValueDouble(ForsPAF *, const char *, double);
116 int forsPAFSetValueString(ForsPAF *, const char *, const char *);
117 int forsPAFSetComment(ForsPAF *, const char *, const char *);
118 
119 /*
120  * Inserting and removing elements
121  */
122 
123 int forsPAFInsertBool(ForsPAF *, const char *, const char *, int, const char *);
124 int forsPAFInsertInt(ForsPAF *, const char *, const char *, int, const char *);
125 int forsPAFInsertDouble(ForsPAF *, const char *, const char *, double,
126  const char *);
127 int forsPAFInsertString(ForsPAF *, const char *, const char *, const char *,
128  const char *);
129 
130 int forsPAFInsertAfterBool(ForsPAF *, const char *, const char *, int,
131  const char *);
132 int forsPAFInsertAfterInt(ForsPAF *, const char *, const char *, int,
133  const char *);
134 int forsPAFInsertAfterDouble(ForsPAF *, const char *, const char *, double,
135  const char *);
136 int forsPAFInsertAfterString(ForsPAF *, const char *, const char *,
137  const char *, const char *);
138 
139 int forsPAFPrependBool(ForsPAF *, const char *, int, const char *);
140 int forsPAFPrependInt(ForsPAF *, const char *, int, const char *);
141 int forsPAFPrependDouble(ForsPAF *, const char *, double, const char *);
142 int forsPAFPrependString(ForsPAF *, const char *, const char *, const char *);
143 
144 int forsPAFAppendBool(ForsPAF *, const char *, int, const char *);
145 int forsPAFAppendInt(ForsPAF *, const char *, int, const char *);
146 int forsPAFAppendDouble(ForsPAF *, const char *, double, const char *);
147 int forsPAFAppendString(ForsPAF *, const char *, const char *, const char *);
148 
149 void forsPAFErase(ForsPAF *, const char *);
150 void forsPAFClear(ForsPAF *);
151 
152 /*
153  * Read and write operations
154  */
155 
156 int forsPAFWrite(ForsPAF *);
157 
158 /*
159  * Miscellaneous utilities
160  */
161 
162 int forsPAFIsValidName(const char *);
163 
164 CPL_END_DECLS
165 
166 #endif /* FORS_PAF_H */
int forsPAFAppendInt(ForsPAF *, const char *, int, const char *)
Append a integer value to a PAF object.
Definition: fors_paf.c:729
int forsPAFIsEmpty(const ForsPAF *)
Check whether a PAF object is empty.
Definition: fors_paf.c:594
int forsPAFIsValidName(const char *)
Verify that the given string is a valid PAF keyword.
Definition: fors_paf.c:642
void deleteForsPAF(ForsPAF *)
Destroy a PAF object.
Definition: fors_paf.c:511
int forsPAFAppendDouble(ForsPAF *, const char *, double, const char *)
Append a double value to a PAF object.
Definition: fors_paf.c:764
int forsPAFWrite(ForsPAF *)
Write a PAF object to a disk file.
Definition: fors_paf.c:834
int forsPAFAppendBool(ForsPAF *, const char *, int, const char *)
Append a boolean value to a PAF object.
Definition: fors_paf.c:695
int forsPAFAppendString(ForsPAF *, const char *, const char *, const char *)
Append a string value to a PAF object.
Definition: fors_paf.c:800
size_t forsPAFGetSize(const ForsPAF *)
Get the actual size of the given PAF object.
Definition: fors_paf.c:618
ForsPAF * newForsPAF(const char *, const char *, const char *, const char *)
Create a new PAF object.
Definition: fors_paf.c:550