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