#pragma once #include #include #include #include #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 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 { inline std::size_t operator()(const LicenseData d) const noexcept { return combine_hashes({std::hash()(d.Project), std::hash()(d.Spdx)}); } }; std::unordered_set &get_license_data(); #define LOAD_LICENSE(data, prefix) if (data.LicenseContents == "") data.load_contents(prefix##_license_data, prefix##_license_size);