Small style stuff
[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  *  Copyright 2010 ZXing authors All rights reserved.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22
23 #include <string>
24 #include <sstream>
25 #include <zxing/qrcode/decoder/Mode.h>
26 #include <zxing/common/BitSource.h>
27 #include <zxing/common/Counted.h>
28 #include <zxing/common/Array.h>
29
30
31
32 namespace zxing {
33 namespace qrcode {
34
35 class DecodedBitStreamParser {
36 private:
37   static const char ALPHANUMERIC_CHARS[];
38
39   static const char *ASCII;
40   static const char *ISO88591;
41   static const char *UTF8;
42   static const char *SHIFT_JIS;
43   static const char *EUC_JP;
44
45   static void decodeKanjiSegment(Ref<BitSource> bits, std::string &result, int count);
46   static void decodeByteSegment(Ref<BitSource> bits, std::string &result, int count);
47   static void decodeAlphanumericSegment(Ref<BitSource> bits, std::string &result, int count);
48   static void decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count);
49   static const char *guessEncoding(unsigned char *bytes, int length);
50   static void append(std::string &ost, const unsigned char *bufIn, size_t nIn, const char *src);
51
52 public:
53   static std::string decode(ArrayRef<unsigned char> bytes, Version *version);
54 };
55
56 }
57 }
58
59 #endif // __DECODED_BIT_STREAM_PARSER_H__