summaryrefslogtreecommitdiff
path: root/lib/Data/QRCode/Input.pm
blob: 937474ca790cd77a35ea0612af3419795e180141 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package Data::QRCode::Input; 
use strict;
use warnings;
# ABSTRACT: qrcodes in C 
# VERSION 
use Data::QRCode::Input::Inline with => 'Alien::QREncode';
use Data::QRCode::Input::Inline => (
    'DATA',
    autowrap => 1,
    typemaps => 'typemap',
);
 
=head1 SYNOPSIS
 
  use Data::QRCode::Input;
 
  my $input = Data::QRCode::Input->new();
 
  $input->version(3);
  $input->error_correction_level(Data::QRCode::Input::ECLEVEL_M);
  $input->append(Data::QRCode::Input::MODE_8, 'some data'),
 
=method C<new>
 
=cut
 
sub new {
    my ($class) = @_;
 
    my $self = QRinput_new();
    bless $self,$class;
    return $self;
}
 
=attr C<version>
 
=cut
 
sub version {
    my $self = shift;
    if (@_) {
        return QRinput_setVersion($self,shift);
    }
    else {
        return QRinput_getVersion($self);
    }
}
 
=attr C<error_correction_level>
 
=cut
 
sub error_correction_level {
    my $self = shift;
    if (@_) {
        return QRinput_setErrorCorrectionLevel($self,shift);
    }
    else {
        return QRinput_getErrorCorrectionLevel($self);
    }
}
 
=head2 CONSTANTS
 
=head3 Error Correction Level
 
=for :list
= C<ECLEVEL_L>
= C<ECLEVEL_M>
= C<ECLEVEL_Q>
= C<ECLEVEL_H>
 
=head3 Data Mode
 
=for :list
= C<MODE_NUM>
= C<MODE_AN>
= C<MODE_8>
= C<MODE_KANJI>
= C<MODE_STRUCTURE>
= C<MODE_ECI>
= C<MODE_FNC1FIRST>
= C<MODE_FNC1SECOND>
 
=method C<append>
 
=for Pod::Coverage
QRinput_getVersion
QRinput_setVersion
QRinput_getErrorCorrectionLevel
QRinput_setErrorCorrectionLevel
QRinput_new
 
=cut
 
1;
 
__DATA__
__C__
 
QRecLevel ECLEVEL_L() { return QR_ECLEVEL_L; }
QRecLevel ECLEVEL_M() { return QR_ECLEVEL_M; }
QRecLevel ECLEVEL_Q() { return QR_ECLEVEL_Q; }
QRecLevel ECLEVEL_H() { return QR_ECLEVEL_H; }
 
QRencodeMode MODE_NUM() { return QR_MODE_NUM; }
QRencodeMode MODE_AN() { return QR_MODE_AN; }
QRencodeMode MODE_8() { return QR_MODE_8; }
QRencodeMode MODE_KANJI() { return QR_MODE_KANJI; }
QRencodeMode MODE_STRUCTURE() { return QR_MODE_STRUCTURE; }
QRencodeMode MODE_ECI() { return QR_MODE_ECI; }
QRencodeMode MODE_FNC1FIRST() { return QR_MODE_FNC1FIRST; }
QRencodeMode MODE_FNC1SECOND() { return QR_MODE_FNC1SECOND; }
 
extern QRinput *QRinput_new(void);
void DESTROY(QRinput *input) { QRinput_free(input); }
 
int append(QRinput *input, QRencodeMode mode, SV *data) {
    unsigned char * str;
    STRLEN len;
 
    str = SvPVutf8(data,len);
    return QRinput_append(input,mode,len,str);
}
 
extern int QRinput_getVersion(QRinput *input);
extern int QRinput_setVersion(QRinput *input, int version);
 
extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input);
extern int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level);