This commit is contained in:
2024-01-24 08:25:44 +01:00
parent f260e92596
commit 36a799057c
42 changed files with 926 additions and 2313 deletions

94
src/ReadLicence.cpp Normal file
View File

@@ -0,0 +1,94 @@
#include <stdio.h>
#include "utils.h"
#include "licenceGenerator.h"
#include "licenceReader.h"
#include "licenceCommon.h"
/// @brief hlavní funkce
/// @param argc
/// @param argv parametry pro generování licence
/// @return
int main()
{
// unordered_map<string, string> arguments = getArguments(argc, argv);
// try
// {
// unordered_map<string, string> arguments = getArguments(argc, argv);
// LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
// generatorOld.createLicenceFile();
// system("pause");
// return SUCCES;
// }
// catch (...)
// {
// cerr << "Obecná chyba\n";
// }
// system("pause");
// return SUCCES;
try
{
int protocolId = 222;
LicenceReader licenceReader1 {};
InitStructure initStructure;
initStructure.licenceType = (int)LicenceType::EOS_EOV;
initStructure.licenceVersion = 1;
initStructure.licenceIndex = 0;
initStructure.compatibility = 1;
initStructure.licenceFilePath = "";
initStructure.cid_csd_filePath = "";
cout << "-- verze #1: init a iterace" << "\n";
//verze #1: načtení kompletní licence a zobrazení
if (licenceReader1.init(2, initStructure))
{
LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
if (licenceReader1.getLicenceInfo(&info))
{
std::cout << "Počet licenčních bodů pro : " << protocolId << ": " << info.reqDataPointsCount << std::endl;
if (info.licences.count(protocolId) > 0) cout << "Počet z vectoru pro : " << protocolId << ": " << info.licences.at(protocolId) << endl;
cout << "Všechny licenční body: " << endl;
for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; }
}
else
cerr << "Došlo k chybě: " << licenceReader1.error.message;
}
else
{
cerr << "Došlo k chybě: " << licenceReader1.error.message;
}
cout << "\n" << "-- verze #2: init a iterace" << "\n";
//verze #2 : iterace pro kazdý bod zvlášť
LicenceReader licenceReader2 {};
if (licenceReader2.initread(2, initStructure))
{
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
if (licenceReader2.getLicenceItemInfo(protocolId, &info))
{
std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
}
else
cerr << "Došlo k chybě: " << licenceReader2.error.message;
}
else
{
cerr << "Došlo k chybě: " << licenceReader2.error.message;
}
}
catch (...)
{
cerr << "Obecná chyba\n";
}
system("pause");
return SUCCES;
}