libsc 2.8.7.187-a49fd
The SC library provides support for parallel scientific applications.
Loading...
Searching...
No Matches
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
33#include <sc_containers.h>
34
35SC_EXTERN_C_BEGIN;
36
47
49typedef struct sc_keyvalue sc_keyvalue_t;
50
55
64
74
79
87 const char *key);
88
96 const char *key);
97
107 const char *key, int dvalue);
108
118 const char *key, double dvalue);
119
129 const char *key,
130 const char *dvalue);
131
141 const char *key, void *dvalue);
142
159 const char *key, int *status);
160
168 const char *key, int newvalue);
169
177 const char *key, double newvalue);
178
186 const char *key,
187 const char *newvalue);
188
196 const char *key, void *newvalue);
197
205typedef int (*sc_keyvalue_foreach_t) (const char *key,
207 type, void *entry,
208 const void *u);
209
217 void *user_data);
218
219SC_EXTERN_C_END;
220
221#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:49
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:39
@ SC_KEYVALUE_ENTRY_DOUBLE
Used for values of type double.
Definition sc_keyvalue.h:42
@ SC_KEYVALUE_ENTRY_NONE
Designate an invalid situation.
Definition sc_keyvalue.h:40
@ SC_KEYVALUE_ENTRY_POINTER
Used for values of anonymous pointer type.
Definition sc_keyvalue.h:44
@ SC_KEYVALUE_ENTRY_STRING
Used for values of type const char *.
Definition sc_keyvalue.h:43
@ SC_KEYVALUE_ENTRY_INT
Used for values of type int.
Definition sc_keyvalue.h:41
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:205
const char * sc_keyvalue_get_string(sc_keyvalue_t *kv, const char *key, const char *dvalue)
Retrieve a string value by its key.