#pragma once
#include "Barcode.h"
#include "BarcodeFormat.h"
#ifdef ZXING_INTERNAL
#include "ZXAlgorithms.h"
#endif
#include <string>
#include <string_view>
namespace ZXing::GTIN {
#ifdef ZXING_INTERNAL
template <typename T>
T ComputeCheckDigit(const std::basic_string<T>& digits, bool skipTail = false)
{
int sum = 0, N = Size(digits) - skipTail;
for (int i = N - 1; i >= 0; i -= 2)
sum += digits[i] - '0';
sum *= 3;
for (int i = N - 2; i >= 0; i -= 2)
sum += digits[i] - '0';
return ToDigit<T>((10 - (sum % 10)) % 10);
}
template <typename T>
bool IsCheckDigitValid(const std::basic_string<T>& s)
{
return ComputeCheckDigit(s, true) == s.back();
}
#endif
std::string LookupCountryIdentifier(std::string_view GTIN, BarcodeFormat format = BarcodeFormat::None);
std::string EanAddOn(const Barcode& barcode);
std::string IssueNr(const std::string& ean2AddOn);
std::string Price(const std::string& ean5AddOn);
}