Fixed things broken in the last commit.
[zxing.git] / cpp / core / src / zxing / qrcode / decoder / DecodedBitStreamParser.h
1 #ifndef __DECODED_BIT_STREAM_PARSER_H__
2 #define __DECODED_BIT_STREAM_PARSER_H__
3
4 /*
5  *  DecodedBitStreamParser.h
6  *  zxing
7  *
8  *  Created by Christian Brunschen on 20/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 <string>
25 #include <sstream>
26 #include <zxing/qrcode/decoder/Mode.h>
27 #include <zxing/common/BitSource.h>
28 #include <zxing/common/Counted.h>
29 #include <zxing/common/Array.h>
30
31
32
33 namespace zxing {
34 namespace qrcode {
35
36 class DecodedBitStreamParser {
37 private:
38   static const char ALPHANUMERIC_CHARS[];
39
40   static const char *ASCII;
41   static const char *ISO88591;
42   static const char *UTF8;
43   static const char *SHIFT_JIS;
44   static const char *EUC_JP;
45
46   static void decodeKanjiSegment(Ref<BitSource> bits, std::string &result, int count);
47   static void decodeByteSegment(Ref<BitSource> bits, std::string &result, int count);
48   static void decodeAlphanumericSegment(Ref<BitSource> bits, std::string &result, int count);
49   static void decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count);
50   static const char *guessEncoding(unsigned char *bytes, int length);
51   static void append(std::string &ost, const unsigned char *bufIn, size_t nIn, const char *src);
52
53 public:
54   static std::string decode(ArrayRef<unsigned char> bytes, Version *version);
55 };
56
57 }
58 }
59
60 #endif // __DECODED_BIT_STREAM_PARSER_H__