39 vector<ojomatch> OjoAgent::processFile(
const string &filePath,
42 ifstream stream(filePath);
43 std::stringstream sstr;
44 sstr << stream.rdbuf();
47 throw std::runtime_error(filePath);
50 const string fileContent = sstr.str();
51 vector<ojomatch> licenseList;
52 vector<ojomatch> licenseNames;
55 for (
auto m : licenseList)
61 findLicenseId(licenseNames, databaseHandler, groupId, userId);
74 vector<ojomatch> OjoAgent::processFile(
const string &filePath)
76 ifstream stream(filePath);
77 std::stringstream sstr;
78 sstr << stream.rdbuf();
81 throw std::runtime_error(filePath);
84 const string fileContent = sstr.str();
85 vector<ojomatch> licenseList;
86 vector<ojomatch> licenseNames;
89 for (
auto m : licenseList)
96 vector<ojomatch>::iterator uniqueListIt = std::unique(licenseNames.begin(),
98 licenseNames.resize(std::distance(licenseNames.begin(), uniqueListIt));
112 vector<ojomatch> &result,
unsigned int offset,
bool isDualTest)
114 string::const_iterator end = text.end();
115 string::const_iterator pos = text.begin();
121 if (boost::regex_search(pos, end, res, reg))
123 string content =
"Dual-license";
126 content = res[1].str();
131 offset + res.position(1) + res.length(1),
135 offset += res.position() + res.length();
153 std::remove_if(matches.begin(), matches.end(), [](
ojomatch match)
154 { return match.license_fk <= 0;}), matches.end());
168 for (
size_t i = 0; i < matches.size(); ++i)
171 matches[i].content, groupId, userId);
const boost::regex regLicenseList
void scanString(const std::string &text, boost::regex reg, std::vector< ojomatch > &result, unsigned int offset, bool isDualTest)
const boost::regex regDualLicense
void findLicenseId(std::vector< ojomatch > &matches, OjosDatabaseHandler &databaseHandler, const int groupId, const int userId)
void filterMatches(std::vector< ojomatch > &matches)
const boost::regex regLicenseName
unsigned long getLicenseIdForName(std::string const &rfShortName, const int groupId, const int userId)
Get the license id for a given short name.
#define SPDX_DUAL_LICENSE
Regex to check if Dual-license.
#define SPDX_LICENSE_NAMES
Regex to filter license names from list of license list.
#define SPDX_LICENSE_LIST
Regex to filter the list of licenses.
Store the results of a regex match.
Store the results of a regex match.