Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
30extern "C" {
31#elif 0
32} /* so that editors will match preceding brace */
33#endif
34
35struct tagLALDictEntry;
36typedef struct tagLALDictEntry LALDictEntry;
37
38struct tagLALDict;
39typedef struct tagLALDict LALDict;
40
42 /* private data */
45 size_t pos;
46};
47typedef struct tagLALDictIter LALDictIter;
48
49void XLALDictEntryFree(LALDictEntry *list);
50LALDictEntry * XLALDictEntryAlloc(size_t size);
51LALDictEntry * XLALDictEntryRealloc(LALDictEntry *entry, size_t size);
52LALDictEntry * XLALDictEntrySetKey(LALDictEntry *entry, const char *key);
53LALDictEntry * XLALDictEntrySetValue(LALDictEntry *entry, const void *data, size_t size, LALTYPECODE type);
54
55/* warning: shallow pointer */
56const char * XLALDictEntryGetKey(const LALDictEntry *entry);
57/* warning: shallow pointer */
58const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry);
59
60void XLALClearDict(LALDict *dict);
61void XLALDestroyDict(LALDict *dict);
62LALDict * XLALCreateDict(void);
63int XLALDictUpdate(LALDict *dst, const LALDict *src);
64LALDict * XLALDictMerge(const LALDict *dict1, const LALDict *dict2);
65LALDict * XLALDictDuplicate(const LALDict *orig);
66
67void XLALDictForeach(LALDict *dict, void (*func)(char *, LALValue *, void *), void *thunk);
68LALDictEntry * XLALDictFind(LALDict *dict, int (*func)(const char *, const LALValue *, void *), void *thunk);
69void XLALDictIterInit(LALDictIter *iter, LALDict *dict);
70LALDictEntry * XLALDictIterNext(LALDictIter *iter);
71
72LALList * XLALDictKeys(const LALDict *dict);
73LALList * XLALDictValues(const LALDict *dict);
74
75int XLALDictContains(const LALDict *dict, const char *key);
76size_t XLALDictSize(const LALDict *dict);
77int XLALDictRemove(LALDict *dict, const char *key);
78int XLALDictInsert(LALDict *dict, const char *key, const void *data, size_t size, LALTYPECODE type);
79int XLALDictInsertValue(LALDict *dict, const char *key, const LALValue *value);
80int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size);
81int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string);
82int XLALDictInsertCHARValue(LALDict *dict, const char *key, CHAR value);
83int XLALDictInsertINT2Value(LALDict *dict, const char *key, INT2 value);
84int XLALDictInsertINT4Value(LALDict *dict, const char *key, INT4 value);
85int XLALDictInsertINT8Value(LALDict *dict, const char *key, INT8 value);
86int XLALDictInsertUCHARValue(LALDict *dict, const char *key, UCHAR value);
87int XLALDictInsertUINT2Value(LALDict *dict, const char *key, UINT2 value);
88int XLALDictInsertUINT4Value(LALDict *dict, const char *key, UINT4 value);
89int XLALDictInsertUINT8Value(LALDict *dict, const char *key, UINT8 value);
90int XLALDictInsertREAL4Value(LALDict *dict, const char *key, REAL4 value);
91int XLALDictInsertREAL8Value(LALDict *dict, const char *key, REAL8 value);
92int XLALDictInsertCOMPLEX8Value(LALDict *dict, const char *key, COMPLEX8 value);
93int XLALDictInsertCOMPLEX16Value(LALDict *dict, const char *key, COMPLEX16 value);
94
95LALDictEntry *XLALDictLookup(const LALDict *dict, const char *key);
96void * XLALDictLookupBLOBValue(const LALDict *dict, const char *key);
97/* warning: shallow pointer */
98const char * XLALDictLookupStringValue(const LALDict *dict, const char *key);
99CHAR XLALDictLookupCHARValue(const LALDict *dict, const char *key);
100INT2 XLALDictLookupINT2Value(const LALDict *dict, const char *key);
101INT4 XLALDictLookupINT4Value(const LALDict *dict, const char *key);
102INT8 XLALDictLookupINT8Value(const LALDict *dict, const char *key);
103UCHAR XLALDictLookupUCHARValue(const LALDict *dict, const char *key);
104UINT2 XLALDictLookupUINT2Value(const LALDict *dict, const char *key);
105UINT4 XLALDictLookupUINT4Value(const LALDict *dict, const char *key);
106UINT8 XLALDictLookupUINT8Value(const LALDict *dict, const char *key);
107REAL4 XLALDictLookupREAL4Value(const LALDict *dict, const char *key);
108REAL8 XLALDictLookupREAL8Value(const LALDict *dict, const char *key);
109COMPLEX8 XLALDictLookupCOMPLEX8Value(const LALDict *dict, const char *key);
110COMPLEX16 XLALDictLookupCOMPLEX16Value(const LALDict *dict, const char *key);
111REAL8 XLALDictLookupValueAsREAL8(const LALDict *dict, const char *key);
112
113LALDictEntry * XLALDictPop(LALDict *dict, const char *key);
114LALValue * XLALDictPopValue(LALDict *dict, const char *key);
115void * XLALDictPopBLOBValue(LALDict *dict, const char *key);
116char * XLALDictPopStringValue(LALDict *dict, const char *key);
117CHAR XLALDictPopCHARValue(LALDict *dict, const char *key);
118INT2 XLALDictPopINT2Value(LALDict *dict, const char *key);
119INT4 XLALDictPopINT4Value(LALDict *dict, const char *key);
120INT8 XLALDictPopINT8Value(LALDict *dict, const char *key);
121UCHAR XLALDictPopUCHARValue(LALDict *dict, const char *key);
122UINT2 XLALDictPopUINT2Value(LALDict *dict, const char *key);
123UINT4 XLALDictPopUINT4Value(LALDict *dict, const char *key);
124UINT8 XLALDictPopUINT8Value(LALDict *dict, const char *key);
125REAL4 XLALDictPopREAL4Value(LALDict *dict, const char *key);
126REAL8 XLALDictPopREAL8Value(LALDict *dict, const char *key);
127COMPLEX8 XLALDictPopCOMPLEX8Value(LALDict *dict, const char *key);
128COMPLEX16 XLALDictPopCOMPLEX16Value(LALDict *dict, const char *key);
129REAL8 XLALDictPopValueAsREAL8(LALDict *dict, const char *key);
130
131
132char * XLALDictAsStringAppend(char *s, const LALDict *dict);
133void XLALDictPrint(const LALDict *dict, int fd);
134
135#if 0
136{ /* so that editors will match succeeding brace */
137#elif defined(__cplusplus)
138}
139#endif
140#endif /* _LAL_DICT_H */
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:284
UINT8 XLALDictLookupUINT8Value(const LALDict *dict, const char *key)
LALDictEntry * XLALDictIterNext(LALDictIter *iter)
Definition: LALDict.c:189
void * XLALDictPopBLOBValue(LALDict *dict, const char *key)
Definition: LALDict.c:518
COMPLEX8 XLALDictLookupCOMPLEX8Value(const LALDict *dict, const char *key)
LALValue * XLALDictPopValue(LALDict *dict, const char *key)
Definition: LALDict.c:507
INT8 XLALDictLookupINT8Value(const LALDict *dict, const char *key)
int XLALDictInsertINT2Value(LALDict *dict, const char *key, INT2 value)
REAL8 XLALDictLookupValueAsREAL8(const LALDict *dict, const char *key)
Definition: LALDict.c:494
LALList * XLALDictKeys(const LALDict *dict)
Definition: LALDict.c:244
int XLALDictUpdate(LALDict *dst, const LALDict *src)
Definition: LALDict.c:208
LALDictEntry * XLALDictEntrySetValue(LALDictEntry *entry, const void *data, size_t size, LALTYPECODE type)
Definition: LALDict.c:106
COMPLEX16 XLALDictPopCOMPLEX16Value(LALDict *dict, const char *key)
LALDictEntry * XLALDictPop(LALDict *dict, const char *key)
Definition: LALDict.c:314
COMPLEX8 XLALDictPopCOMPLEX8Value(LALDict *dict, const char *key)
LALDictEntry * XLALDictEntryAlloc(size_t size)
Definition: LALDict.c:73
int XLALDictInsert(LALDict *dict, const char *key, const void *data, size_t size, LALTYPECODE type)
Definition: LALDict.c:344
REAL8 XLALDictPopREAL8Value(LALDict *dict, const char *key)
int XLALDictInsertINT8Value(LALDict *dict, const char *key, INT8 value)
LALDictEntry * XLALDictLookup(const LALDict *dict, const char *key)
Definition: LALDict.c:305
CHAR XLALDictPopCHARValue(LALDict *dict, const char *key)
char * XLALDictPopStringValue(LALDict *dict, const char *key)
Definition: LALDict.c:529
REAL8 XLALDictLookupREAL8Value(const LALDict *dict, const char *key)
LALDict * XLALDictMerge(const LALDict *dict1, const LALDict *dict2)
Definition: LALDict.c:225
void * XLALDictLookupBLOBValue(const LALDict *dict, const char *key)
Definition: LALDict.c:442
const char * XLALDictLookupStringValue(const LALDict *dict, const char *key)
Definition: LALDict.c:455
UINT4 XLALDictLookupUINT4Value(const LALDict *dict, const char *key)
void XLALDictEntryFree(LALDictEntry *list)
Definition: LALDict.c:61
int XLALDictRemove(LALDict *dict, const char *key)
Definition: LALDict.c:335
INT2 XLALDictLookupINT2Value(const LALDict *dict, const char *key)
void XLALDestroyDict(LALDict *dict)
Definition: LALDict.c:137
LALDict * XLALDictDuplicate(const LALDict *orig)
Definition: LALDict.c:239
UINT4 XLALDictPopUINT4Value(LALDict *dict, const char *key)
CHAR XLALDictLookupCHARValue(const LALDict *dict, const char *key)
LALDict * XLALCreateDict(void)
Definition: LALDict.c:148
int XLALDictInsertCOMPLEX16Value(LALDict *dict, const char *key, COMPLEX16 value)
LALList * XLALDictValues(const LALDict *dict)
Definition: LALDict.c:264
void XLALClearDict(LALDict *dict)
Definition: LALDict.c:127
int XLALDictInsertINT4Value(LALDict *dict, const char *key, INT4 value)
LALDictEntry * XLALDictEntrySetKey(LALDictEntry *entry, const char *key)
Definition: LALDict.c:97
int XLALDictInsertREAL8Value(LALDict *dict, const char *key, REAL8 value)
INT2 XLALDictPopINT2Value(LALDict *dict, const char *key)
int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size)
Definition: LALDict.c:404
INT4 XLALDictPopINT4Value(LALDict *dict, const char *key)
INT4 XLALDictLookupINT4Value(const LALDict *dict, const char *key)
size_t XLALDictSize(const LALDict *dict)
Definition: LALDict.c:293
int XLALDictInsertCOMPLEX8Value(LALDict *dict, const char *key, COMPLEX8 value)
void XLALDictIterInit(LALDictIter *iter, LALDict *dict)
Definition: LALDict.c:181
int XLALDictInsertUINT8Value(LALDict *dict, const char *key, UINT8 value)
REAL4 XLALDictLookupREAL4Value(const LALDict *dict, const char *key)
COMPLEX16 XLALDictLookupCOMPLEX16Value(const LALDict *dict, const char *key)
REAL4 XLALDictPopREAL4Value(LALDict *dict, const char *key)
UINT8 XLALDictPopUINT8Value(LALDict *dict, const char *key)
UINT2 XLALDictPopUINT2Value(LALDict *dict, const char *key)
INT8 XLALDictPopINT8Value(LALDict *dict, const char *key)
void XLALDictPrint(const LALDict *dict, int fd)
Definition: LALDict.c:601
int XLALDictInsertUCHARValue(LALDict *dict, const char *key, UCHAR value)
int XLALDictInsertValue(LALDict *dict, const char *key, const LALValue *value)
Definition: LALDict.c:396
char * XLALDictAsStringAppend(char *s, const LALDict *dict)
Definition: LALDict.c:591
UCHAR XLALDictLookupUCHARValue(const LALDict *dict, const char *key)
const char * XLALDictEntryGetKey(const LALDictEntry *entry)
Definition: LALDict.c:114
int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
Definition: LALDict.c:411
const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry)
Definition: LALDict.c:120
UCHAR XLALDictPopUCHARValue(LALDict *dict, const char *key)
LALDictEntry * XLALDictFind(LALDict *dict, int(*func)(const char *, const LALValue *, void *), void *thunk)
Definition: LALDict.c:169
void XLALDictForeach(LALDict *dict, void(*func)(char *, LALValue *, void *), void *thunk)
Definition: LALDict.c:158
int XLALDictInsertREAL4Value(LALDict *dict, const char *key, REAL4 value)
int XLALDictInsertCHARValue(LALDict *dict, const char *key, CHAR value)
LALDictEntry * XLALDictEntryRealloc(LALDictEntry *entry, size_t size)
Definition: LALDict.c:84
REAL8 XLALDictPopValueAsREAL8(LALDict *dict, const char *key)
Definition: LALDict.c:566
UINT2 XLALDictLookupUINT2Value(const LALDict *dict, const char *key)
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