NoteData.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 #include "squid.h"
10 #include "acl/Acl.h"
11 #include "acl/Checklist.h"
12 #include "acl/NoteData.h"
13 #include "acl/StringData.h"
14 #include "ConfigParser.h"
15 #include "Debug.h"
16 #include "sbuf/StringConvert.h"
17 #include "wordlist.h"
18 
20 {}
21 
23 {
24  delete values;
25 }
26 
27 bool
29 {
30  if (entry->name().cmp(name) != 0)
31  return false; // name mismatch
32 
33  // a name-only note ACL matches any value; others require a values match
34  return values->empty() ||
35  values->match(entry->value());
36 }
37 
40 {
41  SBufList sl;
42  sl.push_back(name);
43  sl.splice(sl.end(), values->dump());
44  return sl;
45 }
46 
47 void
49 {
50  char* t = ConfigParser::strtokFile();
51  assert (t != NULL);
52  name = t;
53  values->parse();
54 }
55 
56 bool
58 {
59  return name.isEmpty();
60 }
61 
64 {
65  ACLNoteData * result = new ACLNoteData;
66  result->values = dynamic_cast<ACLStringData*>(values->clone());
67  assert(result->values);
68  result->name = name;
69  return result;
70 }
71 
virtual ACLData< NotePairs::Entry * > * clone() const
Definition: NoteData.cc:63
#define assert(EX)
Definition: assert.h:17
virtual ~ACLNoteData()
Definition: NoteData.cc:22
const SBuf & name() const
Definition: Notes.h:186
bool isEmpty() const
Definition: SBuf.h:422
SBuf name
Note name to check. It is always set.
Definition: NoteData.h:33
virtual SBufList dump() const
Definition: StringData.cc:49
virtual SBufList dump() const
Definition: NoteData.cc:39
ACLStringData * values
if set, at least one value must match
Definition: NoteData.h:34
Used to store a note key/value pair.
Definition: Notes.h:173
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
virtual bool empty() const
Definition: NoteData.cc:57
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:265
virtual bool match(NotePairs::Entry *)
Definition: NoteData.cc:28
const SBuf & value() const
Definition: Notes.h:187
bool empty() const
Definition: StringData.cc:64
virtual void parse()
Definition: NoteData.cc:48
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors