]> git.ipfire.org Git - thirdparty/squid.git/blame - src/wordlist.h
initial version of libsbuf
[thirdparty/squid.git] / src / wordlist.h
CommitLineData
d295d770 1/*
ef57eb7b 2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
d295d770 3 *
bbc27441
AJ
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.
d295d770 7 */
bbc27441 8
d295d770 9#ifndef SQUID_WORDLIST_H
10#define SQUID_WORDLIST_H
11
582c2af2 12#include "globals.h"
582c2af2 13#include "profiler/Profiler.h"
65e41a45 14#include "sbuf/SBufList.h"
d295d770 15
6a17a36d
FC
16/** A list of C-strings
17 *
18 * \deprecated use SBufList instead
19 */
d295d770 20class wordlist
21{
d295d770 22 MEMPROXY_CLASS(wordlist);
0d225c05 23 friend char *wordlistChopHead(wordlist **);
741c2986
AJ
24
25public:
0d225c05
FC
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
d295d770 33 char *key;
34 wordlist *next;
0d225c05
FC
35
36private:
2f373c58 37 // does not free data members.
0d225c05 38 ~wordlist() = default;
d295d770 39};
40
9ce629cf 41class MemBuf;
514fc315 42
6a17a36d
FC
43/** Add a null-terminated c-string to a wordlist
44 *
45 * \deprecated use SBufList.push_back(SBuf(word)) instead
46 */
8a648e8d 47const char *wordlistAdd(wordlist **, const char *);
514fc315 48
6a17a36d
FC
49/** Concatenate a wordlist
50 *
65e41a45 51 * \deprecated use SBufListContainerJoin(SBuf()) from sbuf/SBufAlgos.h instead
6a17a36d
FC
52 */
53void wordlistCat(const wordlist *, MemBuf *);
514fc315 54
6a17a36d
FC
55/** append a wordlist to another
56 *
57 * \deprecated use SBufList.merge(otherwordlist) instead
58 */
8a648e8d 59void wordlistAddWl(wordlist **, wordlist *);
514fc315 60
6a17a36d
FC
61/** Concatenate the words in a wordlist
62 *
65e41a45 63 * \deprecated use SBufListContainerJoin(SBuf()) from sbuf/SBufAlgos.h instead
6a17a36d 64 */
8a648e8d 65void wordlistJoin(wordlist **, wordlist **);
514fc315 66
6a17a36d 67/// destroy a wordlist
8a648e8d 68void wordlistDestroy(wordlist **);
d295d770 69
2f373c58 70/** Remove and destroy the first element while preserving and returning its key
0d225c05
FC
71 *
72 * \note the returned key must be freed by the caller using safe_free
73 * \note wl is altered so that it points to the second element
74 * \return nullptr if pointed-to wordlist is nullptr.
75 */
76char *wordlistChopHead(wordlist **);
77
514fc315
FC
78/// convert a wordlist to a SBufList
79SBufList ToSBufList(wordlist *);
80
d295d770 81#endif /* SQUID_WORDLIST_H */
f53969cc 82