48 vector<ojomatch> OjoAgent::processFile(
const string &filePath,
51 ifstream stream(filePath);
52 std::stringstream sstr;
53 sstr << stream.rdbuf();
56 throw std::runtime_error(filePath);
59 const string fileContent = sstr.str();
60 vector<ojomatch> licenseList;
61 vector<ojomatch> licenseNames;
64 for (
auto m : licenseList)
83 vector<ojomatch> OjoAgent::processFile(
const string &filePath)
85 ifstream stream(filePath);
86 std::stringstream sstr;
87 sstr << stream.rdbuf();
90 throw std::runtime_error(filePath);
93 const string fileContent = sstr.str();
94 vector<ojomatch> licenseList;
95 vector<ojomatch> licenseNames;
98 for (
auto m : licenseList)
105 vector<ojomatch>::iterator uniqueListIt = std::unique(licenseNames.begin(),
107 licenseNames.resize(std::distance(licenseNames.begin(), uniqueListIt));
121 vector<ojomatch> &result,
unsigned int offset,
bool isDualTest)
123 string::const_iterator end = text.end();
124 string::const_iterator pos = text.begin();
130 if (boost::regex_search(pos, end, res, reg))
132 string content =
"Dual-license";
135 content = res[1].str();
140 offset + res.position(1) + res.length(1),
144 offset += res.position() + res.length();
162 std::remove_if(matches.begin(), matches.end(), [](
ojomatch match)
163 {
return match.license_fk <= 0;}), matches.end());
175 for (
size_t i = 0; i < matches.size(); ++i)
unsigned long getLicenseIdForName(std::string const &rfShortName)
Get the license id for a given short name.
const boost::regex regDualLicense
const boost::regex regLicenseName
Store the results of a regex match.
#define SPDX_LICENSE_NAMES
Regex to filter license names from list of license list.
#define SPDX_DUAL_LICENSE
Regex to check if Dual-license.
#define SPDX_LICENSE_LIST
Regex to filter the list of licenses.
void findLicenseId(std::vector< ojomatch > &matches, OjosDatabaseHandler &databaseHandler)
const boost::regex regLicenseList
void scanString(const std::string &text, boost::regex reg, std::vector< ojomatch > &result, unsigned int offset, bool isDualTest)
void filterMatches(std::vector< ojomatch > &matches)
Store the results of a regex match.