CAEN Utility  2.0.2
Utilities for CAEN projects
CAENMap.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * CAEN SpA - Software Division
4 * Via Vetraia, 11 - 55049 - Viareggio ITALY
5 * +39 0594 388 398 - www.caen.it
6 *
7 *******************************************************************************
8 *
9 * Copyright (C) 2014 rxi
10 *
11 * This file is part of the CAEN Utility.
12 *
13 * This file is distributed under the MIT License.
14 *
15 * SPDX-License-Identifier: MIT
16 *
17 ***************************************************************************/
25 #ifndef CAEN_INCLUDE_CAENMAP_H_
26 #define CAEN_INCLUDE_CAENMAP_H_
27 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <types/CAENMapTypes.h>
41 #include <CAENUtility.h>
42 #include <stdint.h>
43 
51 #define c_map_init(m, nreserved) (((m) != NULL) ? _map_init(&(m)->base, (nreserved)) : c_Utility_ErrorCode_Map)
52 
59 #define c_map_init_default(m) c_map_init((m), 0)
60 
66 #define c_map_deinit(m) do { if ((m) != NULL) _map_deinit(&(m)->base); } while (0)
67 
75 #define c_map_get(m, key) (((m) != NULL) ? (m)->ref = _map_get(&(m)->base, (key)) : NULL)
76 
85 #define c_map_set(m, key, value) (((m) != NULL) ? ((m)->tmp = (value), _map_set(&(m)->base, (key), &(m)->tmp, sizeof((m)->tmp))) : c_Utility_ErrorCode_Map)
86 
93 #define c_map_remove(m, key) do { if ((m) != NULL) _map_remove(&(m)->base, (key)); } while (0)
94 
101 #define c_map_size(m) (((m) != NULL) ? _map_size(&(m)->base) : 0)
102 
108 #define c_map_iter() _map_iter()
109 
117 #define c_map_next(m, iter) (((m) != NULL) ? _map_next(&(m)->base, (iter)) : NULL)
118 
119 /***************************
120 * Function declaration, not to be used directly.
121 ***************************/
122 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API _map_init(c_map_base_t *m, size_t nreserved);
123 
125 
127 CAEN_UTILITY_DLLAPI void * CAEN_UTILITY_API _map_get(const c_map_base_t *m, const char *key);
128 
129 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API _map_set(c_map_base_t *m, const char *key, const void *value, size_t vsize);
130 
132 
135 
138 
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif // CAEN_INCLUDE_CAENMAP_H_
Base type for maps.
Definition: CAENMapTypes.h:50
#define CAEN_UTILITY_API
Definition: CAENUtility.h:104
Definitions and types for CAENMAP.h.
Main header and generic tools.
size_t _map_size(const c_map_base_t *m)
Definition: CAENMap.c:241
c_map_iter_t _map_iter(void)
Definition: CAENMap.c:247
#define CAEN_UTILITY_DLLAPI
Definition: CAENUtility.h:105
void _map_deinit(c_map_base_t *m)
Definition: CAENMap.c:165
void * _map_get(const c_map_base_t *m, const char *key)
Definition: CAENMap.c:184
#define c_nodiscard
Definition: CAENUtility.h:245
Iterator.
Definition: CAENMapTypes.h:58
int32_t _map_init(c_map_base_t *m, size_t nreserved)
Definition: CAENMap.c:149
int32_t _map_set(c_map_base_t *m, const char *key, const void *value, size_t vsize)
Definition: CAENMap.c:195
const char * _map_next(const c_map_base_t *m, c_map_iter_t *iter)
Definition: CAENMap.c:256
void _map_remove(c_map_base_t *m, const char *key)
Definition: CAENMap.c:226