#include <stdio.h>
#include "utils.h"
#include "licenceGenerator.h"
#include "licenceCommon.h"

/// @brief hlavní funkce
/// @param argc
/// @param argv parametry pro generování licence
/// @return
int main(int argc, char *argv[])
{
  // cout << "test" << endl;
  // unordered_map<string, string> arguments = getArguments(argc, argv);
  // LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
  // generatorOld.createLicenceFile();
  // return 0;
  //cout << "Reading Test" << endl;
  LicenceGenerator licenceGenerator = LicenceGenerator();

  InitStructure initStructure;
  initStructure.elcType = 2;
  initStructure.licenceType = (int)LicenceType::EOS_EOV;
  initStructure.licenceVersion = 1;
  initStructure.licenceIndex = 0;
  initStructure.compatibility = 1;
  initStructure.licenceFilePath = "";

  // if (licenceGenerator.init(initStructure))
  // {
  //   LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
    
  //   if (licenceGenerator.getLicenceInfo(888, &info))
  //   {
  //     std::cout << "Počet licenčních bodů pro 888: " << info.reqDataPointsCount << std::endl;
  //     if (info.licences.count(888) > 0) cout << "počet z vectoru pro 888: " << info.licences.at(888) << 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ě: " << licenceGenerator.error.message;
  // }
  // else
  // {
  //   cerr << "Došlo k chybě: " << licenceGenerator.error.message;
  // }
  
  if (licenceGenerator.initread(initStructure))
  {
    LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
    if (licenceGenerator.getLicenceItemInfo(777, &info))
    {
      std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
      //for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl;
    }
    else cerr << "Došlo k chybě: " << licenceGenerator.error.message;
  }
  else
  {
    cerr << "Došlo k chybě: " << licenceGenerator.error.message;
  }


  system("pause");

  return EXIT_SUCCESS;
}
