FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
scanners.cc
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  */
18 
19 #include "scanners.hpp"
20 
21 #include <sstream>
22 #include <cstring>
23 
32 bool ReadFileToString(const string& fileName, string& out)
33 {
34  ifstream stream(fileName);
35  std::stringstream sstr;
36  sstr << stream.rdbuf();
37  out = sstr.str();
38  return !stream.fail();
39 }
40 
45 bool operator==(const match& m1, const match& m2)
46 {
47  return m1.start == m2.start && m1.end == m2.end && m1.type == m2.type;
48 }
49 
55 bool operator!=(const match& m1, const match& m2)
56 {
57  return !(m1 == m2);
58 }
59 
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
Utilities to help scanners.
bool operator!=(const match &m1, const match &m2)
Compare two regex match.
Definition: scanners.cc:55
const int end
Definition: scanners.hpp:46