36 lines
No EOL
1.3 KiB
C++
36 lines
No EOL
1.3 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cstring>
|
|
#include <unordered_set>
|
|
#include "log.hpp"
|
|
#include "util.hpp"
|
|
using std::string;
|
|
struct LicenseData {
|
|
string Project;
|
|
string Spdx;
|
|
string LicenseContents = "";
|
|
inline void load_contents(const unsigned int *license_data, const unsigned int license_size) {
|
|
std::vector<char> vec(license_size);
|
|
vec.resize(license_size);
|
|
memcpy(vec.data(), license_data, license_size);
|
|
vec.push_back('\0');
|
|
LicenseContents = string(vec.data());
|
|
DEBUG.writefln("Loading license for project '%s': %s...", Project.c_str(), Spdx.c_str());
|
|
}
|
|
inline LicenseData(string project, string spdx) {
|
|
this->Project = project;
|
|
this->Spdx = spdx;
|
|
}
|
|
inline bool operator==(const LicenseData &other) const {
|
|
return Project == other.Project && Spdx == other.Spdx;
|
|
}
|
|
};
|
|
template<>
|
|
struct std::hash<LicenseData> {
|
|
inline std::size_t operator()(const LicenseData d) const noexcept {
|
|
return combine_hashes({std::hash<string>()(d.Project), std::hash<string>()(d.Spdx)});
|
|
}
|
|
};
|
|
std::unordered_set<LicenseData> &get_license_data();
|
|
#define LOAD_LICENSE(data, prefix) if (data.LicenseContents == "") data.load_contents(prefix##_license_data, prefix##_license_size); |