libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
descriptor.h
Go to the documentation of this file.
1 /* Copyright (C) 2004-2017 Jeremy Faden <jeremy-faden@uiowa.edu>
2  * Chris Piker <chris-piker@uiowa.edu>
3  *
4  * This file is part of libdas2, the Core Das2 C Library.
5  *
6  * Libdas2 is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
21 #ifndef _descriptor_h_
22 #define _descriptor_h_
23 #include <stdbool.h>
24 
25 #include <das2/units.h>
26 #include <das2/util.h>
27 #include <das2/buffer.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
41 typedef enum DescriptorType {
42  Unknown=0, PLANE=14001, PACKET=14002, STREAM=14003, VARIABLE=1500,
43  DATASET=1501
44 } desc_type_t;
45 
46 
80 typedef struct das_descriptor {
81  desc_type_t type;
82  char* properties[DAS_XML_MAXPROPS];
83  const struct das_descriptor* parent;
84  bool bLooseParsing;
85 } DasDesc;
86 
87 
102 void DasDesc_init(DasDesc* pThis, desc_type_t type);
103 
104 /* Make an 'Unknown' type descriptor, incase you like using descriptor objects
105  * to store things in your code, not used by the library
106  * @memberof DasDesc
107  */
108 DasDesc* new_Descriptor(void);
109 
110 void DasDesc_freeProps(DasDesc* pThis);
111 
125 bool DasDesc_equals(const DasDesc* pOne, const DasDesc* pTwo);
126 
138 const DasDesc* DasDesc_parent(DasDesc* pThis);
139 
157 size_t DasDesc_length(const DasDesc* pThis);
158 
173 const char* DasDesc_getNameByIdx(const DasDesc* pThis, size_t uIdx);
174 
189 const char* DasDesc_getValByIdx(const DasDesc* pThis, size_t uIdx);
190 
194 const char* DasDesc_getTypeByIdx(const DasDesc* pThis, size_t uIdx);
195 
196 
205 bool DasDesc_has(const DasDesc* pThis, const char* propertyName );
206 
234  DasDesc* pThis, const char* sType, const char* sName, const char* sVal
235 );
236 
237 const char* DasDesc_get(const DasDesc* pThis, const char * propertyName );
238 
239 
249 bool DasDesc_remove(DasDesc* pThis, const char* propretyName);
250 
254 const char* DasDesc_getStr(const DasDesc* pThis, const char * propertyName );
255 
262  DasDesc* pThis, const char* sName, const char* sVal
263 );
264 
269  DasDesc* pThis, const char* sName, const char* sFmt, ...
270 );
271 
272 
277 double DasDesc_getDouble(const DasDesc* pThis, const char * propertyName);
278 
282 DasErrCode DasDesc_setDouble(DasDesc* pThis, const char * propertyName, double value);
283 
298 double DasDesc_getDatum(DasDesc* pThis, const char * sPropName,
299  das_units units );
300 
314  DasDesc* pThis, const char* sName, double rVal, das_units units
315 );
316 
336 double* DasDesc_getDoubleAry(DasDesc* pThis, const char * propertyName,
337  int *nitems );
338 
343  DasDesc* pThis, const char * propertyName, int nitems, double *value
344 );
345 
356 int DasDesc_getInt(const DasDesc* pThis, const char* propertyName);
357 
361 DasErrCode DasDesc_setInt(DasDesc* pThis, const char * sName, int nVal);
362 
370 bool DasDesc_getBool(DasDesc* pThis, const char* sPropName);
371 
378 DasErrCode DasDesc_setBool(DasDesc* pThis, const char* sPropName, bool bVal);
379 
384 DasDesc* pThis, const char * sName, double beg, double end, das_units units
385 );
386 
395  DasDesc* pThis, const char* sName, char* sMin, char* sMax,
396  das_units* pUnits, size_t uLen
397 );
398 
404  DasDesc* pThis, const char * propertyName, int nitems, float *value
405 );
406 
412 void DasDesc_copyIn(DasDesc* pThis, const DasDesc* source );
413 
422 DasErrCode DasDesc_encode(DasDesc* pThis, DasBuf* pBuf, const char* sIndent);
425 #ifdef __cplusplus
426 }
427 #endif
428 
429 #endif /* _descriptor_h_ */
DasErrCode DasDesc_set(DasDesc *pThis, const char *sType, const char *sName, const char *sVal)
Generic property setter.
bool DasDesc_remove(DasDesc *pThis, const char *propretyName)
Remove a property from a descriptor, if preset.
size_t DasDesc_length(const DasDesc *pThis)
Get the number of properties in a descriptor.
desc_type_t
enumeration of Descriptor types, used internally for type checking.
Definition: descriptor.h:41
DasErrCode DasDesc_getStrRng(DasDesc *pThis, const char *sName, char *sMin, char *sMax, das_units *pUnits, size_t uLen)
Get a property of type DatumRange with unconverted strings.
bool DasDesc_getBool(DasDesc *pThis, const char *sPropName)
Get a property boolean value.
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: util.h:117
Little buffer class to handle accumulating string data.
Definition: buffer.h:49
#define DAS_XML_MAXPROPS
limit of number of properties per descriptor.
Definition: util.h:379
DasErrCode DasDesc_setDouble(DasDesc *pThis, const char *propertyName, double value)
Set property of type double.
double * DasDesc_getDoubleAry(DasDesc *pThis, const char *propertyName, int *nitems)
Get the values of an array property.
const char * DasDesc_getTypeByIdx(const DasDesc *pThis, size_t uIdx)
Get a data type of a property by an index.
Base structure for Stream Header Items.
Definition: descriptor.h:80
bool DasDesc_has(const DasDesc *pThis, const char *propertyName)
Determine if a property is present in a Descriptor or it&#39;s ancestors.
const DasDesc * DasDesc_parent(DasDesc *pThis)
The the parent of a Descriptor.
DasErrCode DasDesc_encode(DasDesc *pThis, DasBuf *pBuf, const char *sIndent)
Encode a generic set of properties to a buffer.
double DasDesc_getDatum(DasDesc *pThis, const char *sPropName, das_units units)
Get the a numeric property in the specified units.
void DasDesc_copyIn(DasDesc *pThis, const DasDesc *source)
Deepcopy properties into a descriptor.
DasErrCode DasDesc_setDoubleArray(DasDesc *pThis, const char *propertyName, int nitems, double *value)
Set the property of type double array.
const char * DasDesc_getNameByIdx(const DasDesc *pThis, size_t uIdx)
Get a property name by an index.
Defines units used for items in the stream, most notably time units that reference an epoch and a ste...
DasErrCode DasDesc_setStr(DasDesc *pThis, const char *sName, const char *sVal)
SetProperty methods add properties to any Descriptor (stream,packet,plane).
bool DasDesc_equals(const DasDesc *pOne, const DasDesc *pTwo)
Check to see if two descriptors contain the same properties Note, the order of the properties may be ...
Utility to assist with encode and decode operations.
DasErrCode DasDesc_setDatum(DasDesc *pThis, const char *sName, double rVal, das_units units)
Set property of type Datum (double, UnitType pair)
DasErrCode DasDesc_vSetStr(DasDesc *pThis, const char *sName, const char *sFmt,...)
Set a string property in the manner of sprintf.
DasErrCode DasDesc_setInt(DasDesc *pThis, const char *sName, int nVal)
Set the property of type int.
const char * DasDesc_getStr(const DasDesc *pThis, const char *propertyName)
read the property of type String named propertyName.
const char * DasDesc_getValByIdx(const DasDesc *pThis, size_t uIdx)
Get a property value by an index.
double DasDesc_getDouble(const DasDesc *pThis, const char *propertyName)
Read the property of type double named propertyName.
int DasDesc_getInt(const DasDesc *pThis, const char *propertyName)
Get a property integer value.
DasErrCode DasDesc_setFloatAry(DasDesc *pThis, const char *propertyName, int nitems, float *value)
Set the property of type float array.
const char * das_units
Enumeration of unit types, that correspond to physical unit types.
Definition: units.h:135
DasErrCode DasDesc_setDatumRng(DasDesc *pThis, const char *sName, double beg, double end, das_units units)
Set property of type DatumRange (double, double, UnitType triple)
DasErrCode DasDesc_setBool(DasDesc *pThis, const char *sPropName, bool bVal)
Set a boolean property Encodes the value as either the string &quot;true&quot; or the string &quot;false&quot;...