-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsymbol.go
More file actions
37 lines (31 loc) · 693 Bytes
/
symbol.go
File metadata and controls
37 lines (31 loc) · 693 Bytes
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
package grcode
// #cgo LDFLAGS: -lzbar
// #include <zbar.h>
import "C"
type Symbol struct {
symbol *C.zbar_symbol_t
}
// NewSymbol new the symbol object
func NewSymbol(z *C.zbar_symbol_t) *Symbol {
return &Symbol{symbol: z}
}
// Next returns next symbol
func (s *Symbol) Next() *Symbol {
n := C.zbar_symbol_next(s.symbol)
if n != nil {
return NewSymbol(n)
}
return nil
}
// Data returns the string data of the symbol
func (s *Symbol) Data() string {
data := C.zbar_symbol_get_data(s.symbol)
if data != nil {
return C.GoString(data)
}
return ""
}
// Type returns the symbol type
func (s *Symbol) Type() SymbolType {
return SymbolType{t: C.zbar_symbol_get_type(s.symbol)}
}