diff --git a/Example.txt b/Example.txt new file mode 100644 index 0000000..90ca0f2 --- /dev/null +++ b/Example.txt @@ -0,0 +1,163 @@ +Привет, меня зовут QR-код +Меня придумали для разных вещей, вроде порабощения человечества, или чего похуже. +Но на самом деле я хороший - во мне можно хранить разный текст и даже файлы. +Однако, для последних потребуется специальный декодер, так как не каждая программа для чтения QR-кодов с этим справится. +Чего нельзя сказать про библиотеку, с помощью которой меня создали. +Она позволяет создавать QR-коды размером до 40-й версии (максимальная, дозволенная стандартом) в цифровом, символьном и байтовом режимах кодировки. +Она так же позволяет устанавливать предыдущие параметры вручную. +Так же как с уровнем коррекции (меня можно чутка повредить, но сканер всё равно сможет меня считать) и маской. +Последняя пока не выбирается динамически, но ждите версию v0.2.0, где эта возможность обязательно появится. +На этом, раскланяюсь. Навеки ваш QR-код :) +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +████████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████████ ██████████████ ██ ████████████████ ██ ██████████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██████ ██ ██ ██████ ██████ ████ ██ ██ ████████ +████████ ██████████ ██ ██████ ██ ████ ██████████████ ██ ██████ ████████ ██████ ██ ██ ████ ██ ██ ████ ████ ████ ██████ ██████ ██ ████████ ████ ████ ██ ██ ████ ██ ████████████ ████████████████████ ████ ██ ████ ██████████ ████████ +████████ ██ ██ ████ ██████ ██ ██ ██ ██ ██████ ██ ██ ████ ██ ████ ██████████ ██ ██ ████ ██ ██ ██ ██ ████ ██ ██ ████ ████ ██████ ████ ██ ████ ████ ██ ██ ██ ██ ██ ████████ +████████ ██ ██ ████████ ████ ████ ████ ████ ████ ████████ ██ ████ ██ ██ ██ ████ ██████████ ██████ ██ ██████ ██ ████████ ██████ ██ ██████ ██████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ████████ +████████ ██ ██ ██ ████ ██ ██████ ████████████ ██████ ██ ██ ██████ ████████ ████ ██████ ████████ ██ ████ ████ ██ ██████ ██████ ████ ██████ ██ ██ ██████ ██████ ██ ██████████ ██ ██ ████████ +████████ ██████████ ████ ████ ████████████ ████████ ██ ██ ██ ██████ ██████ ██ ████████ ██████ ████ ██████ ██ ██████████████ ████████ ██████████ ██████ ██ ██ ██ ████ ██████ ██ ████ ████ ████ ████████ ██ ██████████ ████████ +████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████████ +████████████████████████████ ██████ ██ ████ ██████ ████ ██ ██████ ██ ██ ████ ██ ██ ██ ██████ ██ ██████ ██████ ████████ ████ ██████ ██ ████ ██████ ██ ████ ████ ████ ██ ██ ██████ ████ ██ ████████████ ██████ ████████████████████████ +████████ ██ ██ ██ ████ ██ ██████ ██████████████ ██ ██ ██ ██ ██████ ██ ██ ████ ████████ ████████ ██████ ██ ██ ██ ██ ██ ██ ██ ████████ ██ ██ ██████████████ ██ ██████ ████ ██████████ +██████████ ██ ██████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██████ ██ ██ ████ ██ ████ ████ ██ ████████ ██████ ████ ██████ ██ ████ ████ ████ ██ ██████ ██ ██ ██ ██ ████ ████████ +████████ ██ ██ ██ ████████ ████████ ████████ ██████ ██ ██ ██ ██ ████ ████████ ██ ██ ██ ██ ██ ████ ██████ ████ ████ ████ ██████ ████ ██████ ████ ████ ████ ██ ████ ████ ██ ██ ██ ██████████ +████████████████ ████ ██ ██ ██ ██████ ████ ██ ██ ██ ██ ██ ██████ ██ ████ ████ ████████ ██ ██ ████ ██ ████ ████ ██ ██ ████ ██ ██ ██ ████████ ████████████ ██████████████████ ██ ██████ ████████████ +████████ ██████ ██ ██ ██ ████████ ██ ██ ████ ████████ ██ ████████████████ ██ ██████ ████ ██████████ ████████ ██████████ ██ ██ ████ ██ ████ ████ ██ ████ ██ ██ ██████████████ ████ ██████ ████ ██ ██████ ██ ████████ +████████████ ████ ██ ██████████ ████ ████ ████ ██ ████████ ██ ██ ██ ████████ ██████████████ ████ ██ ██ ████ ██ ██████ ██████ ██ ████ ██████ ██ ██ ██ ████ ████ ████ ████████ ████ ████████████████ +████████ ██████████ ██ ██ ██ ████ ████████ ████ ██ ██ ████ ████ ██████████████ ██ ██ ██ ██ ██████ ██ ████ ██ ██ ████ ████ ████████ ████ ██ ██████ ██ ████ ██ ██ ██████████ ██████ ██ ██████████ +████████ ██ ██████████ ██████████ ██ ██ ██ ██ ██████ ████ ██ ████ ██ ██████ ██ ████████ ██████ ██████ ████ ██ ████ ██ ██ ████ ██ ██ ██████████████████████████ ██████ ████ ██ ██ ██████████ +████████ ████ ██ ██ ██ ██ ████ ████ ██ ██████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ████████████ ██ ████ ██████ ██ ████ ██ ██ ██ ██ ██ ████ ██████ ██████ ██████ ████ ██ ██████ ████ ██████ ████████ +████████ ████ ██ ████ ████████ ████████ ██████ ████ ████████ ██ ██████ ██████ ██ ██████ ██ ██ ██ ██ ██████ ██ ██████ ████████ ████ ██████ ████ ██ ████ ██ ████ ██ ██████ ████ ████ ████ ████████████ +████████ ██████ ██ ██ ██ ██ ██████████ ████████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ████ ██ ██ ████ ██ ██ ██ ██ ████ ████ ████ ██████████ ████ ████ ██ ██ ████ ██ ██████ ██ ██████████ +████████ ██ ████ ████████ ████████ ██ ██ ██ ██ ████ ██ ██ ██ ██████████ ██ ██ ██ ██████████ ████████████ ██████ ████████████ ██ ██ ████████████████ ██ ██ ████ ██ ██████████ ████████████ ██ ████████ ██████ ██ ██████████ +██████████ ████ ██ ██████ ████ ████ ██ ██████ ██████ ██ ████ ██████ ██ ██ ████████████ ████████ ████ ██ ██ ████ ██ ██ ████ ██████ ████ ██ ██████ ████ ████████ ██ ██ ██████ ████ ████ ██ ██████████████████ +████████ ██ ██ ████ ██ ████ ██ ██ ████ ████████ ████████ ████ ████ ██████ ████ ██ ██ ██ ████████ ██ ████ ██ ██ ████ ██████ ████ ██ ██ ████ ████ ████ ██████ ██ ██ ██ ██ ████ ██ ██████ ████ ████████ +████████ ██ ██ ██ ████ ██ ████ ██████ ████ ██ ██ ██ ██ ████████ ██████ ██████ ██ ██ ██ ██ ██ ██ ████ ██████ ██ ████ ██ ████ ██ ██ ██ ████ ████ ████ ██████ ██ ██ ████████████ +████████ ████████ ██ ██ ██ ██ ████ ██ ██ ██ ██████ ██ ████ ████████ ██ ████ ██████ ████ ████ ██████ ████████████ ██ ██ ██ ██ ██ ██ ████ ██████ ██ ██ ████████████ ████ ██████ ██████ ██ ██ ██████████ +████████ ██ ██ ██ ██ ██ ████ ██ ██ ████████ ████ ████ ██ ████ ████████ ████ ████ ██ ██████████████████ ██ ████ ██████ ██ ██ ████ ██████ ██ ██████ ████ ██ ██ ████ ██ ████ ██ ██ ████ ██████ ████ ████ ████████ +██████████ ██████████ ██████ ██ ██████ ████ ████████ ██████ ██ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ██ ██████ ██ ████ ██ ██ ████ ████████ ████ ████████ ██ ██ ████ ██ ██ ██████ ██ ████████ ████████████████ +████████ ██ ████ ██████ ██████ ████ ██ ████ ██ ████ ██ ██ ██ ██ ██ ████████ ██ ██ ██ ██ ████████ ██ ██ ██████████ ██ ██ ██████ ██████ ████ ████████████████ ██ ██ ██ ████ ████████ ████ ██████████ +██████████████ ██ ████ ████ ██ ██ ██ ██ ██ ████████ ██ ██████ ██ ██ ██ ██ ██ ████ ████ ██ ██ ████ ████ ██ ██████ ██ ██ ████ ██████ ████ ██████ ██████ ████ ████████████ ████ ████ ██████ ██ ████ ████████ +██████████ ████ ████████████████████ ██ ██ ████ ██ ██ ██████████ ██ ██ ██████ ████████ ██████ ████████████████████ ████ ██ ████ ██ ██ ██ ██ ██ ████ ████ ██████ ██████ ██ ██ ██ ██ ██ ████ ██ ████████ +████████ ████ ██ ██ ██████ ██ ████ ██ ██████████ ██ ████ ██ ██████████ ██ ████ ████ ██████ ████ ████ ████ ██ ██ ████ ██ ████████████ ████ ██ ████████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ████████ +████████ ████ ██ ████ ██ ██████ ████████ ████ ████████ ████ ██ ████ ██ ██ ████████ ████ ██ ██ ████████ ██ ████████ ████ ██ ██ ████ ████ ████ ████ ████ ██████ ██████ ██████ ██ ████████████ +██████████████ ████████ ██████ ████ ██ ██████ ██ ████████ ██ ████ ██ ██ ████████ ████████████ ████████ ████ ████ ██████ ████ ██ ████ ██ ████ ██ ██ ████ ██ ████ ██ ████ ██████ ██████████ ██ ██ ██████████ +██████████████ ██ ██████ ██ ████ ██ ██ ██ ████████████ ██████ ██ ██ ██ ██ ████████████ ██████████ ████ ████ ██ ████ ████ ████ ██ ██ ████ ████ ██ ██ ██ ████ ██ ████████ +████████████ ██████ ████ ██ ████ ████████ ████████ ██████ ████ ██ ██ ██ ██ ████ ██████ ████ ██████ ██ ████ ██████ ██ ██ ████████ ████ ██ ████ ██████ ██ ██ ████ ██ ██ ██ ██ ██████ ████ ████████ +████████ ██ ██ ██ ██ ████ ██████ ████ ██████████████ ██ ██ ██ ██ ████ ████ ██████ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██████ ██ ██████ ██████ ██ ████ ██ ██ ██ ████ ████ ████ ██ ██ ██ ████████████ +████████ ██████ ██████ ██ ██████ ██ ████████████ ████ ██████ ██ ██ ████ ██ ██ ██████ ████ ██████ ██████████████ ██████ ██████ ████ ██████ ████ ██████ ██ ████ ████ ██████ ██ ██████████ ██████ ████ ████████ ██████ ██████████ +████████ ████ ████ ██ ██ ██ ██ ██ ██████ ██ ██████████ ██ ████ ██ ██ ████ ██ ████████████████ ██████ ████ ████ ██████ ██████ ██ ██ ██████ ████████████████████ ████ ████ ████████ +██████████ ████████ ██ ██ ██ ████████ ██████ ████ ██████ ██████████ ██ ██████ ██████ ██████ ████ ████ ████ ██ ████ ████████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ████ ████ ██ ██ ██ ██ ████████ +████████ ██ ██ ████ ██ ██ ██ ██████ ████ ██████ ████████ ████████ ████ ██ ████ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██████ ██████ ████ ██████ ████ ██████ ██ ██ ██ ██████ ██████ ████████ ████████████ +██████████ ██████ ██ ██ ██ ████████ ██ ████████████ ██ ████████ ██████████ ████████ ██████ ██████ ██ ████ ██████ ██████ ██████ ██ ██ ████ ██ ████ ████ ██████ ████ ██████████████████ ████ ████████ ████ ██ ████ ██████████ +██████████ ████ ██ ██ ████ ████ ██ ██ ██████████ ██ ██ ████ ██ ██ ██ ██████ ████ ██ ████ ██ ████ ██ ██ ██████ ████ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██████ ██ ██ ██████ ██ ██ ████ ████ ██████ ██ ██ ████████ +████████ ██ ████ ██ ████████ ██ ████ ██████ ██████████ ████████ ████ ████████ ████████ ██████ ██ ██ ████ ██ ██ ████████ ██████████ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██████ ██ ████████████ +████████████ ██ ██ ██ ██ ██ ██ ████ ████████ ████ ██ ██████████ ██ ██ ██ ████ ██ ████ ████████ ██ ██ ██ ██████ ██████ ██ ████ ████████████ ████ ██████ ████ ██ ████ ████ ████ ██ ██████████ +██████████████████████ ██████████ ██ ██ ██ ████ ██ ████████ ████ ██ ████ ████ ████████████ ██ ██ ██████ ████████ ██████ ████ ██████ ██ ██ ██ ██ ██ ████ ██████ ██ ██ ██████████████ ██ ██ ████ ████ ██ ██ ████ ██████████ +██████████ ████ ████████████ ██████ ████ ██ ██ ████ ██████ ██████ ████████ ██ ██ ██ ████ ████████ ██ ██████████ ██ ██ ██ ██ ████████████████ ████ ████ ██ ██████████ ██████████ ██████ ████ ████ ██ ██ ████████████ +████████ ████ ██████████ ██████ ██ ██ ████ ██████ ██ ██ ██████████ ██████████ ██ ██ ████ ██ ████ ██████ ██████ ██ ██ ██████ ████ ██ ████ ██ ████ ██ ██ ██████ ████ ████████ +████████ ████ ██ ██ ██████████ ████ ████ ████ ████ ██ ████ ████ ██████ ████████ ██████ ██ ████ ██ ████ ████ ██ ██ ██ ████████████████ ████ ████ ██ ██ ██ ██████ ████ ██████ ██ ████ ██ ██ ██ ████████ +████████ ████████ ██ ████ ██ ████ ██ ████ ████ ████ ██ ██████ ██ ████ ████████ ██ ██████ ████ ████ ██████ ██████ ██ ██ ██ ████ ████████ ████ ██ ██ ████████ ████████████████████████ ██ ██ ████ ██ ██████████ +████████████ ██ ████ ██ ██ ██ ████ ████████ ████ ████ ████ ████████ ████████ ██ ██ ████ ██ ██████ ██████████████████████████ ██ ██ ██ ██████ ██ ████ ██ ████████ ██ ██████ ██ ██ ██████ ██ ██████ ██████████ ████████████ +████████ ████ ██ ██ ████████ ████████ ████ ██ ████████ ██ ████████████ ██ ████ ██ ██ ████████ ██████ ██████ ██████ ████ ██████ ██ ████ ██ ████ ████████ ██████ ██ ██ ██████ ██ ██ ██ ██ ██ ████ ████ ██ ██████ ██ ████████ +██████████ ██ ██████ ██ ██ ██ ██ ██ ██ ██████████ ██████ ████████ ██ ████ ██ ██████ ██ ██ ██ ██ ████ ██ ██████ ██████ ██████ ████ ████ ██ ████ ██ ████ ██ ██████ ████ ██ ████████████ +████████████ ██ ████ ██ ██ ████ ██████ ████ ██ ██████ ██████████████ ██████ ██████ ████ ██ ████ ██ ██ ████ ██████ ██████ ██ ████████ ████ ████ ██ ████ ██ ██ ██ ██████ ██ ██████████ ██████████ ██ ████ ██████████ +██████████ ██ ████ ██ ██████ ██ ██ ██ ████ ██ ██ ████ ████ ██ ██ ████████████ ██ ██ ██████████████████ ██ ██ ████ ██████████ ██ ████ ██ ██████ ████ ██████ ██ ██ ██████ ██ ██ ██ ████████ +████████ ████ ██████ ████ ████ ██ ██ ██ ██ ██ ████ ██ ██████ ██████ ██ ████████ ██████ ██ ████████ ████ ██ ██ ██ ██ ██ ████ ██████ ██ ██████ ██ ██ ████ ██ ██ ██ ████ ██ ██ ████ ██ ██ ██████ ████████ +████████ ██ ██████ ██ ██████ ██ ██ ██ ████████ ██ ██ ████████ ██ ████████ ██ ████ ██████ ████ ████ ██ ████ ██ ██ ██████ ██████ ████ ████ ██ ██ ██████ ██ ██ ████ ██████ ████ ████ ████ ████████████ +████████ ████████████ ██ ██ ██ ██ ████ ████ ██████ ██ ██ ████ ████ ██████ ██ ██ ██ ██████ ██████ ████ ██████████ ████████ ██ ██ ████ ████ ██████ ████ ████ ██ ██████ ████ ██ ██████ ████████████ ████ ██ ██ ████ ██████████ +██████████████████ ██ ██████ ██ ████████████████ ██ ████ ████ ████████ ████ ████ ██ ██████████████████████████ ████████ ████████ ██ ██ ████ ██ ██ ██ ██ ██ ██████████ ██ ██████ ██████████████ ██ ██ ██ ████████ +██████████ ██ ██ ██ ████ ██ ██████ ████ ██ ████ ████████ ██████ ██ ████████████ ████ ████ ████████ ████ ██████ ████ ██ ██ ████ ██ ██ ██ ████ ██ ████ ██████ ████ ██ ██ ██ ██ ██████████████ +████████ ██ ████████ ██ ██ ████ ██ ██████ ██ ██████ ██████████████ ████ ██ ██ ██ ██ ██ ████ ██ ████ ██████ ████ ██ ████████ ██ ████ ██ ██ ██████████ +████████ ██ ██████ ██ ████████ ██ ██████ ████ ████████ ██████ ████ ████ ██ ██████ ████ ██ ██████ ██ ██ ██████ ██████ ██████ ██ ██ ██████ ██ ██ ████ ████ ████ ██ ██████ ████ ██ ████████████████████████ ██████ ████████████ +██████████ ██ ██ ████ ████████████████████ ██ ██ ██ ██████ ██ ████ ██ ████ ██ ██ ██ ██ ██████████ ██ ██ ████ ██ ██ ██ ██ ██████ ████ ████ ██ ██ ██ ██ ██ ██ ██████ ████ ████████ ████ ██████ ██ ██ ██ ████████ +████████████ ██████ ██ ██ ████ ██ ████ ██ ████ ██████ ████ ██ ██ ██ ████ ██ ██ ██ ██████ ████ ████ ████ ██████ ██ ██ ██████ ████████ ██████ ████ ██ ██ ████████ ██████ ██ ██ ██ ██████ ██ ████ ██ ██████ ████████████ +████████ ████ ██ ██ ████████ ██████ ████ ████████ ██ ████ ████ ██ ████ ██ ████ ██ ██ ██ ████████ ████ ██ ████ ██ ██████ ██████ ██ ██ ██ ████ ████ ██████████ +████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████████ ██ ████ ██ ██ ████ ████ ████ ██ ██ ██ ██ ████ ████████ ████ ████ ████ ██ ██ ████ ██ ████ ██████████ ██ ██████ ████ ████████ ██ ██ ██ ██████████ +████████████ ██ ████ ██ ██ ████ ██ ██ ████ ████ ██████ ██████ ██ ██ ████ ██████████ ██ ██ ██ ██ ██████████ ██████ ██ ████ ██ ████ ████ ██████ ████ ████ ████ ██ ████ ██████ ██ ████ ████████████████ +████████ ██ ████████████ ████ ████ ████████ ██ ██ ████ ████ ████████ ██ ██ ██████ ██ ████████ ██ ██ ██ ████ ██ ██ ████████ ██ ██ ████████ ██ ██ ████████ ████ ██████████ ████ ██ ████████ +████████████████████ ██ ██ ████ ██████ ██ ████ ████ ██ ████ ██ ██ ██ ████ ██ ██ ████████████ ████ ██ ██ ██ ████ ██ ██ ██████████████ ██████ ██████████ ██ ████████ ██████ ██ ██ ██ ██████████████ +████████ ████ ██ ██ ██ ████ ██ ████ ████ ██████ ████ ██████ ████ ██ ██ ██ ██ ████ ████████ ████ ██████ ██ ██ ██ ████ ██████ ██ ██ ██████████████████ ████ ████████ ████ ██ ██████████ +████████ ████ ████████ ██ ██ ██ ██ ████ ██ ██ ██████ ████ ██████ ██ ████ ██████████ ████████████ ██████ ██ ██ ████ ██ ██ ██ ████ ██ ██ ████ ████ ██ ██ ████ ████ ██ ██ ██████ ████████████ ██ ████████ +████████ ██ ████████ ██ ██ ████ ██ ██ ██ ██ ██████ ██████ ██ ████████ ██ ██ ██████ ████ ████████ ██████ ██████ ████ ██ ██ ████ ██████ ██ ██████ ██████ ██ ████ ██ ██ ████████████ ██ ██ ██████████ +████████ ██ ██ ██ ██████ ████ ██ ██████████████ ██ ██ ████ ██ ██ ██ ████████ ██ ██ ██ ██ ██ ████ ██ ████ ████ ██ ████ ██ ████ ████ ████ ██ ████ ██ ████ ████████████ ████ ████ ████ ██ ██ ████████████ +████████████ ██ ██ ████████████ ████ ██ ██ ██ ██ ████ ████ ██ ████ ██ ████ ██ ██ ██████ ████ ████ ██████ ██████ ██ ██████ ████ ████ ██ ██████ ██ ██████████████ ████ ████████████ ██ ████████████ +████████ ██ ██ ████ ██████ ██ ██ ██ ██ ████ ██████ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██████████████ ████████████████████████████ ██ ██ ██ ██ ██ ████ ██ ██████ ██ ██ ██████████ ██████ ██████ ██████████ ██ ██ ██ ████████ +████████ ██ ██████ ██ ██████ ██ ██████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ████████████ ████ ██ ██████ ██ ████ ████ ██████ ██████ ████ ██ ████ ████ ██ ██ ██ ██ ████ ██ ██ ██ ████████ +██████████ ████████ ██ ██ ████ ██████ ██ ██ ██ ████ ██ ██ ██ ██████████████████ ████ ██ ████ ████ ██ ████████ ██ ████ ████ ████ ████████████████████████ ██████ ██████ ██ ██ ██ ██████████████ +████████ ██ ██████████ ██ ██ ██ ████████ ██ ██ ██████████ ██ ████████ ████ ████ ██ ████ ████ ██████ ████ ██ ██ ████████ ██ ████ ██ ██ ██ ████ ██████ ██ ██ ██ ████ ████ ██ ██████████████████ ██ ██████████ +████████ ████ ██ ████████ ████████ ████████ ████████ ████ ██ ██████ ██ ██ ████ ██ ██ ████ ██ ██████████████ ████ ████ ██ ██████████ ██ ██ ██ ██ ██████ ██ ██ ████████ ██████████ ██████ ██████ ██ ██████████ ██████ ██ ████████ +██████████ ██ ████████ ██ ████ ██ ██ ██ ████ ██ ██ ██ ████ ██████████ ████ ██ ████ ██████ ████ ██████ ████ ██ ████ ████ ██ ██ ██████ ██████ ██ ██ ██████ ██ ██ ██ ██ ██ ████ ██ ██████████████ +████████ ██ ██ ██ ██████████ ██ ████ ██████ ████ ██ ████ ████████ ████ ██████████ ████ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ████ ████ ██████ ████ ██ ██████ ████ ████ ████ ████ ██ ██ ██ ██████████ +████████████ ██ ████ ██ ████ ██████████ ██████ ████████████ ████ ████████ ██ ████ ████ ██ ██ ██ ██████ ████ ████ ██████ ████ ██ ██ ██ ████ ██████ ██████ ██ ██ ██████████████████████ ██ ████ ████████ ██████ ████ ████████ ██ ████████████ +██████████ ██ ████████████ ██ ██████ ██ ██ ████████ ████ ██ ████ ██████ ██ ██████ ████ ██████████████████████ ██████ ████ ████ ██ ████ ██ ████ ██ ████ ██████ ██ ██ ████████ ████ ████████████ ████████ ██ ██ ████████ +████████ ████ ██████ ██ ████ ██ ██ ████ ████ ██████ ██ ██ ████ ████ ████████ ██████ ██ ████ ████████ ████ ██████ ██████ ██████ ██ ████ ██ ████ ██ ██ ████ ██████ ██ ██████ ████████ ██████ ████ ████ ██ ████ ██████████ +████████ ██ ██ ██████ ████ ██ ██████ ██ ██ ████ ████ ████████████ ██ ████ ██ ██ ██████ ██ ████ ██ ████ ██ ██████████████████ ████ ████ ████ ████ ██ ██████ ██ ██ ██ ████ ██████ ██ ██ ████████████████ +██████████ ████ ████ ████████ ██ ██ ██████ ████ ████████ ████ ████ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██ ██ ██████ ████ ██ ██████████ ████ ████ ████ ████ ██ ████ ████ ██ ██ ██ ██ ██████ ████ ████ ████ ████ ██████ ██ ████████████ +████████████████ ██ ██████ ██ ██ ██ ████ ██ ██████ ██████ ██ ██ ██ ██████ ██████ ██ ████████████████████ ████ ████████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ████ ██ ████████ +████████████████ ██████ ██ ██ ██ ██████ ██ ██ ████ ██████ ██████ ████ ██████ ████ ██████ ██████ ██████ ██ ████ ████ ██ ████ ████ ██ ██████ ██ ██ ██ ████████ ██ ██████ ████ ████████ +████████ ██ ██ ██ ██████ ████ ██ ██ ████████ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ████████ ████ ████ ██ ██ ████ ██████ ██ ████ ██ ██ ████████████ +████████ ██ ██████ ██████ ██ ██ ████████████████ ██ ██ ██████ ████ ████ ██ ████ ██ ██████ ██████ ████ ██████ ██████ ██████ ██████ ██ ██ ██ ██ ████ ██ ██████ ████████████████████ ████ ██ ██████ ██████ ██████████ +████████ ████████ ██ ████ ██ ████ ██ ██ ████ ██████████ ██ ██ ██ ██ ████████ ██ ██ ████████ ████ ██ ██████ ██ ██ ████ ████ ██ ████ ██ ██ ██████ ██████ ██ ██████████ ██ ██ ██ ████████ +████████████████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ████ ████ ██ ████ ██ ████ ██ ██ ██ ██ ████ ████ ██████ ██ ██████ ██ ██ ████ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ████ ██████████████ +██████████ ██████ ████ ██ ██ ██ ████ ██ ██ ████ ██████ ████ ██ ██ ██ ██████████ ████ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██ ████ ██████ ██████████ ████ ██████ ████████ ██ ██ ██ ████ ██████████ +████████ ██████ ██ ██ ████ ██ ████████ ██ ██ ████ ████ ██ ██████████ ██ ████ ████████████ ██ ████ ██ ████ ██ ██ ████ ██████ ██ ██████ ██ ████ ████ ██ ████ ██████ ██ ██ ██████████ ████ ██ ██ ████████████ +██████████████ ██ ██████ ██ ████ ██ ██████ ██ ██ ██████ ██ ██████ ██████████ ██ ██████████ ██ ██████████ ████████████ ██ ██ ██████ ████ ████ ██ ████ ██ ██ ██ ████ ██████ ██████████████ ████ ██ ██ ████████ ██ ████████ +████████ ████ ████████ ██ ██ ██ ██ ████ ████ ██ ██ ████████████ ██ ████ ████ ████ ████ ██ ██ ████ ██████ ██ ██████ ████ ████ ██ ████ ██████ ██████ ██ ██ ██████ ██ ██ ████ ██ ██ ██ ████████ +████████ ██ ██ ██████ ████ ████ ██████████ ████████████████ ████████ ██████████ ████ ██ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ██████ ██████ ██ ██ ██████ ████ ██████ ████████ ██████ ██ ██ ██ ████████████ +██████████████████ ██ ████ ██████ ██ ██ ██ ████ ██ ████ ████ ██ ████████████ ████████ ██ ████ ██ ████████ ████████ ████████ ██ ██ ██ ██ ██ ██ ██ ████ ████ ████████ ██████ ████ ████ ████ ██████ ██████ ██ ██ ██████████ +████████ ██ ██ ██████ ██ ████ ████████ ██ ████ ██ ██████ ██████ ████ ██ ██ ████████ ██████████████████ ██████ ████ ████ ██ ██████ ██ ██ ██ ██ ██ ████ ██████ ██ ████ ██ ████ ██████ ██ ████████ +██████████████ ████ ████ ██████ ██████ ██████ ██ ██ ██████ ██ ██ ██ ██████████ ██ ██ ██ ██████ ██ ████ ████ ██ ██ ██ ██████ ██████ ██ ████ ██ ████ ██ ████████ ██ ████ ██ ██ ██████ ██████ ████████ +████████████████ ██ ██ ██ ██ ██████ ████ ██ ████ ██ ████ ████ ██ ██ ██ ██ ██████████████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██████ ██████ ████ ██████████ ██ ████ ████ ████ ██ ██████ ████████ +██████████ ██ ████ ██ ██ ██████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████████ ████████ ██ ██ ████ ██████ ██████ ██ ██ ██ ██████ ██████ ████ ██████ ██ ████ ██████████████████ ██ ██████ ██ ██ ██ ████████ +████████ ██ ██ ██ ██ ████ ██ ████████████ ████ ████████████ ████ ██ ██ ██████████ ██████ ████████ ████ ██ ████ ████ ██ ██ ██ ████ ██ ████████ ██████ ████ ██████████████████████ ████ ██ ████████ +████████ ██ ████ ██████ ██ ████ ██ ██ ████ ██ ██ ██ ██ ████████ ██ ██████ ██████ ██ ████ ████ ██ ██ ████ ██ ██ ████████ ████████ ██ ██ ████ ████████ ██ ██████ ██ ██ ██████ ██ ██ ████ ████████ +████████ ██████ ██ ██ ██ ████████ ██ ██ ██ ██ ████ ████ ████ ████████████ ██ ████████ ██ ██ ██ ██ ████ ██ ██ ██ ██ ████ ████ ██ ██ ██████████ ████████████████ ████ ████ ████ ██ ██ ██ ████████████ +██████████████████ ██████ ████ ████ ████ ██████ ██ ████ ██ ██████ ████ ██ ██████████████ ██ ████ ██ ██████ ██████ ██████ ████ ████████ ██████ ████ ████ ████ ██ ██████ ██ ██ ████████████ ██████████████ ██████ ██ ██ ██████████ +████████ ████ ████ ██ ████ ████████ ██████ ██ ████ ██ ██ ██████ ██████ ████ ██ ████████ ██████████ ██████████ ██ ██ ██ ██ ██ ██ ████ ████ ██████ ██ ████████████ ████ ██████ ██████████████ ██ ████████████ ████████ +████████ ██ ██ ██ ████ ████ ██ ██ ████ ████████ ██████████ ████ ██████ ██ ██████ ████ ████████ ██ ██ ████████ ████ ██ ████ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ██████ ██ ██ ██ ██████████ +████████████ ██ ████ ████ ██ ██████ ██ ████ ██ ██ ██████ ████ ██████████ ██ ██ ████ ██ ██ ██ ██ ████ ████ ████████ ██ ██ ████████████ ██ ████ ████████████████ ██ ██████ ██ ████████ ████ ██ ████████████ +████████ ██ ██ ██████ ██████ ██████ ██ ████ ██ ██ ██ ██████ ████ ██ ██ ██ ██ ██████ ████ ██████ ████████ ██ ████ ██ ██ ████ ██████ ████ ████ ██ ██ ██ ██ ██████ ████ ████ ██ ██ ████ ██ ██ ████████████ +████████ ████ ██ ████ ████ ████████ ████ ████ ████ ██ ████ ██ ██ ████████ ██ ██████████ ██ ████████████████ ████ ████████ ██████ ████ ██ ██ ██ ████ ██████ ██ ██ ██ ██████ ████████ ██ ██████████ ██ ██████ ██ ████████ +████████ ██ ██████ ██ ██ ██████ ██ ████ ████ ████ ██ ████ ████ ██ ██████ ████ ████ ████ ██████ ██ ████ ██ ████ ██ ██ ██████ ██████ ████ ██████ ████ ████ ██ ████ ██ ██ ██ ████ ██ ██ ████████ ██ ████████ +████████ ██ ██ ████ ██████ ████ ██ ████ ████ ██ ████ ██ ██ ██ ██ ████ ████ ████ ██ ██ ████████████ ████ ████████ ██ ████ ██████████████ ████ ██ ████████████████ +████████████ ██ ██████ ██ ██████████ ██ ████████████████ ██ ██████ ████ ████ ██ ██████████████ ██ ██████ ██████ ██████ ████ ████████████ ██ ██████ ████ ████ ██ ████ ████ ██████ ████ ████ ████ ████████████████████ ██████ ██ ██████████ +██████████ ████ ██ ██ ██████ ████ ████ ████ ██ ██████ ██ ██ ██ ██ ██ ██ ██████████ ██ ██ ██ ██ ██ ████ ████████████ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██████ ██████ ██ ██████ ████ ██ ██ ██ ████████ +████████ ██ ██████ ████ ██████ ██████████ ██ ██ ██████ ████ ██████████ ██████ ██████ ████ ████ ██████ ██████ ██████ ██████ ██ ████████████ ██ ██████ ██ ██ ██ ██ ██ ██████ ████████████ +████████ ██ ██ ██ ██ ██████ ████ ██████ ██ ██ ██████ ████████████ ██ ██ ██ ████ ██ ████ ██ ██ ████ ████ ██ ██ ██ ██████ ████ ██ ████ ██ ██ ██████████ +██████████ ████ ██ ████ ████ ██████████ ██ ██ ██ ████████████ ██████ ████ ██████ ██ ████████████████ ████ ████ ██ ████ ██ ██████ ██ ██ ██ ██ ██ ████ ████████████ ██ ████████ ██ ██ ██ ██████████ +████████ ██ ████████ ██████████ ████ ██████ ████ ██ ████ ██ ██ ████ ████ ██ ████ ████ ██ ██████ ██ ██████ ████ ██████ ████ ████ ████ ██ ██ ██ ████████████ ██████ ██ ██ ██████ ██████ ██████ ██ ████ ████████ +██████████ ██ ████ ████████████ ██ ████ ████ ██ ██ ██ ████ ██ ████ ████ ████ ██ ██ ██ ████ ██████ ██ ██ ██ ██ ████ ██████ ██████ ██████ ██ ████ ██ ██ ████ ██████ ████ ████████ +████████ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ████ ██ ████ ██ ████████ ██ ██████████ ██ ████ ██████ ████ ██ ██ ████████████ ████ ██████ ████ ██████████ ██████ ████ ██████ ██ ████ ██ ████████████ +██████████████ ██ ████ ██ ████████████ ██████ ██████ ████ ████ ████ ████ ██ ████ ██ ██ ██ ██ ██ ████ ████ ██████ ██ ████ ████ ██████ ████ ████ ██ ████ ████ ██ ████ ████ ██ ████ ██████████ ██ ██ ████ ██████████ +████████ ██ ████████ ██ ████████████████ ██ ██ ████ ████ ██ ██ ████ ████ ██ ██ ██ ██ ████████████ ██ ██████████ ██ ████ ██████ ██ ██ ██████████████ ████ ████ ████████ ██████████ ██ ██ ████████ +██████████ ██ ██ ██ ██████████ ████ ██ ██ ████ ██ ████ ██ ██ ████████ ██ ████ ██████ ████ ████ ██ ████ ████ ████████ ████ ██ ██████████████ ████████████ ██ ████████████ ████ ████ ████ ██ ██ ██ ██ ██████████ +████████████ ████ ████ ██ ██ ██████ ██ ████████████ ██ ██ ██ ██ ██ ████ ██ ████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██████ ████████ ██████ ████ ████ ████ ██ ██ ██ ████████████ +██████████████ ██ ██ ██ ██ ██████ ██ ██ ██ ██ ████████ ██████ ████████ ██████████ ██████████ ████ ██████ ██ ██ ██ ██ ██ ██ ██ ████ ████ ████ ████ ██ ████ ████ ██████ ████ ██ ██ ██ ████████████ +████████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ████████ ██ ██ ████ ████████████ ██ ████████████████ ██████ ██████ ██ ████ ██ ██ ██████████ ████ ██████ ████ ████████████████████ ██ ████ ████████ +████████ ████ ████ ██████ ██████ ████ ██████ ████████████████████ ████ ██ ████ ████ ██ ██ ████ ████ ██████ ██ ████ ████ ████ ██ ██ ██ ████ ██ ██ ██ ██ ████ ████ ██ ██ ██ ████ ████ ██████ ██ ██ ██ ████████████ +██████████ ████ ████████ ████ ████ ██████████ ██████ ██████ ██ ██ ██ ██████ ████ ██ ████ ██ ████ ████ ██ ██ ████ ████████ ██████ ██████ ██████ ████ ████ ████████████ ████ ██████ ████ ████ ██ ████ ██████████ +██████████ ████ ████████ ████ ██████████████ ██████ ██ ██████ ██ ██████████ ██ ████████████ ████ ██ ██████ ██████ ████ ██████ ████ ████ ██ ██ ██████ ████ ██ ████ ████████ ████████████ ██████████████ ████████████ ██ ████ ██ ████████ +████████ ██ ██ ██████ ██ ██ ██ ████████████ ██ ██████ ████ ██████ ████ ██ ██ ██████████████ ████████████████ ██████████ ██████████ ████ ██ ██ ██ ████ ████ ██ ██ ██ ██ ████ ██████ ████████ ██ ██████████ +████████ ████████ ██ ██ ██ ██████ ██████ ██ ██ ██ ████ ██ ██ ██ ██ ██████ ██ ████ ██ ██████████████ ████ ██ ██████ ████ ██ ██ ██████ ████ ██ ██████████ ████ ██████ ██ ██████████ +██████████ ████████ ██ ██████ ██ ██ ████ ██████ ██████ ████ ██ ████ ████ ██████ ██████████ ██ ██ ██ ██ ████ ████ ██████ ████████████ ██████████████ ██ ██████ ████ ████ ████ ████ ██ ████ ████████████ +████████ ██████ ████████████ ████ ████ ██ ██████ ████ ██████████ ██ ██ ██████ ██ ██ ██ ████ ██ ████████████ ██████ ██████ ██████ ██████ ████ ██████ ██████ ██ ████ ██ ██ ████ ████ ████ ██████████ ████████████ +████████ ██ ████ ██ ██ ██ ████████ ██ ████ ██ ██ ██ ██████ ██ ██ ████ ██ ██ ████ ████ ████████ ██████████████████████ ████ ██ ██ ██ ██ ██ ██████ ████ ██ ████ ██████ ████ ████ ██ ██ ████████ +██████████ ██████ ██ ██████ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██████ ██ ████ ████ ██ ██ ██████ ██████ ██████ ██ ████ ██ ██████ ██ ██ ████ ██ ██ ██ ██ ██████████ +████████ ██ ██████ ██ ██ ██ ██████ ████ ██████ ██████ ██████ ██████ ██ ██████ ████ ██ ████ ██ ████ ██ ██ ██ ████ ████ ████ ██ ██████ ████████████ ████ ████ ██████ ██ ██ ████████████ +██████████ ██████████████ ██ ██ ██ ████████████ ██ ██ ████ ██████ ████ ██ ██ ██ ██ ████ ██████ ████ ██████ ██████ ████████████ ██ ██ ████ ██ ██ ██ ████ ██████████ ████████████ ██ ██████ ████ ██ ████████████ +████████ ██ ██ ██████ ██████ ██████ ██████████ ████ ████████ ████ ██ ██ ██████ ██ ██ ██████████ ████ ████████████ ██ ██ ██ ████ ██ ████ ██ ██ ████ ██████ ██████ ████ ████████ ██ ████████ +████████████████████████ ████ ██ ██ ████ ████ ██ ██ ██ ██████ ████ ████ ████████ ██ ██ ██████ ████ ██████ ██ ██ ██████ ██████ ██████ ██████ ████ ██ ████ ██████ ████ ██ ██ ██ ██ ██████ ████████████████ +████████ ████ ██████ ██ ████ ██ ██ ██ ██ ██ ██████ ████ ████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ████ ██████ ████ ██ ██ ████ ██ ██████ ██ ██ ██ ██ ██████████ +████████ ██████████ ██████ ██████ ██ ██ ██████ ██ ██████ ██████████ ██ ████ ██ ██ ██ ██ ██████ ██████████████ ████ ██ ████ ██ ██████ ██ ██ ██ ████ ██████ ████████████ ████ ████ ██ ████ ██████ ██ ████████ +████████ ██ ██ ██ ████████████████ ██ ██ ██ ████ ████ ██████ ██ ██ ██ ██ ██ ██ ████████ ██████ ████ ██ ██ ██ ██ ██ ████ ██ ██ ████ ████ ██ ██████ ████ ████ ██████████ ████████████ +████████ ██ ██ ██████ ██ ████ ██ ████ ████ ████████ ██ ██ ██████ ████ ██ ██ ████ ████ ██ ██ ██ ████ ██ ██ ██████████ ██████ ██████ ██ ██ ██ ████ ████ ██ ██████ ████████ ██████████ +████████ ██ ██ ██ ██████ ████ ████ ██ ██ ████████ ████████ ██ ██ ██ ████ ████ ██ ██████████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ████ ██ ████ ████ ██ ████ ██ ██ ████ ████ ██ ████████ +████████ ██████████ ████ ████ ██ ██ ██████ ██ ████ ██ ██ ████ ██ ████████████ ████████████ ██ ██ ██ ████ ██████ ████ ██ ████ ████ ██ ████████ ████ ██ ██ ██ ██ ██ ██ ██████ ██ ████ ██ ████████ ██ ████ ██████████ +████████ ██ ████ ██ ████ ██████ ██ ████ ████ ██████ ██ ██████ ██████████ ██████████ ██ ██ ████████████████████ ██ ████ ████ ████ ██ ████████ ██ ████ ██ ██████████ ██ ██████ ████████ ██ ████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ diff --git a/QRCodeLibrary/BitArray.hpp b/QRCodeLibrary/BitArray.hpp index cca56ac..4125fd6 100644 --- a/QRCodeLibrary/BitArray.hpp +++ b/QRCodeLibrary/BitArray.hpp @@ -2,10 +2,12 @@ #include <vector> #include <string> +#include <stdexcept> using namespace std; constexpr unsigned ceil_div(unsigned a, unsigned b) { + if (b == 0) throw runtime_error("Dividion by zero not possible"); return a / b + (a % b > 0); } diff --git a/QRCodeLibrary/Encoder.cpp b/QRCodeLibrary/Encoder.cpp index e908325..74a7867 100644 --- a/QRCodeLibrary/Encoder.cpp +++ b/QRCodeLibrary/Encoder.cpp @@ -40,33 +40,6 @@ char Encoder::determite_version(unsigned size, CorrectionLevel corr_lvl) return version; } -unsigned Encoder::calculate_encoded_input_size(unsigned input_size, QRCodeMethod method) -{ - if (method == QRCodeMethod::Dynamic) throw std::runtime_error("Specify correct method"); - - unsigned bit_num = 0; - - switch (method) { - case QRCodeMethod::Numeric: - bit_num = 10 * (input_size / 3); - if (input_size % 3 == 2) - bit_num += 7; - else if (input_size % 3 == 1) - bit_num += 4; - break; - case QRCodeMethod::Alphabetic: - bit_num = 11 * (input_size / 2); - if (input_size % 2 == 1) - bit_num += 6; - break; - case QRCodeMethod::Byte: - bit_num = input_size * 8; - break; - } - - return bit_num; -} - unsigned Encoder::calculate_metadata_size(QRCodeMethod method, char version) { if (method == QRCodeMethod::Dynamic) throw std::runtime_error("Specify correct method"); @@ -123,13 +96,16 @@ void Encoder::encode_byte(const string& input, BitArray& out, unsigned offset) out.set(offset + i * 8, input[i], 8); } -unsigned char Encoder::encode_char(char ch) +constexpr unsigned char Encoder::encode_char(char ch) { - for (unsigned i = 0; i < Tables::alphabetic.size(); i++) + for (unsigned char i = 0; i < Tables::alphabetic.size(); i++) if (ch == Tables::alphabetic.at(i)) return i; - throw std::runtime_error("No such character in alphabet. Use bytes QR code method."); + if (!Tables::is_alphabetic(ch)) + throw std::runtime_error("No such character in alphabet. Use bytes QR code method."); + + return 0; } void Encoder::pad_data(BitArray& arr, unsigned bits_written) @@ -141,13 +117,6 @@ void Encoder::pad_data(BitArray& arr, unsigned bits_written) arr.v[i] = ((i - encoded_bytes) % 2 == 0) ? 0b11101100 : 0b00010001; } -char Encoder::get_version() const -{ - if (version < 0) throw std::runtime_error("Determite version before getting it"); - - return version; -} - BitArray Encoder::get_data() const { if (e.size == 0) throw std::runtime_error("Data is not calculated yet"); diff --git a/QRCodeLibrary/Encoder.hpp b/QRCodeLibrary/Encoder.hpp index 7ebda8a..359b7d5 100644 --- a/QRCodeLibrary/Encoder.hpp +++ b/QRCodeLibrary/Encoder.hpp @@ -2,6 +2,7 @@ #include <string> #include <array> +#include <stdexcept> #include "Method.hpp" #include "BitArray.hpp" @@ -17,7 +18,7 @@ public: static char determite_version(unsigned size, CorrectionLevel corr_lvl); - static unsigned calculate_encoded_input_size(unsigned input_size, QRCodeMethod method); + static constexpr unsigned calculate_encoded_input_size(unsigned input_size, QRCodeMethod method); static unsigned calculate_metadata_size(QRCodeMethod method, char version); static void write_metadata(unsigned input_size, unsigned input_bits_amount_size, QRCodeMethod method, BitArray& out); @@ -40,14 +41,14 @@ public: static void encode_alphabetic(const string& input, BitArray& out, unsigned offset); static void encode_byte(const string& input, BitArray& out, unsigned offset); - static unsigned char encode_char(char ch); - static void pad_data(BitArray& arr, unsigned bits_written); - char get_version() const; + constexpr char get_version() const { return version; }; BitArray get_data() const; private: + static constexpr unsigned char encode_char(char ch); + const string input; CorrectionLevel corr_lvl; const QRCodeMethod method; @@ -56,6 +57,33 @@ private: BitArray e; }; +constexpr unsigned Encoder::calculate_encoded_input_size(unsigned input_size, QRCodeMethod method) +{ + if (method == QRCodeMethod::Dynamic) throw std::runtime_error("Specify correct method"); + + unsigned bit_num = 0; + + switch (method) { + case QRCodeMethod::Numeric: + bit_num = 10 * (input_size / 3); + if (input_size % 3 == 2) + bit_num += 7; + else if (input_size % 3 == 1) + bit_num += 4; + break; + case QRCodeMethod::Alphabetic: + bit_num = 11 * (input_size / 2); + if (input_size % 2 == 1) + bit_num += 6; + break; + case QRCodeMethod::Byte: + bit_num = input_size * 8; + break; + } + + return bit_num; +} + template <typename T, size_t N> constexpr unsigned upper_index(const array<T, N> arr, T val) { unsigned count = arr.size(), s = 0, e = 0, step = 0; diff --git a/QRCodeLibrary/Method.cpp b/QRCodeLibrary/Method.cpp index 42ece72..0d3524b 100644 --- a/QRCodeLibrary/Method.cpp +++ b/QRCodeLibrary/Method.cpp @@ -1,7 +1,5 @@ #include "pch.h" -#include <algorithm> - #include "Method.hpp" #include "Tables.hpp" @@ -14,7 +12,7 @@ QRCodeMethod Method::determite_method(string& input) if (!is_num(ch)) type = QRCodeMethod::Alphabetic; if (type == QRCodeMethod::Alphabetic) - if (!is_alphabetic(ch)) + if (!Tables::is_alphabetic(ch)) type = QRCodeMethod::Byte; if (type == QRCodeMethod::Byte) break; @@ -22,8 +20,3 @@ QRCodeMethod Method::determite_method(string& input) return type; } - -bool Method::is_alphabetic(char ch) -{ - return find(Tables::alphabetic.cbegin(), Tables::alphabetic.cend(), ch) != Tables::alphabetic.cend(); -} diff --git a/QRCodeLibrary/Method.hpp b/QRCodeLibrary/Method.hpp index 8c2e41a..0838b5f 100644 --- a/QRCodeLibrary/Method.hpp +++ b/QRCodeLibrary/Method.hpp @@ -23,5 +23,4 @@ public: static QRCodeMethod determite_method(string& input); static constexpr bool is_num(char ch) { return ch >= '0' && ch <= '9'; }; - static bool is_alphabetic(char ch); -}; \ No newline at end of file +}; diff --git a/QRCodeLibrary/QRCode.hpp b/QRCodeLibrary/QRCode.hpp index d46240c..637ec8c 100644 --- a/QRCodeLibrary/QRCode.hpp +++ b/QRCodeLibrary/QRCode.hpp @@ -12,8 +12,8 @@ class QRCode public: QRCode(string& input_, CorrectionLevel corr_lvl_ = CorrectionLevel::M, QRCodeMethod method_ = QRCodeMethod::Dynamic, char version_ = -1, unsigned char mask_n = 0); - string to_string() { return matrix.to_string(); }; - string to_ascii(char black = '#', char white = ' ', char empty = 'E') { return matrix.to_ascii(black, white, empty); } + string to_string() const { return matrix.to_string(); }; + string to_ascii(char black = '#', char white = ' ', char empty = 'E') const { return matrix.to_ascii(black, white, empty); } vector<vector<Trit>> to_vector() const { return matrix.to_vector(); }; protected: diff --git a/QRCodeLibrary/Tables.hpp b/QRCodeLibrary/Tables.hpp index a768746..a16df0d 100644 --- a/QRCodeLibrary/Tables.hpp +++ b/QRCodeLibrary/Tables.hpp @@ -8,7 +8,7 @@ #include "Method.hpp" namespace Tables { - static const std::array<char, 45> alphabetic{ + static constexpr std::array<char, 45> alphabetic{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', @@ -16,6 +16,15 @@ namespace Tables { '+', '-', '.', '/', ':' }; + constexpr bool is_alphabetic(char ch) + { + for (unsigned i = 0; i < Tables::alphabetic.size(); i++) + if (Tables::alphabetic[i] == ch) + return true; + + return false; + } + static const std::map<CorrectionLevel, const std::array<unsigned, 40>>max_capability{ { CorrectionLevel::L, {{ 152, 272, 440, 640, 864, 1088, 1248, 1552, 1856, 2192, 2592, 2960, 3424, 3688, 4184, 4712, 5176, 5768, 6360, 6888, 7456, 8048, 8752, 9392, 10208, 10960, 11744, 12248, 13048, 13880, 14744, 15640, 16568, 17528, 18448, 19472, 20528, 21616, 22496, 23648 }} }, { CorrectionLevel::M, {{ 128, 224, 352, 512, 688, 864, 992, 1232, 1456, 1728, 2032, 2320, 2672, 2920, 3320, 3624, 4056, 4504, 5016, 5352, 5712, 6256, 6880, 7312, 8000, 8496, 9024, 9544, 10136, 10984, 11640, 12328, 13048, 13800, 14496, 15312, 15936, 16816, 17728, 18672 }} }, @@ -64,7 +73,7 @@ namespace Tables { { 30, {{ 41, 173, 145, 152, 216, 31, 179, 182, 50, 48, 110, 86, 239, 96, 222, 125, 42, 173, 226, 193, 224, 130, 156, 37, 251, 216, 238, 40, 192, 180 }}} }; - static const std::array<unsigned char, 256>galois_field{ + static constexpr std::array<unsigned char, 256>galois_field{ 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, @@ -83,7 +92,7 @@ namespace Tables { 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1, }; - static const std::array<unsigned char, 256>reverse_galois_field{ + static constexpr std::array<unsigned char, 256>reverse_galois_field{ 0, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69, @@ -114,7 +123,7 @@ namespace Tables { {6, 28, 54, 80, 106, 132, 158}, {6, 32, 58, 84, 110, 136, 162}, {6, 26, 54, 82, 110, 138, 166}, {6, 30, 58, 86, 114, 142, 170} }; - static const array<const array<unsigned char, 3>, 34>version_codes{ { + static constexpr array<const array<unsigned char, 3>, 34>version_codes{ { { 0b000010, 0b011110, 0b100110 }, { 0b010001, 0b011100, 0b111000 }, { 0b110111, 0b011000, 0b000100 }, diff --git a/README.MD b/README.MD index 3c94477..2a2222e 100644 --- a/README.MD +++ b/README.MD @@ -22,8 +22,8 @@ public: unsigned char mask_n = 0 // index of mask to use (see below for different masks options) ); - string to_string() { return matrix.to_string(); }; // presents qr-code as multiline string of zeros and ones - string to_ascii(char black = '#', char white = ' ', char empty = 'E') { return matrix.to_ascii(black, white, empty); } // presents qr-code as multiline string of specified characters + string to_string() const { return matrix.to_string(); }; // presents qr-code as multiline string of zeros and ones + string to_ascii(char black = '#', char white = ' ', char empty = 'E') const { return matrix.to_ascii(black, white, empty); } // presents qr-code as multiline string of specified characters vector<vector<Trit>> to_vector() const { return matrix.to_vector(); }; // presents qr-code as 2D vector of Trits } ```