Skyld AV  0.6
On access virus scanning for Linux
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
StringSet.cc
Go to the documentation of this file.
1 /*
2  * File: StringSet.c
3  *
4  * Copyright 2013 Heinrich Schuchardt <xypron.glpk@gmx.de>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 
25 #include <iostream>
26 #include "StringSet.h"
27 
32 }
33 
38 void StringSet::add(const char *value) {
39  std::string *str = new std::string(value);
40  if (!this->insert(str).second) {
41  delete str;
42  }
43 }
44 
50 int StringSet::find(const char *value) {
51  int ret = 0;
52  std::string *str = new std::string(value);
53  if (this->end() != this->find(str)) {
54  ret = 1;
55  }
56  delete str;
57  return ret;
58 }
59 
64  StringSet::iterator pos;
65  for (pos = this->begin(); pos != this->end(); ++pos) {
66  std::cout << "'" <<**pos << "'" << std::endl;
67  }
68 }
69 
74  StringSet::iterator pos;
75  for (pos = this->begin(); pos != this->end(); ++pos) {
76  delete *pos;
77  }
78  this->clear();
79 }
80 
StringSet()
Creates string set.
Definition: StringSet.cc:31
void add(const char *value)
Adds entry to string set.
Definition: StringSet.cc:38
int find(const char *value)
Finds entry in string set.
Definition: StringSet.cc:50
Set of strings.
virtual ~StringSet()
Destroys stringset.
Definition: StringSet.cc:73
void print()
Prints content of string set to console.
Definition: StringSet.cc:63