libsc 2.8.5.210-64a7
The SC library provides support for parallel scientific applications.
sc_keyvalue.h
Go to the documentation of this file.
1/*
2 This file is part of the SC Library.
3 The SC Library provides support for parallel scientific applications.
4
5 Copyright (C) 2010 The University of Texas System
6 Additional copyright (C) 2011 individual authors
7
8 The SC Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The SC Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the SC Library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef SC_KEYVALUE_H
25#define SC_KEYVALUE_H
26
31#include <sc_containers.h>
32
33SC_EXTERN_C_BEGIN;
34
36typedef enum
37{
45
47typedef struct sc_keyvalue sc_keyvalue_t;
48
53
62
72
77
85 const char *key);
86
94 const char *key);
95
105 const char *key, int dvalue);
106
116 const char *key, double dvalue);
117
127 const char *key,
128 const char *dvalue);
129
139 const char *key, void *dvalue);
140
157 const char *key, int *status);
158
166 const char *key, int newvalue);
167
175 const char *key, double newvalue);
176
184 const char *key,
185 const char *newvalue);
186
194 const char *key, void *newvalue);
195
203typedef int (*sc_keyvalue_foreach_t) (const char *key,
205 type, void *entry,
206 const void *u);
207
215 void *user_data);
216
217SC_EXTERN_C_END;
218
219#endif /* !SC_KEYVALUE_H */
Dynamic containers such as lists, arrays, and hash tables.
void sc_keyvalue_set_int(sc_keyvalue_t *kv, const char *key, int newvalue)
Routine to set an integer value for a given key.
void sc_keyvalue_foreach(sc_keyvalue_t *kv, sc_keyvalue_foreach_t fn, void *user_data)
Iterate through all stored key-value pairs.
struct sc_keyvalue sc_keyvalue_t
The key-value container is an opaque structure.
Definition: sc_keyvalue.h:47
int sc_keyvalue_get_int_check(sc_keyvalue_t *kv, const char *key, int *status)
Query an integer key with error checking.
sc_keyvalue_t * sc_keyvalue_new()
Create a new key-value container.
sc_keyvalue_entry_type_t
The values can have different types.
Definition: sc_keyvalue.h:37
@ SC_KEYVALUE_ENTRY_DOUBLE
Used for values of type double.
Definition: sc_keyvalue.h:40
@ SC_KEYVALUE_ENTRY_NONE
Designate an invalid situation.
Definition: sc_keyvalue.h:38
@ SC_KEYVALUE_ENTRY_POINTER
Used for values of anonymous pointer type.
Definition: sc_keyvalue.h:42
@ SC_KEYVALUE_ENTRY_STRING
Used for values of type const char *.
Definition: sc_keyvalue.h:41
@ SC_KEYVALUE_ENTRY_INT
Used for values of type int.
Definition: sc_keyvalue.h:39
sc_keyvalue_t * sc_keyvalue_newf(int dummy,...)
Create a container and set one or more key-value pairs.
void sc_keyvalue_destroy(sc_keyvalue_t *kv)
Free a key-value container and all internal memory for key storage.
sc_keyvalue_entry_type_t sc_keyvalue_unset(sc_keyvalue_t *kv, const char *key)
Routine to remove an entry.
void sc_keyvalue_set_double(sc_keyvalue_t *kv, const char *key, double newvalue)
Routine to set a double value for a given key.
void * sc_keyvalue_get_pointer(sc_keyvalue_t *kv, const char *key, void *dvalue)
Retrieve a pointer value by its key.
void sc_keyvalue_set_pointer(sc_keyvalue_t *kv, const char *key, void *newvalue)
Routine to set a pointer value for a given key.
void sc_keyvalue_set_string(sc_keyvalue_t *kv, const char *key, const char *newvalue)
Routine to set a string value for a given key.
sc_keyvalue_t * sc_keyvalue_newv(va_list ap)
Create a container and set one or more key-value pairs.
double sc_keyvalue_get_double(sc_keyvalue_t *kv, const char *key, double dvalue)
Retrieve a double value by its key.
int sc_keyvalue_get_int(sc_keyvalue_t *kv, const char *key, int dvalue)
Routines to retrieve an integer value by its key.
sc_keyvalue_entry_type_t sc_keyvalue_exists(sc_keyvalue_t *kv, const char *key)
Routine to check existence of an entry.
int(* sc_keyvalue_foreach_t)(const char *key, const sc_keyvalue_entry_type_t type, void *entry, const void *u)
Function to call on every key value pair.
Definition: sc_keyvalue.h:203
const char * sc_keyvalue_get_string(sc_keyvalue_t *kv, const char *key, const char *dvalue)
Retrieve a string value by its key.