LAL  7.5.0.1-08ee4f4
LALDict.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2016 Jolien Creighton
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 #ifndef _LAL_DICT_H
21 #define _LAL_DICT_H
22 
23 #include <stdio.h>
24 #include <stddef.h>
25 #include <lal/LALDatatypes.h>
26 #include <lal/LALValue.h>
27 #include <lal/LALList.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #elif 0
32 } /* so that editors will match preceding brace */
33 #endif
34 
35 struct tagLALDictEntry;
36 typedef struct tagLALDictEntry LALDictEntry;
37 
38 struct tagLALDict;
39 typedef struct tagLALDict LALDict;
40 
42  /* private data */
43  struct tagLALDict *dict;
45  size_t pos;
46 };
47 typedef struct tagLALDictIter LALDictIter;
48 
49 void XLALDictEntryFree(LALDictEntry *list);
50 LALDictEntry * XLALDictEntryAlloc(size_t size);
51 LALDictEntry * XLALDictEntryRealloc(LALDictEntry *entry, size_t size);
52 LALDictEntry * XLALDictEntrySetKey(LALDictEntry *entry, const char *key);
53 LALDictEntry * XLALDictEntrySetValue(LALDictEntry *entry, const void *data, size_t size, LALTYPECODE type);
54 
55 /* warning: shallow pointer */
56 const char * XLALDictEntryGetKey(const LALDictEntry *entry);
57 /* warning: shallow pointer */
58 const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry);
59 
60 void XLALDestroyDict(LALDict *dict);
61 LALDict * XLALCreateDict(void);
62 LALDict * XLALDictDuplicate(LALDict *old);
63 
64 void XLALDictForeach(LALDict *dict, void (*func)(char *, LALValue *, void *), void *thunk);
65 LALDictEntry * XLALDictFind(LALDict *dict, int (*func)(const char *, const LALValue *, void *), void *thunk);
66 void XLALDictIterInit(LALDictIter *iter, LALDict *dict);
67 LALDictEntry * XLALDictIterNext(LALDictIter *iter);
68 
69 LALList * XLALDictKeys(const LALDict *dict);
70 LALList * XLALDictValues(const LALDict *dict);
71 
72 int XLALDictContains(const LALDict *dict, const char *key);
73 size_t XLALDictSize(const LALDict *dict);
74 int XLALDictRemove(LALDict *dict, const char *key);
75 int XLALDictInsert(LALDict *dict, const char *key, const void *data, size_t size, LALTYPECODE type);
76 int XLALDictInsertValue(LALDict *dict, const char *key, const LALValue *value);
77 int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size);
78 int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string);
79 int XLALDictInsertCHARValue(LALDict *dict, const char *key, CHAR value);
80 int XLALDictInsertINT2Value(LALDict *dict, const char *key, INT2 value);
81 int XLALDictInsertINT4Value(LALDict *dict, const char *key, INT4 value);
82 int XLALDictInsertINT8Value(LALDict *dict, const char *key, INT8 value);
83 int XLALDictInsertUCHARValue(LALDict *dict, const char *key, UCHAR value);
84 int XLALDictInsertUINT2Value(LALDict *dict, const char *key, UINT2 value);
85 int XLALDictInsertUINT4Value(LALDict *dict, const char *key, UINT4 value);
86 int XLALDictInsertUINT8Value(LALDict *dict, const char *key, UINT8 value);
87 int XLALDictInsertREAL4Value(LALDict *dict, const char *key, REAL4 value);
88 int XLALDictInsertREAL8Value(LALDict *dict, const char *key, REAL8 value);
89 int XLALDictInsertCOMPLEX8Value(LALDict *dict, const char *key, COMPLEX8 value);
90 int XLALDictInsertCOMPLEX16Value(LALDict *dict, const char *key, COMPLEX16 value);
91 
92 LALDictEntry *XLALDictLookup(LALDict *dict, const char *key);
93 void * XLALDictLookupBLOBValue(LALDict *dict, const char *key);
94 /* warning: shallow pointer */
95 const char * XLALDictLookupStringValue(LALDict *dict, const char *key);
96 CHAR XLALDictLookupCHARValue(LALDict *dict, const char *key);
97 INT2 XLALDictLookupINT2Value(LALDict *dict, const char *key);
98 INT4 XLALDictLookupINT4Value(LALDict *dict, const char *key);
99 INT8 XLALDictLookupINT8Value(LALDict *dict, const char *key);
100 UCHAR XLALDictLookupUCHARValue(LALDict *dict, const char *key);
101 UINT2 XLALDictLookupUINT2Value(LALDict *dict, const char *key);
102 UINT4 XLALDictLookupUINT4Value(LALDict *dict, const char *key);
103 UINT8 XLALDictLookupUINT8Value(LALDict *dict, const char *key);
104 REAL4 XLALDictLookupREAL4Value(LALDict *dict, const char *key);
105 REAL8 XLALDictLookupREAL8Value(LALDict *dict, const char *key);
106 COMPLEX8 XLALDictLookupCOMPLEX8Value(LALDict *dict, const char *key);
107 COMPLEX16 XLALDictLookupCOMPLEX16Value(LALDict *dict, const char *key);
108 
109 REAL8 XLALDictLookupValueAsREAL8(LALDict *dict, const char *key);
110 
111 char * XLALDictAsStringAppend(char *s, LALDict *dict);
112 void XLALDictPrint(LALDict *dict, int fd);
113 
114 #if 0
115 { /* so that editors will match succeeding brace */
116 #elif defined(__cplusplus)
117 }
118 #endif
119 #endif /* _LAL_DICT_H */
CHAR XLALDictLookupCHARValue(LALDict *dict, const char *key)
int XLALDictInsertUINT4Value(LALDict *dict, const char *key, UINT4 value)
int XLALDictInsertUINT2Value(LALDict *dict, const char *key, UINT2 value)
int XLALDictContains(const LALDict *dict, const char *key)
Definition: LALDict.c:261
INT4 XLALDictLookupINT4Value(LALDict *dict, const char *key)
LALList * XLALDictKeys(const LALDict *dict)
Definition: LALDict.c:221
int XLALDictInsertINT2Value(LALDict *dict, const char *key, INT2 value)
const char * XLALDictLookupStringValue(LALDict *dict, const char *key)
Definition: LALDict.c:425
LALDictEntry * XLALDictEntrySetValue(LALDictEntry *entry, const void *data, size_t size, LALTYPECODE type)
Definition: LALDict.c:106
const char * XLALDictEntryGetKey(const LALDictEntry *entry)
Definition: LALDict.c:114
COMPLEX8 XLALDictLookupCOMPLEX8Value(LALDict *dict, const char *key)
UCHAR XLALDictLookupUCHARValue(LALDict *dict, const char *key)
LALDictEntry * XLALDictEntrySetKey(LALDictEntry *entry, const char *key)
Definition: LALDict.c:97
REAL8 XLALDictLookupREAL8Value(LALDict *dict, const char *key)
int XLALDictInsert(LALDict *dict, const char *key, const void *data, size_t size, LALTYPECODE type)
Definition: LALDict.c:313
int XLALDictInsertINT8Value(LALDict *dict, const char *key, INT8 value)
void XLALDictEntryFree(LALDictEntry *list)
Definition: LALDict.c:61
INT2 XLALDictLookupINT2Value(LALDict *dict, const char *key)
char * XLALDictAsStringAppend(char *s, LALDict *dict)
Definition: LALDict.c:491
COMPLEX16 XLALDictLookupCOMPLEX16Value(LALDict *dict, const char *key)
int XLALDictRemove(LALDict *dict, const char *key)
Definition: LALDict.c:291
LALDictEntry * XLALDictIterNext(LALDictIter *iter)
Definition: LALDict.c:179
void XLALDestroyDict(LALDict *dict)
Definition: LALDict.c:127
UINT8 XLALDictLookupUINT8Value(LALDict *dict, const char *key)
UINT2 XLALDictLookupUINT2Value(LALDict *dict, const char *key)
int XLALDictInsertCOMPLEX16Value(LALDict *dict, const char *key, COMPLEX16 value)
int XLALDictInsertINT4Value(LALDict *dict, const char *key, INT4 value)
LALDictEntry * XLALDictEntryAlloc(size_t size)
Definition: LALDict.c:73
int XLALDictInsertREAL8Value(LALDict *dict, const char *key, REAL8 value)
LALDictEntry * XLALDictEntryRealloc(LALDictEntry *entry, size_t size)
Definition: LALDict.c:84
int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size)
Definition: LALDict.c:373
LALDictEntry * XLALDictLookup(LALDict *dict, const char *key)
Definition: LALDict.c:282
LALDictEntry * XLALDictFind(LALDict *dict, int(*func)(const char *, const LALValue *, void *), void *thunk)
Definition: LALDict.c:159
void * XLALDictLookupBLOBValue(LALDict *dict, const char *key)
Definition: LALDict.c:411
size_t XLALDictSize(const LALDict *dict)
Definition: LALDict.c:270
int XLALDictInsertCOMPLEX8Value(LALDict *dict, const char *key, COMPLEX8 value)
void XLALDictIterInit(LALDictIter *iter, LALDict *dict)
Definition: LALDict.c:171
int XLALDictInsertUINT8Value(LALDict *dict, const char *key, UINT8 value)
LALDict * XLALDictDuplicate(LALDict *old)
Definition: LALDict.c:198
const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry)
Definition: LALDict.c:120
REAL8 XLALDictLookupValueAsREAL8(LALDict *dict, const char *key)
Definition: LALDict.c:464
int XLALDictInsertUCHARValue(LALDict *dict, const char *key, UCHAR value)
int XLALDictInsertValue(LALDict *dict, const char *key, const LALValue *value)
Definition: LALDict.c:365
UINT4 XLALDictLookupUINT4Value(LALDict *dict, const char *key)
void XLALDictPrint(LALDict *dict, int fd)
Definition: LALDict.c:500
INT8 XLALDictLookupINT8Value(LALDict *dict, const char *key)
int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
Definition: LALDict.c:380
REAL4 XLALDictLookupREAL4Value(LALDict *dict, const char *key)
LALList * XLALDictValues(const LALDict *dict)
Definition: LALDict.c:241
LALDict * XLALCreateDict(void)
Definition: LALDict.c:138
void XLALDictForeach(LALDict *dict, void(*func)(char *, LALValue *, void *), void *thunk)
Definition: LALDict.c:148
int XLALDictInsertREAL4Value(LALDict *dict, const char *key, REAL4 value)
int XLALDictInsertCHARValue(LALDict *dict, const char *key, CHAR value)
LALTYPECODE
Type codes: use these type codes to identify a LAL atomic data type, see Headers LAL(Atomic)Datatypes...
Definition: LALDatatypes.h:49
unsigned char UCHAR
One-byte unsigned integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
uint16_t UINT2
Two-byte unsigned integer.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
Definition: LALDict.c:40
struct tagLALDictEntry * next
Definition: LALDict.h:44
struct tagLALDict * dict
Definition: LALDict.h:43
size_t pos
Definition: LALDict.h:45