ucx/cx/map.h

Tue, 14 Oct 2025 21:02:26 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 14 Oct 2025 21:02:26 +0200
branch
dav-2
changeset 887
26541c37b619
parent 886
da79af4baec8
child 889
42cdbf9bbd49
permissions
-rw-r--r--

add TODOs for using modern ucx features

747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
29 * @file map.h
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
30 * @brief Interface for map implementations.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
31 * @author Mike Becker
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
32 * @author Olaf Wintermann
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
33 * @copyright 2-Clause BSD License
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #ifndef UCX_MAP_H
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #define UCX_MAP_H
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "common.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "collection.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include "string.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #include "hash_key.h"
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #ifdef __cplusplus
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 extern "C" {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 #endif
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 /** Type for the UCX map. */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 typedef struct cx_map_s CxMap;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 /** Type for a map entry. */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 typedef struct cx_map_entry_s CxMapEntry;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
54 /** Type for a map iterator. */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
55 typedef struct cx_map_iterator_s CxMapIterator;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
56
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 /** Type for map class definitions. */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 typedef struct cx_map_class_s cx_map_class;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 /** Structure for the UCX map. */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 struct cx_map_s {
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
62 /**
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
63 * Base attributes.
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
64 */
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
65 CX_COLLECTION_BASE;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 /** The map class definition. */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 cx_map_class *cl;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 };
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
71 * A map entry.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
72 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
73 struct cx_map_entry_s {
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
74 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
75 * A pointer to the key.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
76 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
77 const CxHashKey *key;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
78 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
79 * A pointer to the value.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
80 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
81 void *value;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
82 };
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
83
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
84 /**
750
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
85 * The type of iterator for a map.
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
86 */
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
87 enum cx_map_iterator_type {
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
88 /**
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
89 * Iterates over key/value pairs.
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
90 */
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
91 CX_MAP_ITERATOR_PAIRS,
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
92 /**
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
93 * Iterates over keys only.
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
94 */
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
95 CX_MAP_ITERATOR_KEYS,
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
96 /**
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
97 * Iterates over values only.
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
98 */
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
99 CX_MAP_ITERATOR_VALUES
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
100 };
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
101
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
102 /**
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
103 * Internal iterator struct - use CxMapIterator.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
104 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
105 struct cx_map_iterator_s {
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
106 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
107 * Inherited common data for all iterators.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
108 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
109 CX_ITERATOR_BASE;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
110
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
111 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
112 * Handle for the source map.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
113 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
114 union {
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
115 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
116 * Access for mutating iterators.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
117 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
118 CxMap *m;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
119 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
120 * Access for normal iterators.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
121 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
122 const CxMap *c;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
123 } map;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
124
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
125 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
126 * Handle for the current element.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
127 *
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
128 * @attention Depends on the map implementation, do not assume a type (better: do not use!).
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
129 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
130 void *elem;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
131
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
132 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
133 * Reserved memory for a map entry.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
134 *
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
135 * If a map implementation uses an incompatible layout, the iterator needs something
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
136 * to point to during iteration which @em is compatible.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
137 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
138 CxMapEntry entry;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
139
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
140 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
141 * Field for storing the current slot number.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
142 *
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
143 * (Used internally)
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
144 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
145 size_t slot;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
146
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
147 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
148 * Counts the elements successfully.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
149 * It usually does not denote a stable index within the map as it would be for arrays.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
150 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
151 size_t index;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
152
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
153 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
154 * The size of a value stored in this map.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
155 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
156 size_t elem_size;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
157
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
158 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
159 * May contain the total number of elements, if known.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
160 * Set to @c SIZE_MAX when the total number is unknown during iteration.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
161 *
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
162 * @remark The UCX implementations of #CxMap always know the number of elements they store.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
163 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
164 size_t elem_count;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
165
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
166 /**
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
167 * The type of this iterator.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
168 */
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
169 enum cx_map_iterator_type type;
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
170 };
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
171
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
172 /**
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 * The class definition for arbitrary maps.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 struct cx_map_class_s {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 * Deallocates the entire memory.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
179 void (*deallocate)(struct cx_map_s *map);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 * Removes all elements.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 void (*clear)(struct cx_map_s *map);
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 * Add or overwrite an element.
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
188 * If the @p value is @c NULL, the implementation
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
189 * shall only allocate memory instead of adding an existing value to the map.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
190 * Returns a pointer to the allocated memory or @c NULL if allocation fails.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 */
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
192 void *(*put)(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 CxHashKey key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 );
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 * Returns an element.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 void *(*get)(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
202 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 CxHashKey key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 );
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 * Removes an element.
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
208 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
209 * Implementations SHALL check if @p targetbuf is set and copy the elements
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
210 * to the buffer without invoking any destructor.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
211 * When @p targetbuf is not set, the destructors SHALL be invoked.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
212 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
213 * The function SHALL return zero when the @p key was found and
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
214 * non-zero, otherwise.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
216 int (*remove)(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 CxHashKey key,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
219 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 );
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 /**
750
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
223 * Creates an iterator for this map.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 */
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
225 CxMapIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 };
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 750
diff changeset
228 /**
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 750
diff changeset
229 * A shared instance of an empty map.
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 750
diff changeset
230 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
231 * Writing to that map is not allowed.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
232 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
233 * You can use this is a placeholder for initializing CxMap pointers
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
234 * for which you do not want to reserve memory right from the beginning.
775
e5909dff0dbf update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 750
diff changeset
235 */
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
236 cx_attr_export
750
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
237 extern CxMap *const cxEmptyMap;
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
238
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 * Deallocates the memory of the specified map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
242 * Also calls the content destructor functions for each element, if specified.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
243 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
244 * @param map the map to be freed
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 */
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
246 cx_attr_export
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
247 void cxMapFree(CxMap *map);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 * Clears a map by removing all elements.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
253 * Also calls the content destructor functions for each element, if specified.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
254 *
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 * @param map the map to be cleared
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
257 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 static inline void cxMapClear(CxMap *map) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 map->cl->clear(map);
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
262 /**
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
263 * Returns the number of elements in this map.
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
264 *
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
265 * @param map the map
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
266 * @return the number of stored elements
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
267 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
268 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
269 static inline size_t cxMapSize(const CxMap *map) {
816
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
270 return map->collection.size;
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
271 }
839fefbdedc7 compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents: 775
diff changeset
272
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 * Creates a value iterator for a map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 *
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
276 * When the map is storing pointers, those pointers are returned.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
277 * Otherwise, the iterator iterates over pointers to the memory within the map where the
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
278 * respective elements are stored.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
279 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
280 * @note An iterator iterates over all elements successively. Therefore, the order
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 * highly depends on the map implementation and may change arbitrarily when the contents change.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
283 * @param map the map to create the iterator for (can be @c NULL)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 * @return an iterator for the currently stored values
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
286 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
287 static inline CxMapIterator cxMapIteratorValues(const CxMap *map) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
288 if (map == NULL) map = cxEmptyMap;
750
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
289 return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 * Creates a key iterator for a map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 *
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
295 * The elements of the iterator are keys of type CxHashKey and the pointer returned
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
296 * during iterator shall be treated as @c const @c CxHashKey* .
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
298 * @note An iterator iterates over all elements successively. Therefore, the order
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 * highly depends on the map implementation and may change arbitrarily when the contents change.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
301 * @param map the map to create the iterator for (can be @c NULL)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 * @return an iterator for the currently stored keys
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
304 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
305 static inline CxMapIterator cxMapIteratorKeys(const CxMap *map) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
306 if (map == NULL) map = cxEmptyMap;
750
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
307 return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 * Creates an iterator for a map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 *
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
313 * The elements of the iterator are key/value pairs of type CxMapEntry and the pointer returned
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
314 * during iterator shall be treated as @c const @c CxMapEntry* .
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
316 * @note An iterator iterates over all elements successively. Therefore, the order
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 * highly depends on the map implementation and may change arbitrarily when the contents change.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
319 * @param map the map to create the iterator for (can be @c NULL)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 * @return an iterator for the currently stored entries
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 * @see cxMapIteratorKeys()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 * @see cxMapIteratorValues()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
324 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
325 static inline CxMapIterator cxMapIterator(const CxMap *map) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
326 if (map == NULL) map = cxEmptyMap;
750
4d7a2238c5ac update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 747
diff changeset
327 return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 * Creates a mutating iterator over the values of a map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 *
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
334 * When the map is storing pointers, those pointers are returned.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
335 * Otherwise, the iterator iterates over pointers to the memory within the map where the
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
336 * respective elements are stored.
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
337 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
338 * @note An iterator iterates over all elements successively. Therefore, the order
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 * highly depends on the map implementation and may change arbitrarily when the contents change.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
341 * @param map the map to create the iterator for (can be @c NULL)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 * @return an iterator for the currently stored values
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
344 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
345 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
346 CxMapIterator cxMapMutIteratorValues(CxMap *map);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 * Creates a mutating iterator over the keys of a map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 *
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
351 * The elements of the iterator are keys of type CxHashKey and the pointer returned
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
352 * during iterator shall be treated as @c const @c CxHashKey* .
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
354 * @note An iterator iterates over all elements successively. Therefore, the order
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 * highly depends on the map implementation and may change arbitrarily when the contents change.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
357 * @param map the map to create the iterator for (can be @c NULL)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 * @return an iterator for the currently stored keys
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
360 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
361 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
362 CxMapIterator cxMapMutIteratorKeys(CxMap *map);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 * Creates a mutating iterator for a map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 *
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
367 * The elements of the iterator are key/value pairs of type CxMapEntry and the pointer returned
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
368 * during iterator shall be treated as @c const @c CxMapEntry* .
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
370 * @note An iterator iterates over all elements successively. Therefore, the order
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 * highly depends on the map implementation and may change arbitrarily when the contents change.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 *
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
373 * @param map the map to create the iterator for (can be @c NULL)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 * @return an iterator for the currently stored entries
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 * @see cxMapMutIteratorKeys()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 * @see cxMapMutIteratorValues()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
378 cx_attr_nodiscard
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
379 cx_attr_export
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
380 CxMapIterator cxMapMutIterator(CxMap *map);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 #ifdef __cplusplus
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 } // end the extern "C" block here, because we want to start overloading
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
384 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 static inline int cxMapPut(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 CxHashKey const &key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
390 return map->cl->put(map, key, value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
393 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 static inline int cxMapPut(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 cxstring const &key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
399 return map->cl->put(map, cx_hash_key_cxstr(key), value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
402 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 static inline int cxMapPut(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 cxmutstr const &key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
408 return map->cl->put(map, cx_hash_key_cxstr(key), value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
411 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
412 cx_attr_cstr_arg(2)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 static inline int cxMapPut(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
415 const char *key,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
418 return map->cl->put(map, cx_hash_key_str(key), value) == NULL;
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
419 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
420
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
421 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
422 static inline void *cxMapEmplace(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
423 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
424 CxHashKey const &key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
425 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
426 return map->cl->put(map, key, NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
427 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
428
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
429 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
430 static inline void *cxMapEmplace(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
431 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
432 cxstring const &key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
433 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
434 return map->cl->put(map, cx_hash_key_cxstr(key), NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
435 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
436
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
437 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
438 static inline void *cxMapEmplace(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
439 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
440 cxmutstr const &key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
441 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
442 return map->cl->put(map, cx_hash_key_cxstr(key), NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
443 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
444
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
445 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
446 cx_attr_cstr_arg(2)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
447 static inline void *cxMapEmplace(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
448 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
449 const char *key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
450 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
451 return map->cl->put(map, cx_hash_key_str(key), NULL);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
454 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
455 cx_attr_nodiscard
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 static inline void *cxMapGet(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
457 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 CxHashKey const &key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 return map->cl->get(map, key);
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
463 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
464 cx_attr_nodiscard
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 static inline void *cxMapGet(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
466 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 cxstring const &key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 return map->cl->get(map, cx_hash_key_cxstr(key));
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
472 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
473 cx_attr_nodiscard
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 static inline void *cxMapGet(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
475 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 cxmutstr const &key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478 return map->cl->get(map, cx_hash_key_cxstr(key));
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
481 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
482 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
483 cx_attr_cstr_arg(2)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 static inline void *cxMapGet(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
485 const CxMap *map,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
486 const char *key
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 return map->cl->get(map, cx_hash_key_str(key));
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
491 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
492 static inline int cxMapRemove(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 CxHashKey const &key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
496 return map->cl->remove(map, key, nullptr);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
499 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
500 static inline int cxMapRemove(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 cxstring const &key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
504 return map->cl->remove(map, cx_hash_key_cxstr(key), nullptr);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
506
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
507 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
508 static inline int cxMapRemove(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 cxmutstr const &key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
512 return map->cl->remove(map, cx_hash_key_cxstr(key), nullptr);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
515 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
516 cx_attr_cstr_arg(2)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
517 static inline int cxMapRemove(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
519 const char *key
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
521 return map->cl->remove(map, cx_hash_key_str(key), nullptr);
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
522 }
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
523
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
524 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
525 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
526 static inline int cxMapRemoveAndGet(
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
527 CxMap *map,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
528 CxHashKey key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
529 void *targetbuf
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
530 ) {
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
531 return map->cl->remove(map, key, targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
532 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
533
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
534 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
535 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
536 static inline int cxMapRemoveAndGet(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
537 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
538 cxstring key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
539 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
541 return map->cl->remove(map, cx_hash_key_cxstr(key), targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
542 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
544 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
545 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
546 static inline int cxMapRemoveAndGet(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
547 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
548 cxmutstr key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
549 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
550 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
551 return map->cl->remove(map, cx_hash_key_cxstr(key), targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
554 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
555 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
556 cx_attr_cstr_arg(2)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
557 static inline int cxMapRemoveAndGet(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
559 const char *key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
560 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
562 return map->cl->remove(map, cx_hash_key_str(key), targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 #else // __cplusplus
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
568 * @copydoc cxMapPut()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
570 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 static inline int cx_map_put(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 CxHashKey key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
576 return map->cl->put(map, key, value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
580 * @copydoc cxMapPut()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
582 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 static inline int cx_map_put_cxstr(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 cxstring key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
588 return map->cl->put(map, cx_hash_key_cxstr(key), value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
592 * @copydoc cxMapPut()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
594 cx_attr_nonnull
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
595 static inline int cx_map_put_mustr(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
596 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597 cxmutstr key,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
600 return map->cl->put(map, cx_hash_key_cxstr(key), value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
604 * @copydoc cxMapPut()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
606 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
607 cx_attr_cstr_arg(2)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 static inline int cx_map_put_str(
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
610 const char *key,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 void *value
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612 ) {
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
613 return map->cl->put(map, cx_hash_key_str(key), value) == NULL;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
614 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
615
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
616 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
617 * Puts a key/value-pair into the map.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
618 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
619 * A possible existing value will be overwritten.
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
620 * If destructor functions are specified, they are called for
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
621 * the overwritten element.
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
622 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
623 * If this map is storing pointers, the @p value pointer is written
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
624 * to the map. Otherwise, the memory is copied from @p value with
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
625 * memcpy().
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
626 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
627 * The @p key is always copied.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
628 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
629 * @param map (@c CxMap*) the map
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
630 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
631 * @param value (@c void*) the value
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
632 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
633 * @retval non-zero value on memory allocation failure
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
634 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
635 #define cxMapPut(map, key, value) _Generic((key), \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636 CxHashKey: cx_map_put, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
637 cxstring: cx_map_put_cxstr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 cxmutstr: cx_map_put_mustr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 char*: cx_map_put_str, \
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
640 const char*: cx_map_put_str) \
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
641 (map, key, value)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 /**
886
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
644 * @copydoc cxMapEmplace()
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
645 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
646 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
647 static inline void *cx_map_emplace(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
648 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
649 CxHashKey key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
650 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
651 return map->cl->put(map, key, NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
652 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
653
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
654 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
655 * @copydoc cxMapEmplace()
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
656 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
657 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
658 static inline void *cx_map_emplace_cxstr(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
659 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
660 cxstring key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
661 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
662 return map->cl->put(map, cx_hash_key_cxstr(key), NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
663 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
664
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
665 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
666 * @copydoc cxMapEmplace()
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
667 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
668 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
669 static inline void *cx_map_emplace_mustr(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
670 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
671 cxmutstr key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
672 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
673 return map->cl->put(map, cx_hash_key_cxstr(key), NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
674 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
675
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
676 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
677 * @copydoc cxMapEmplace()
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
678 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
679 cx_attr_nonnull
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
680 cx_attr_cstr_arg(2)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
681 static inline void *cx_map_emplace_str(
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
682 CxMap *map,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
683 const char *key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
684 ) {
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
685 return map->cl->put(map, cx_hash_key_str(key), NULL);
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
686 }
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
687
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
688 /**
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
689 * Allocates memory for a value in the map associated with the specified key.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
690 *
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
691 * A possible existing value will be overwritten.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
692 * If destructor functions are specified, they are called for
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
693 * the overwritten element.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
694 *
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
695 * If the map is storing pointers, this function returns a @c void** pointer,
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
696 * meaning a pointer to that pointer.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
697 *
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
698 * The @p key is always copied.
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
699 *
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
700 * @param map (@c CxMap*) the map
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
701 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
702 * @return the pointer to the allocated memory or @c NULL if allocation fails
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
703 * @retval zero success
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
704 * @retval non-zero value on memory allocation failure
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
705 */
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
706 #define cxMapEmplace(map, key) _Generic((key), \
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
707 CxHashKey: cx_map_emplace, \
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
708 cxstring: cx_map_emplace_cxstr, \
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
709 cxmutstr: cx_map_emplace_mustr, \
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
710 char*: cx_map_emplace_str, \
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
711 const char*: cx_map_emplace_str) \
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
712 (map, key)
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
713
da79af4baec8 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 854
diff changeset
714 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
715 * @copydoc cxMapGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
716 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
717 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
718 cx_attr_nodiscard
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
719 static inline void *cx_map_get(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
720 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
721 CxHashKey key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
722 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
723 return map->cl->get(map, key);
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
724 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
725
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
726 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
727 * @copydoc cxMapGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
728 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
729 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
730 cx_attr_nodiscard
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
731 static inline void *cx_map_get_cxstr(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
732 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
733 cxstring key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
734 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
735 return map->cl->get(map, cx_hash_key_cxstr(key));
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
736 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
737
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
738 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
739 * @copydoc cxMapGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
740 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
741 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
742 cx_attr_nodiscard
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
743 static inline void *cx_map_get_mustr(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
744 const CxMap *map,
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
745 cxmutstr key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
746 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
747 return map->cl->get(map, cx_hash_key_cxstr(key));
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
748 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
749
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
750 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
751 * @copydoc cxMapGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
752 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
753 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
754 cx_attr_nodiscard
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
755 cx_attr_cstr_arg(2)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
756 static inline void *cx_map_get_str(
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
757 const CxMap *map,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
758 const char *key
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
759 ) {
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
760 return map->cl->get(map, cx_hash_key_str(key));
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
761 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
762
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
763 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
764 * Retrieves a value by using a key.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
765 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
766 * If this map is storing pointers, the stored pointer is returned.
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
767 * Otherwise, a pointer to the element within the map's memory
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
768 * is returned (which is valid as long as the element stays in the map).
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
769 *
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
770 * @param map (@c CxMap*) the map
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
771 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
772 * @return (@c void*) the value
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
773 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
774 #define cxMapGet(map, key) _Generic((key), \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
775 CxHashKey: cx_map_get, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
776 cxstring: cx_map_get_cxstr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
777 cxmutstr: cx_map_get_mustr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
778 char*: cx_map_get_str, \
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
779 const char*: cx_map_get_str) \
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
780 (map, key)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
781
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
782 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
783 * @copydoc cxMapRemove()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
784 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
785 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
786 static inline int cx_map_remove(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
787 CxMap *map,
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
788 CxHashKey key
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
789 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
790 return map->cl->remove(map, key, NULL);
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
791 }
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
792
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
793 /**
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
794 * @copydoc cxMapRemove()
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
795 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
796 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
797 static inline int cx_map_remove_cxstr(
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
798 CxMap *map,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
799 cxstring key
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
800 ) {
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
801 return map->cl->remove(map, cx_hash_key_cxstr(key), NULL);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
802 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
803
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
804 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
805 * @copydoc cxMapRemove()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
806 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
807 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
808 static inline int cx_map_remove_mustr(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
809 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
810 cxmutstr key
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
811 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
812 return map->cl->remove(map, cx_hash_key_cxstr(key), NULL);
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
813 }
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
814
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
815 /**
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
816 * @copydoc cxMapRemove()
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
817 */
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
818 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
819 cx_attr_cstr_arg(2)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
820 static inline int cx_map_remove_str(
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
821 CxMap *map,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
822 const char *key
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
823 ) {
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
824 return map->cl->remove(map, cx_hash_key_str(key), NULL);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
825 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
826
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
827 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
828 * Removes a key/value-pair from the map by using the key.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
829 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
830 * Always invokes the destructors functions, if any, on the removed element.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
831 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
832 * @param map (@c CxMap*) the map
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
833 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
834 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
835 * @retval non-zero the key was not found
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
836 *
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
837 * @see cxMapRemoveAndGet()
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
838 */
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
839 #define cxMapRemove(map, key) _Generic((key), \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
840 CxHashKey: cx_map_remove, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
841 cxstring: cx_map_remove_cxstr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
842 cxmutstr: cx_map_remove_mustr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
843 char*: cx_map_remove_str, \
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
844 const char*: cx_map_remove_str) \
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
845 (map, key)
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
846
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
847 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
848 * @copydoc cxMapRemoveAndGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
849 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
850 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
851 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
852 static inline int cx_map_remove_and_get(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
853 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
854 CxHashKey key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
855 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
856 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
857 return map->cl->remove(map, key, targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
858 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
859
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
860 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
861 * @copydoc cxMapRemoveAndGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
862 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
863 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
864 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
865 static inline int cx_map_remove_and_get_cxstr(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
866 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
867 cxstring key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
868 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
869 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
870 return map->cl->remove(map, cx_hash_key_cxstr(key), targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
871 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
872
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
873 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
874 * @copydoc cxMapRemoveAndGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
875 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
876 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
877 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
878 static inline int cx_map_remove_and_get_mustr(
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
879 CxMap *map,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
880 cxmutstr key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
881 void *targetbuf
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
882 ) {
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
883 return map->cl->remove(map, cx_hash_key_cxstr(key), targetbuf);
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
884 }
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
885
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
886 /**
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
887 * @copydoc cxMapRemoveAndGet()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
888 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
889 cx_attr_nonnull
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
890 cx_attr_access_w(3)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
891 cx_attr_cstr_arg(2)
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
892 static inline int cx_map_remove_and_get_str(
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
893 CxMap *map,
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
894 const char *key,
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
895 void *targetbuf
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
896 ) {
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
897 return map->cl->remove(map, cx_hash_key_str(key), targetbuf);
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
898 }
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
899
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
900 /**
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
901 * Removes a key/value-pair from the map by using the key.
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
902 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
903 * This function will copy the contents of the removed element
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
904 * to the target buffer, which must be guaranteed to be large enough
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
905 * to hold the element (the map's element size).
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
906 * The destructor functions, if any, will @em not be called.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
907 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
908 * If this map is storing pointers, the element is the pointer itself
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
909 * and not the object it points to.
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
910 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
911 * @param map (@c CxMap*) the map
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
912 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
913 * @param targetbuf (@c void*) the buffer where the element shall be copied to
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
914 * @retval zero success
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
915 * @retval non-zero the key was not found
854
1c8401ece69e update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 852
diff changeset
916 *
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
917 * @see cxMapRemove()
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
918 */
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
919 #define cxMapRemoveAndGet(map, key, targetbuf) _Generic((key), \
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
920 CxHashKey: cx_map_remove_and_get, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
921 cxstring: cx_map_remove_and_get_cxstr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
922 cxmutstr: cx_map_remove_and_get_mustr, \
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
923 char*: cx_map_remove_and_get_str, \
852
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
924 const char*: cx_map_remove_and_get_str) \
83fdf679df99 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 816
diff changeset
925 (map, key, targetbuf)
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
926
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
927 #endif // __cplusplus
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
928
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
929 #endif // UCX_MAP_H

mercurial