From 3d98710648f2bdc94aa1ad400d6d4e38a1d2efc3 Mon Sep 17 00:00:00 2001 From: dm1sh Date: Sun, 12 Dec 2021 16:25:27 +0300 Subject: [PATCH] Switched from class to namespace for Tables organization --- QRCodeLibrary/QRCodeLibrary.vcxproj | 1 - QRCodeLibrary/QRCodeLibrary.vcxproj.filters | 3 -- QRCodeLibrary/Tables.cpp | 30 ------------------- QRCodeLibrary/Tables.hpp | 32 ++++++++++++++++----- 4 files changed, 25 insertions(+), 41 deletions(-) delete mode 100644 QRCodeLibrary/Tables.cpp diff --git a/QRCodeLibrary/QRCodeLibrary.vcxproj b/QRCodeLibrary/QRCodeLibrary.vcxproj index bca060a..1101763 100644 --- a/QRCodeLibrary/QRCodeLibrary.vcxproj +++ b/QRCodeLibrary/QRCodeLibrary.vcxproj @@ -172,7 +172,6 @@ Create - diff --git a/QRCodeLibrary/QRCodeLibrary.vcxproj.filters b/QRCodeLibrary/QRCodeLibrary.vcxproj.filters index 0e0799f..f291a63 100644 --- a/QRCodeLibrary/QRCodeLibrary.vcxproj.filters +++ b/QRCodeLibrary/QRCodeLibrary.vcxproj.filters @@ -50,9 +50,6 @@ Source Files - - Source Files - Source Files diff --git a/QRCodeLibrary/Tables.cpp b/QRCodeLibrary/Tables.cpp deleted file mode 100644 index 367da28..0000000 --- a/QRCodeLibrary/Tables.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "pch.h" - -#include "Tables.hpp" - -const std::array Tables::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', - 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', - '+', '-', '.', '/', ':' -}; - -const std::map> Tables::max_capability{ - { CorrectionLevel::L, {{152, 272, 440, 640, 864, 1088, 1248, 1552, 1856, 2192, 2592, 2960, 3424, 3688, 4184, 4712, 5176, 5768, 6360, 6888}} }, - { CorrectionLevel::M, {{128, 224, 352, 512, 688, 864, 992, 1232, 1456, 1728, 2032, 2320, 2672, 2920, 3320, 3624, 4056, 4504, 5016, 5352}} }, - { CorrectionLevel::Q, {{104, 176, 272, 384, 496, 608, 704, 880, 1056, 1232, 1440, 1648, 1952, 2088, 2360, 2600, 2936, 3176, 3560, 3880}} }, - { CorrectionLevel::H, {{72, 128, 208, 288, 368, 480, 528, 688, 800, 976, 1120, 1264, 1440, 1576, 1784, 2024, 2264, 2504, 2728, 3080}} } -}; - -const std::map Tables::mode_indicator{ - { QRCodeMethod::Numeric, 0b0001 }, - { QRCodeMethod::Alphabetic, 0b0010 }, - { QRCodeMethod::Byte, 0b0100 } -}; - -const std::map, 3>> Tables::data_amount_lengths{ - { QRCodeMethod::Numeric, {{ {0, 10}, {8, 12}, {25, 14} }} }, - { QRCodeMethod::Alphabetic, {{ {0, 9}, {8, 11}, {25, 13} }} } , - { QRCodeMethod::Byte, {{ {0, 8}, {8, 16}, {25, 16} }} } -}; diff --git a/QRCodeLibrary/Tables.hpp b/QRCodeLibrary/Tables.hpp index 76759ad..76fd77e 100644 --- a/QRCodeLibrary/Tables.hpp +++ b/QRCodeLibrary/Tables.hpp @@ -5,12 +5,30 @@ #include "Method.hpp" -class Tables { -public: - static const std::arrayalphabetic; +namespace Tables { + static const std::array 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', + 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', + '+', '-', '.', '/', ':' + }; - static const std::map>max_capability; + static const std::map> max_capability{ + { CorrectionLevel::L, {{152, 272, 440, 640, 864, 1088, 1248, 1552, 1856, 2192, 2592, 2960, 3424, 3688, 4184, 4712, 5176, 5768, 6360, 6888}} }, + { CorrectionLevel::M, {{128, 224, 352, 512, 688, 864, 992, 1232, 1456, 1728, 2032, 2320, 2672, 2920, 3320, 3624, 4056, 4504, 5016, 5352}} }, + { CorrectionLevel::Q, {{104, 176, 272, 384, 496, 608, 704, 880, 1056, 1232, 1440, 1648, 1952, 2088, 2360, 2600, 2936, 3176, 3560, 3880}} }, + { CorrectionLevel::H, {{72, 128, 208, 288, 368, 480, 528, 688, 800, 976, 1120, 1264, 1440, 1576, 1784, 2024, 2264, 2504, 2728, 3080}} } + }; - static const std::mapmode_indicator; - static const std::map, 3>>data_amount_lengths; -}; \ No newline at end of file + static const std::map mode_indicator{ + { QRCodeMethod::Numeric, 0b0001 }, + { QRCodeMethod::Alphabetic, 0b0010 }, + { QRCodeMethod::Byte, 0b0100 } + }; + static const std::map, 3>> data_amount_lengths{ + { QRCodeMethod::Numeric, {{ {0, 10}, {8, 12}, {25, 14} }} }, + { QRCodeMethod::Alphabetic, {{ {0, 9}, {8, 11}, {25, 13} }} } , + { QRCodeMethod::Byte, {{ {0, 8}, {8, 16}, {25, 16} }} } + }; +}