/
codedata.h
95 lines (75 loc) · 2.14 KB
/
codedata.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/////////////////////////////////////////////////////////////////////////
//
// codedata.h --a part of libdecodeqr
//
// Copyright(C) 2007 NISHI Takao <zophos@koka-in.org>
// JMA (Japan Medical Association)
// NaCl (Network Applied Communication Laboratory Ltd.)
//
// This is free software with ABSOLUTELY NO WARRANTY.
// You can redistribute and/or modify it under the terms of LGPL.
//
// $Id: codedata.h 36 2007-02-21 23:22:03Z zophos $
//
#ifndef __QR_CODE_DATA__
#define __QR_CODE_DATA__
#include <memory.h>
#include "galois.h"
#include "bitstream.h"
#include "ecidecoder.h"
#include "qrerror.h"
#ifndef NULL
#define NULL 0
#endif
#define QR_CODE_DATA_GX 0x11d //G(x)=x^8+x^4+x^3+x^2+1
namespace Qr{
class CodeBlock{
public:
int total_words;
int data_words;
int capability;
unsigned char *data;
short status;
private:
int _size;
Galois::Field *_gf;
public:
CodeBlock(int total_words,int data_words,int capability,
Galois::Field *gf);
~CodeBlock();
void clear();
unsigned char *push(unsigned char data);
bool has_vacant_data();
int error_correct();
};
class CodeData{
public:
int version;
int level;
int total_words; // total words (data+ecc)
int data_words; // number of data words
int data_blocks; // number of rs_block
CodeBlock **data;
int length; // number of decoded charactors
int byte_length;
short status;
private:
Galois::Field *_gf;
int _size;
int _index;
unsigned char *_raw_data;
public:
CodeData(int version,int level);
~CodeData();
void clear();
unsigned char *push(unsigned char data);
unsigned char *dump();
unsigned char *dump_block(int index);
unsigned char *dump_data();
unsigned char *raw_data();
int decode();
private:
int _error_correct();
};
};
#endif