Version.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __VERSION_H__
  2. #define __VERSION_H__
  3. /*
  4. * Version.h
  5. * zxing
  6. *
  7. * Copyright 2010 ZXing authors All rights reserved.
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. */
  21. #include <zxing/common/Counted.h>
  22. #include <zxing/qrcode/ErrorCorrectionLevel.h>
  23. #include <zxing/ReaderException.h>
  24. #include <zxing/common/BitMatrix.h>
  25. #include <zxing/common/Counted.h>
  26. #include <vector>
  27. namespace zxing {
  28. namespace qrcode {
  29. class ECB {
  30. private:
  31. int count_;
  32. int dataCodewords_;
  33. public:
  34. ECB(int count, int dataCodewords);
  35. int getCount();
  36. int getDataCodewords();
  37. };
  38. class ECBlocks {
  39. private:
  40. int ecCodewords_;
  41. std::vector<ECB*> ecBlocks_;
  42. public:
  43. ECBlocks(int ecCodewords, ECB *ecBlocks);
  44. ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2);
  45. int getECCodewords();
  46. std::vector<ECB*>& getECBlocks();
  47. ~ECBlocks();
  48. };
  49. class Version : public Counted {
  50. private:
  51. int versionNumber_;
  52. std::vector<int> &alignmentPatternCenters_;
  53. std::vector<ECBlocks*> ecBlocks_;
  54. int totalCodewords_;
  55. Version(int versionNumber, std::vector<int> *alignmentPatternCenters, ECBlocks *ecBlocks1, ECBlocks *ecBlocks2,
  56. ECBlocks *ecBlocks3, ECBlocks *ecBlocks4);
  57. public:
  58. static unsigned int VERSION_DECODE_INFO[];
  59. static int N_VERSION_DECODE_INFOS;
  60. static std::vector<Ref<Version> > VERSIONS;
  61. ~Version();
  62. int getVersionNumber();
  63. std::vector<int> &getAlignmentPatternCenters();
  64. int getTotalCodewords();
  65. int getDimensionForVersion();
  66. ECBlocks &getECBlocksForLevel(ErrorCorrectionLevel &ecLevel);
  67. static Version *getProvisionalVersionForDimension(int dimension);
  68. static Version *getVersionForNumber(int versionNumber);
  69. static Version *decodeVersionInformation(unsigned int versionBits);
  70. Ref<BitMatrix> buildFunctionPattern();
  71. static int buildVersions();
  72. };
  73. }
  74. }
  75. #endif // __VERSION_H__