StringData.cc
Go to the documentation of this file.
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 /* DEBUG: section 28 Access Control */
10 
11 #include "squid.h"
12 #include "acl/Checklist.h"
13 #include "acl/StringData.h"
14 #include "ConfigParser.h"
15 #include "Debug.h"
16 
17 ACLStringData::ACLStringData(ACLStringData const &old) : stringValues(old.stringValues)
18 {
19 }
20 
21 void
22 ACLStringData::insert(const char *value)
23 {
24  stringValues.insert(SBuf(value));
25 }
26 
27 bool
29 {
30  if (stringValues.empty() || tf.isEmpty())
31  return 0;
32 
33  debugs(28, 3, "aclMatchStringList: checking '" << tf << "'");
34 
35  bool found = (stringValues.find(tf) != stringValues.end());
36  debugs(28, 3, "aclMatchStringList: '" << tf << "' " << (found ? "found" : "NOT found"));
37 
38  return found;
39 }
40 
41 // XXX: performance regression due to SBuf(char*) data-copies.
42 bool
43 ACLStringData::match(char const *toFind)
44 {
45  return match(SBuf(toFind));
46 }
47 
50 {
51  SBufList sl;
52  sl.insert(sl.end(), stringValues.begin(), stringValues.end());
53  return sl;
54 }
55 
56 void
58 {
59  while (const char *t = ConfigParser::strtokFile())
60  stringValues.insert(SBuf(t));
61 }
62 
63 bool
65 {
66  return stringValues.empty();
67 }
68 
71 {
72  /* Splay trees don't clone yet. */
73  return new ACLStringData(*this);
74 }
75 
Definition: SBuf.h:87
bool isEmpty() const
Definition: SBuf.h:422
virtual SBufList dump() const
Definition: StringData.cc:49
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
StringValues_t stringValues
Definition: StringData.h:39
virtual ACLData< char const * > * clone() const
Definition: StringData.cc:70
std::list< SBuf > SBufList
Definition: forward.h:26
bool match(char const *)
Definition: StringData.cc:43
virtual void parse()
Definition: StringData.cc:57
static char * strtokFile()
Definition: ConfigParser.cc:82
bool empty() const
Definition: StringData.cc:64
void insert(const char *)
Insert a string data value.
Definition: StringData.cc:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors