FOSSology  4.7.0-rc1
Open Source License Compliance by Open Source Software
copyscan.hpp
1 /*
2  SPDX-FileCopyrightText: © 2015 Siemens AG
3  Author: Florian Krügel
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 #ifndef COPYSCAN_HPP_
8 #define COPYSCAN_HPP_
9 
10 #include "scanners.hpp"
11 #include "regex.hpp"
12 
13 using std::vector;
14 using std::pair;
15 
20 struct CleanupResult {
21  std::string content;
31  enum class Disposition { KEEP, DEACTIVATE, DISCARD } disposition;
32 };
33 
38 class hCopyrightScanner : public scanner
39 {
40 public:
41  void ScanString(const string& s, list<match>& results) const;
43  CleanupResult Cleanup(const string &raw) const;
44  void TrimPunctuation(string &text) const;
45  void RemoveNoisePatterns(string& text) const;
46  void NormalizeCopyright(string& text) const;
47  void StripSuffixes(string& text) const;
48 private:
61  rx::regex regCopyright, regException, regExceptionCopy, regNonBlank, regSimpleCopyright,
62  regSpdxCopyright, regRemoveFileStmt, regStripLicenseTrail, regStripTrademarkTrail, regStripAllRightReserveTrail, regExceptionVerbFollow, regExceptionAdjectivePrefix, regExceptionTemplate, regExceptionPassive, regStripCopySymNonYear, regExceptionBinaryNoise, regExceptionMeta, regExceptionCharNameRun;
63 } ;
64 
65 #endif
66 
Implementation of scanner class for copyright.
Definition: copyscan.hpp:39
rx::regex regNonBlank
Definition: copyscan.hpp:61
void ScanString(const string &s, list< match > &results) const
Scan a given string for copyright statements.
Definition: copyscan.cc:78
rx::regex regSpdxCopyright
Definition: copyscan.hpp:62
hCopyrightScanner()
Constructor for default hCopyrightScanner.
Definition: copyscan.cc:24
rx::regex regCopyright
Definition: copyscan.hpp:61
rx::regex regSimpleCopyright
Definition: copyscan.hpp:61
rx::regex regException
Definition: copyscan.hpp:61
Abstract class to provide interface to scanners.
Definition: scanners.hpp:59
int s
The socket that the CLI will use to communicate.
Definition: fo_cli.c:37
Utilities to help scanners.
Outcome of the Cleanup() function.
Definition: copyscan.hpp:20
std::string content
Cleaned text; empty when the copyright was removed.
Definition: copyscan.hpp:21
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:308