]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/StringData.cc
Merged from trunk
[thirdparty/squid.git] / src / acl / StringData.cc
1 /*
2 * Copyright (C) 1996-2015 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 /* DEBUG: section 28 Access Control */
10
11 #include "squid.h"
12 #include "acl/Checklist.h"
13 #include "acl/StringData.h"
14 #include "cache_cf.h"
15 #include "Debug.h"
16
17 ACLStringData::ACLStringData()
18 {}
19
20 ACLStringData::ACLStringData(ACLStringData const &old) : stringValues(old.stringValues)
21 {
22 }
23
24 ACLStringData::~ACLStringData()
25 {
26 }
27
28 void
29 ACLStringData::insert(const char *value)
30 {
31 stringValues.insert(SBuf(value));
32 }
33
34 bool
35 ACLStringData::match(char const *toFind)
36 {
37 if (stringValues.empty() || !toFind)
38 return 0;
39
40 SBuf tf(toFind);
41 debugs(28, 3, "aclMatchStringList: checking '" << tf << "'");
42
43 bool found = (stringValues.find(tf) != stringValues.end());
44 debugs(28, 3, "aclMatchStringList: '" << tf << "' " << (found ? "found" : "NOT found"));
45
46 return found;
47 }
48
49 SBufList
50 ACLStringData::dump() const
51 {
52 SBufList sl;
53 sl.insert(sl.end(), stringValues.begin(), stringValues.end());
54 return sl;
55 }
56
57 void
58 ACLStringData::parse()
59 {
60 char *t;
61 while ((t = strtokFile()))
62 stringValues.insert(SBuf(t));
63 }
64
65 bool
66 ACLStringData::empty() const
67 {
68 return stringValues.empty();
69 }
70
71 ACLData<char const *> *
72 ACLStringData::clone() const
73 {
74 /* Splay trees don't clone yet. */
75 return new ACLStringData(*this);
76 }
77