FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
scanners.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015, Siemens AG
3  * Author: Florian Krügel
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
22 #ifndef SCANNERS_HPP_
23 #define SCANNERS_HPP_
24 
25 #include <fstream>
26 using std::ifstream;
27 using std::istream;
28 #include <string>
29 using std::string;
30 #include <list>
31 using std::list;
32 
33 bool ReadFileToString(const string& fileName, string& out);
34 
39 struct match {
46  const int start, end;
51  const string& type;
52  match(const int s, const int e, const string& t) : start(s), end(e), type(t) { }
53 } ;
54 
55 bool operator==(const match& m1, const match& m2);
56 bool operator!=(const match& m1, const match& m2);
57 
62 class scanner
63 {
64 public:
65  virtual ~scanner() {};
66 
72  virtual void ScanString(const string& s, list<match>& results) const = 0;
73 
81  virtual void ScanFile(const string& fileName, list<match>& results) const
82  {
83  string s;
84  ReadFileToString(fileName, s);
85  ScanString(s, results);
86  }
87 } ;
88 
89 #endif
90 
const int start
Definition: scanners.hpp:46
bool ReadFileToString(const string &fileName, string &out)
Utility: read file to string from scanners.h.
Definition: scanners.cc:32
Store the results of a regex match.
Definition: scanners.hpp:39
bool operator==(const match &m1, const match &m2)
Compare two regex match.
Definition: scanners.cc:45
int s
The socket that the CLI will use to communicate.
Definition: fo_cli.c:48
bool operator!=(const match &m1, const match &m2)
Compare two regex match.
Definition: scanners.cc:55
virtual void ScanFile(const string &fileName, list< match > &results) const
Helper function to scan file.
Definition: scanners.hpp:81
Abstract class to provide interface to scanners.
Definition: scanners.hpp:62
const int end
Definition: scanners.hpp:46
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:321