]> git.ipfire.org Git - thirdparty/squid.git/blob - src/wordlist.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / wordlist.h
1 /*
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_WORDLIST_H
10 #define SQUID_WORDLIST_H
11
12 #include "globals.h"
13 #include "profiler/Profiler.h"
14 #include "sbuf/List.h"
15
16 /** A list of C-strings
17 *
18 * \deprecated use SBufList instead
19 */
20 class wordlist
21 {
22 MEMPROXY_CLASS(wordlist);
23 friend char *wordlistChopHead(wordlist **);
24
25 public:
26 wordlist() : key(nullptr), next(nullptr) {}
27 // create a new wordlist node, with a copy of k as key
28 explicit wordlist(const char *k) : key(xstrdup(k)), next(nullptr) {}
29
30 wordlist(const wordlist &) = delete;
31 wordlist &operator=(const wordlist &) = delete;
32
33 char *key;
34 wordlist *next;
35
36 private:
37 // does not free data members.
38 ~wordlist() = default;
39 };
40
41 class MemBuf;
42
43 /** Add a null-terminated c-string to a wordlist
44 *
45 * \deprecated use SBufList.push_back(SBuf(word)) instead
46 */
47 const char *wordlistAdd(wordlist **, const char *);
48
49 /** Concatenate a wordlist
50 *
51 * \deprecated use SBufListContainerJoin(SBuf()) from sbuf/Algorithms.h instead
52 */
53 void wordlistCat(const wordlist *, MemBuf *);
54
55 /// destroy a wordlist
56 void wordlistDestroy(wordlist **);
57
58 /** Remove and destroy the first element while preserving and returning its key
59 *
60 * \note the returned key must be freed by the caller using safe_free
61 * \note wl is altered so that it points to the second element
62 * \return nullptr if pointed-to wordlist is nullptr.
63 */
64 char *wordlistChopHead(wordlist **);
65
66 /// convert a wordlist to a SBufList
67 SBufList ToSBufList(wordlist *);
68
69 #endif /* SQUID_WORDLIST_H */
70