ucl 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE-DEPENDENCIES.md +161 -0
- data/README.md +104 -15
- data/ext/extconf.rb +42 -40
- data/ext/libucl/COPYING +23 -0
- data/ext/libucl/include/ucl.h +1689 -0
- data/ext/libucl/klib/khash.h +627 -0
- data/ext/libucl/klib/kvec.h +161 -0
- data/ext/libucl/src/mum.h +440 -0
- data/ext/libucl/src/tree.h +209 -0
- data/ext/libucl/src/ucl_chartable.h +267 -0
- data/ext/libucl/src/ucl_emitter.c +721 -0
- data/ext/libucl/src/ucl_emitter_streamline.c +178 -0
- data/ext/libucl/src/ucl_emitter_utils.c +521 -0
- data/ext/libucl/src/ucl_hash.c +642 -0
- data/ext/libucl/src/ucl_hash.h +115 -0
- data/ext/libucl/src/ucl_internal.h +668 -0
- data/ext/libucl/src/ucl_msgpack.c +1574 -0
- data/ext/libucl/src/ucl_parser.c +3247 -0
- data/ext/libucl/src/ucl_schema.c +1102 -0
- data/ext/libucl/src/ucl_sexp.c +229 -0
- data/ext/libucl/src/ucl_util.c +4004 -0
- data/ext/libucl/uthash/uthash.h +720 -0
- data/ext/libucl/uthash/utlist.h +1076 -0
- data/ext/libucl/uthash/utstring.h +412 -0
- data/ext/ucl.c +308 -89
- data/test/test_ucl.rb +129 -0
- data/ucl.gemspec +20 -7
- metadata +25 -17
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* Copyright (c) 2013, Vsevolod Stakhov
|
|
2
|
+
* All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5
|
+
* modification, are permitted provided that the following conditions are met:
|
|
6
|
+
* * Redistributions of source code must retain the above copyright
|
|
7
|
+
* notice, this list of conditions and the following disclaimer.
|
|
8
|
+
* * Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
* documentation and/or other materials provided with the distribution.
|
|
11
|
+
*
|
|
12
|
+
* THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
|
|
13
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
14
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
15
|
+
* DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
|
|
16
|
+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
17
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
18
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
19
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
20
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
21
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#ifndef __UCL_HASH_H
|
|
25
|
+
#define __UCL_HASH_H
|
|
26
|
+
|
|
27
|
+
#include "ucl.h"
|
|
28
|
+
|
|
29
|
+
/******************************************************************************/
|
|
30
|
+
|
|
31
|
+
struct ucl_hash_node_s;
|
|
32
|
+
typedef struct ucl_hash_node_s ucl_hash_node_t;
|
|
33
|
+
|
|
34
|
+
typedef int (*ucl_hash_cmp_func)(const void *void_a, const void *void_b);
|
|
35
|
+
typedef void (*ucl_hash_free_func)(void *ptr);
|
|
36
|
+
typedef void *ucl_hash_iter_t;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Linear chained hashtable.
|
|
41
|
+
*/
|
|
42
|
+
struct ucl_hash_struct;
|
|
43
|
+
typedef struct ucl_hash_struct ucl_hash_t;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Initializes the hashtable.
|
|
48
|
+
*/
|
|
49
|
+
ucl_hash_t *ucl_hash_create(bool ignore_case);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Deinitializes the hashtable.
|
|
53
|
+
*/
|
|
54
|
+
void ucl_hash_destroy(ucl_hash_t *hashlin, ucl_hash_free_func func);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Inserts an element in the the hashtable.
|
|
58
|
+
* @return true on success, false on failure (i.e. ENOMEM)
|
|
59
|
+
*/
|
|
60
|
+
bool ucl_hash_insert(ucl_hash_t *hashlin, const ucl_object_t *obj, const char *key,
|
|
61
|
+
unsigned keylen);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Replace element in the hash
|
|
65
|
+
*/
|
|
66
|
+
void ucl_hash_replace(ucl_hash_t *hashlin, const ucl_object_t *old,
|
|
67
|
+
const ucl_object_t *new);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Delete an element from the the hashtable.
|
|
71
|
+
*/
|
|
72
|
+
void ucl_hash_delete(ucl_hash_t *hashlin, const ucl_object_t *obj);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Searches an element in the hashtable.
|
|
76
|
+
*/
|
|
77
|
+
const ucl_object_t *ucl_hash_search(ucl_hash_t *hashlin, const char *key,
|
|
78
|
+
unsigned keylen);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Iterate over hash table
|
|
83
|
+
* @param hashlin hash
|
|
84
|
+
* @param iter iterator (must be NULL on first iteration)
|
|
85
|
+
* @param ep pointer record exception (such as ENOMEM), could be NULL
|
|
86
|
+
* @return the next object
|
|
87
|
+
*/
|
|
88
|
+
const void *ucl_hash_iterate2(ucl_hash_t *hashlin, ucl_hash_iter_t *iter, int *ep);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Helper macro to support older code
|
|
92
|
+
*/
|
|
93
|
+
#define ucl_hash_iterate(hl, ip) ucl_hash_iterate2((hl), (ip), NULL)
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Check whether an iterator has next element
|
|
97
|
+
*/
|
|
98
|
+
bool ucl_hash_iter_has_next(ucl_hash_t *hashlin, ucl_hash_iter_t iter);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Free a hash iterator (used when iteration is abandoned early)
|
|
102
|
+
* @param iter iterator to free, may be NULL
|
|
103
|
+
*/
|
|
104
|
+
void ucl_hash_iterate_free(ucl_hash_iter_t iter);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Reserves space in hash
|
|
108
|
+
* @return true on sucess, false on failure (e.g. ENOMEM)
|
|
109
|
+
* @param hashlin
|
|
110
|
+
*/
|
|
111
|
+
bool ucl_hash_reserve(ucl_hash_t *hashlin, size_t sz);
|
|
112
|
+
|
|
113
|
+
void ucl_hash_sort(ucl_hash_t *hashlin, enum ucl_object_keys_sort_flags fl);
|
|
114
|
+
|
|
115
|
+
#endif
|