]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/NoteData.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / NoteData.cc
1 /*
2 * Copyright (C) 1996-2016 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 "wordlist.h"
17
18 ACLNoteData::ACLNoteData() : values(new ACLStringData)
19 {}
20
21 ACLNoteData::~ACLNoteData()
22 {
23 delete values;
24 }
25
26 bool
27 ACLNoteData::match(NotePairs::Entry *entry)
28 {
29 return !entry->name.cmp(name.termedBuf()) && values->match(entry->value.termedBuf());
30 }
31
32 SBufList
33 ACLNoteData::dump() const
34 {
35 SBufList sl;
36 sl.push_back(SBuf(name));
37 #if __cplusplus >= 201103L
38 sl.splice(sl.end(), values->dump());
39 #else
40 // temp is needed until c++11 move constructor
41 SBufList temp = values->dump();
42 sl.splice(sl.end(), temp);
43 #endif
44 return sl;
45 }
46
47 void
48 ACLNoteData::parse()
49 {
50 char* t = ConfigParser::strtokFile();
51 assert (t != NULL);
52 name = t;
53 values->parse();
54 }
55
56 bool
57 ACLNoteData::empty() const
58 {
59 return name.size() == 0;
60 }
61
62 ACLData<NotePairs::Entry *> *
63 ACLNoteData::clone() const
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