aboutsummaryrefslogtreecommitdiffstats
path: root/lib/notmuch/properties.go
blob: 6c025d050f7c8ebc1bff25fb2f9277864238f5c0 (plain) (blame)
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
//go:build notmuch
// +build notmuch

package notmuch

/*
#cgo LDFLAGS: -lnotmuch

#include <notmuch.h>

*/
import "C"

type Properties struct {
	key        *C.char
	value      *C.char
	properties *C.notmuch_message_properties_t
}

// Next advances the Properties iterator to the next property. Next returns false if
// no more properties are available
func (p *Properties) Next() bool {
	if C.notmuch_message_properties_valid(p.properties) == 0 {
		return false
	}
	p.key = C.notmuch_message_properties_key(p.properties)
	p.value = C.notmuch_message_properties_value(p.properties)
	C.notmuch_message_properties_move_to_next(p.properties)
	return true
}

// Returns the key of the current iterator location
func (p *Properties) Key() string {
	return C.GoString(p.key)
}

func (p *Properties) Value() string {
	return C.GoString(p.value)
}