FOSSology  4.4.0
Open Source License Compliance by Open Source Software
scanners.cc
1 /*
2  SPDX-FileCopyrightText: © 2015 Siemens AG
3  Author: Florian Krügel
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 #include "scanners.hpp"
9 
10 #include <sstream>
11 #include <cstring>
12 
21 bool ReadFileToString(const string& fileName, string& out)
22 {
23  ifstream stream(fileName);
24  std::stringstream sstr;
25  sstr << stream.rdbuf();
26  out = sstr.str();
27  return !stream.fail();
28 }
29 
34 bool operator==(const match& m1, const match& m2)
35 {
36  return m1.start == m2.start && m1.end == m2.end && m1.type == m2.type;
37 }
38 
44 bool operator!=(const match& m1, const match& m2)
45 {
46  return !(m1 == m2);
47 }
48 
Utilities to help scanners.
bool operator==(const match &m1, const match &m2)
Compare two regex match.
Definition: scanners.cc:34
bool operator!=(const match &m1, const match &m2)
Compare two regex match.
Definition: scanners.cc:44
bool ReadFileToString(const string &fileName, string &out)
Utility: read file to string from scanners.h.
Definition: scanners.cc:21
Store the results of a regex match.
Definition: scanners.hpp:28
const int start
Definition: scanners.hpp:35
const int end
Definition: scanners.hpp:35