Standardize and update all copyright statements to name "ZXing authors" as suggested...
[zxing.git] / cpp / core / src / 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 "Mode.h"
27 #include "../../common/BitSource.h"
28 #include "../../common/Counted.h"
29 #include "../../common/Array.h"
30
31 #include <iconv.h>
32
33 namespace qrcode {
34   namespace decoder {
35
36     using namespace common;
37     using namespace std;
38     
39     class DecodedBitStreamParser {
40     private:
41       static char ALPHANUMERIC_CHARS[];
42       
43       static char *ASCII;
44       static char *ISO88591;
45       static char *UTF8;
46       static char *SHIFT_JIS;
47       static char *EUC_JP;
48       
49       static void decodeKanjiSegment(Ref<BitSource> bits,
50                                      ostringstream &result,
51                                      int count);
52       static void decodeByteSegment(Ref<BitSource> bits,
53                                     ostringstream &result,
54                                     int count);
55       static void decodeAlphanumericSegment(Ref<BitSource> bits,
56                                             ostringstream &result,
57                                             int count);
58       static void decodeNumericSegment(Ref<BitSource> bits,
59                                        ostringstream &result,
60                                        int count);
61       static char *guessEncoding(unsigned char *bytes, int length);
62       static void append(ostream &ost, unsigned char *bufIn, 
63                          size_t nIn, const char *src);
64       
65     public:
66       static string decode(ArrayRef<unsigned char> bytes, Version *version);
67     };
68     
69   }
70 }
71
72 #endif // __DECODED_BIT_STREAM_PARSER_H__