das2C
das core C utilities (v3)
cli.h
Go to the documentation of this file.
1 
8 #ifndef das2_2_cli_H_
9 #define das2_2_cli_H_
10 
11 #include <das2/das1.h>
12 
13 #include <string.h>
14 #include <stdbool.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
21 #define OP_BEG ".ge."
22 #define OP_END ".lt."
23 #define OP_EQ ".eq."
24 #define OP_NE ".ne."
25 #define OP_LT ".lt."
26 #define OP_GT ".gt."
27 #define OP_LE ".le."
28 #define OP_GE ".ge."
29 
31 enum das_selfmt{bool_t, int_t, real_t, string_t, timept_t};
32 
34 #define REQUIRED 0x00
35 #define OPTIONAL 0x01
36 #define ENUM 0x02
37 #define INTERVAL 0x04
38 #define XLATE_GE_LT 0x08 /* Use .beg. and .end. synonyms for .ge. and .lt.
39  when providing user text for this selector. */
40 
41 #define SHOW_DEFAULT 0x10 /* Show the default values in the help text */
42 
44 typedef struct das_selector_t{
45 
47  const char* sKey;
48 
50  enum das_selfmt nFmt;
51 
53  unsigned int nFlags;
54 
57  const char** psBounds;
58 
59  /* A major design oversight: Should be allowed to place the default
60  values here. Since we can't do that the user ends up re-specifing
61  them all over the place in their programs which invites bugs! */
62  /* const char** psDefaults; */
63 
65  const char* sSummary;
66 
68  char** psValues;
69 
71 
72 
83 const char* das_get_selstr(const DasSelector* pSels, const char* sKey,
84  const char* sOp, const char* sDefault);
85 
86 const char* das_selstr(const DasSelector* pSel, const char* sOp,
87  const char* sDefault);
88 
92 int das_get_selint(const DasSelector* pSels, const char* sKey,
93  const char* sOp, int nDefault);
94 
95 int das_selint(const DasSelector* pSel, const char* sOp, int nDefault);
96 
97 
101 bool das_get_selbool(const DasSelector* pSels, const char* sKey, bool bDefault);
102 
103 bool das_selbool(const DasSelector* pSel, bool bDefault);
104 
105 
110 double das_get_selreal(const DasSelector* pSels, const char* sKey,
111  const char* sOp, double rDefault);
112 
115 double das_selreal(const DasSelector* pSel, const char* sOp, double rDefault);
116 
117 
121 void das_get_seltime(const DasSelector* pSels, const char* sKey, const char* sOp,
122  int* yr, int* mon, int* dom, int* doy, int* hr, int* min, double* sec);
123 
124 void das_seltime(const DasSelector* pSel, const char* sOp, int* yr, int* mon,
125  int* dom, int* doy, int* hr, int* min, double* sec);
126 
128 void das_get_seldastime(
129  const DasSelector* pSels, const char* sKey, const char* sOp, das_time* pDt
130 );
131 
133 void das_seldastime(const DasSelector* pSel, const char* sOp, das_time* pDt);
134 
135 
141 const char* das_get_selenum(const DasSelector* pSels, const char* sKey,
142  const char* sDefault);
143 
144 const char* das_selenum(const DasSelector* pSel, const char* sDefault);
145 
146 
149 #define DAS_OUT_DISABLE 0x0200
150 
154 typedef struct das_output_t{
155 
157  const char* sKey;
158 
160  const char* sUnits;
161 
163  unsigned int nOpts;
164 
166  const char** psDepends;
167 
169  const char* sSummary;
170 
172  char* sInterval;
173 
174 }DasOutput;
175 
176 
178 bool das_get_outenabled(const DasOutput* pOuts, const char* sKey);
179 
181 bool das_outenabled(const DasOutput* pOut);
182 
184 double das_get_outinterval(const DasOutput* pOuts, const char* sKey,
185  double rDefault);
186 
188 double das_outinterval(const DasOutput* pOut, double rDefault);
189 
191 const char* das_get_outunit(const DasOutput* pOut);
192 
193 
231 void das_parsecmdline(int nArgs, char** sArgs, DasSelector* pSels,
232  DasOutput* pOuts, const char* sDesc, const char* sFooter);
233 
234 
238 const char* das_progname();
239 
240 #define DAS_LL_CRIT 100 /* same as java.util.logging.Level.SEVERE */
241 #define DAS_LL_ERROR 80
242 #define DAS_LL_WARN 60 /* same as java.util.logging.Level.WARNING */
243 #define DAS_LL_INFO 40 /* same as java.util.logging.Level.INFO & CONFIG */
244 #define DAS_LL_DEBUG 20 /* same as java.util.logging.Level.FINE */
245 #define DAS_LL_TRACE 0 /* same as java.util.logging.Level.FINER & FINEST */
246 
254 int das_loglevel();
255 
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 
261 
262 #endif /* das2_2_cli_H_ */
const char * das_progname()
Get the program basename Only works after das_parsecmdline() has been called.
bool das_get_outenabled(const DasOutput *pOuts, const char *sKey)
Search for the enabled status for a named output.
double das_selreal(const DasSelector *pSel, const char *sOp, double rDefault)
Get a selection criteria from a particular selector as a double.
bool das_outenabled(const DasOutput *pOut)
Get the enabled status for a given output.
int das_loglevel()
Get the log level.
void das_get_seldastime(const DasSelector *pSels, const char *sKey, const char *sOp, das_time *pDt)
Equivalent to das_get_seltime but uses the new das_time type from time.h.
const char * das_get_selenum(const DasSelector *pSels, const char *sKey, const char *sDefault)
A short form of das_getstr for enumeration selectors.
void das_seldastime(const DasSelector *pSel, const char *sOp, das_time *pDt)
Equivalent to das_seltime but uses the new das_time type from time.h.
das_selfmt
An enumeration of das selector value types.
Definition: cli.h:31
double das_outinterval(const DasOutput *pOut, double rDefault)
Get the interval setting for a given output.
bool das_get_selbool(const DasSelector *pSels, const char *sKey, bool bDefault)
Get a selection criteria as a boolean Only works for BOOLEAN format selectors.
const char * das_get_selstr(const DasSelector *pSels, const char *sKey, const char *sOp, const char *sDefault)
Get the a selection boundary as a raw string.
int das_get_selint(const DasSelector *pSels, const char *sKey, const char *sOp, int nDefault)
Get the selection boundary as an integer This function only works for INTEGER parameter types.
void das_get_seltime(const DasSelector *pSels, const char *sKey, const char *sOp, int *yr, int *mon, int *dom, int *doy, int *hr, int *min, double *sec)
Parse the boundary value into a time tuple.
const char * das_get_outunit(const DasOutput *pOut)
Get the units for an output.
double das_get_selreal(const DasSelector *pSels, const char *sKey, const char *sOp, double rDefault)
Search for a selection criteria, return boundary value as a double.
void das_parsecmdline(int nArgs, char **sArgs, DasSelector *pSels, DasOutput *pOuts, const char *sDesc, const char *sFooter)
Parse a Das 2.3 style commandline, with Das 2.1 support.
double das_get_outinterval(const DasOutput *pOuts, const char *sKey, double rDefault)
Search for the interval setting for a named output.
Das 1 Compatability Utilities.
A basic statement of output is needed to help with output resolution reduction.
Definition: cli.h:153
Holds a single data selection query parameter.
Definition: cli.h:43
Basic date-time structure used throughout the Das1 & Das2 utilities.
Definition: time.h:43