forked from bminor/bash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assoc.hh
73 lines (51 loc) · 2.22 KB
/
assoc.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* assoc.h -- definitions for the interface exported by assoc.c that allows
the rest of the shell to manipulate associative array variables. */
/* Copyright (C) 2008,2009-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ASSOC_H_
#define _ASSOC_H_
#include "hashlib.hh"
namespace bash
{
constexpr int ASSOC_HASH_BUCKETS = 1024;
class SHELL_VAR;
// Subclass of HASH_TABLE for associative arrays.
class ASSOC_ARRAY : public HASH_TABLE<SHELL_VAR> {
public:
ASSOC_ARRAY () : HASH_TABLE<SHELL_VAR> (ASSOC_HASH_BUCKETS) {}
void insert (string_view, string_view);
};
#if 0
void assoc_dispose (HASH_TABLE *);
void assoc_flush (HASH_TABLE *);
int assoc_insert (HASH_TABLE *, char *, const char *);
void *assoc_replace (HASH_TABLE *, char *, const char *);
void assoc_remove (HASH_TABLE *, const char *);
char *assoc_reference (HASH_TABLE *, const char *);
char *assoc_subrange (HASH_TABLE *, arrayind_t, arrayind_t, int, int, int);
char *assoc_patsub (HASH_TABLE *, const char *, const char *, int);
char *assoc_modcase (HASH_TABLE *, const char *, int, int);
HASH_TABLE *assoc_quote (HASH_TABLE *);
HASH_TABLE *assoc_quote_escapes (HASH_TABLE *);
HASH_TABLE *assoc_dequote (HASH_TABLE *);
HASH_TABLE *assoc_dequote_escapes (HASH_TABLE *);
HASH_TABLE *assoc_remove_quoted_nulls (HASH_TABLE *);
char *assoc_to_kvpair (HASH_TABLE *, int);
char *assoc_to_assign (HASH_TABLE *, int);
WORD_LIST *assoc_to_word_list (HASH_TABLE *);
WORD_LIST *assoc_keys_to_word_list (HASH_TABLE *);
char *assoc_to_string (HASH_TABLE *, const char *, int);
#endif
} // namespace bash
#endif /* _ASSOC_H_ */