コード例 #1
0
ファイル: db.go プロジェクト: gmuch/gmuch
// NewQuery creates a new query from a string following xapian format.
func (db *DB) NewQuery(queryString string) *Query {
	cstr := C.CString(queryString)
	defer C.free(unsafe.Pointer(cstr))
	cquery := C.notmuch_query_create(db.toC(), cstr)
	query := &Query{
		cptr:   unsafe.Pointer(cquery),
		parent: (*cStruct)(db),
	}
	setGcClose(query)
	return query
}
コード例 #2
0
ファイル: notmuch.go プロジェクト: kalbasit/go.notmuch
func (db *DB) QueryCreate(queryString string) *Query {
	cstr := C.CString(queryString)
	defer C.free(unsafe.Pointer(cstr))
	cquery := C.notmuch_query_create(db.toC(), cstr)
	query := &Query{
		cptr: cquery,
		db:   db,
	}
	runtime.SetFinalizer(query, func(q *Query) {
		C.notmuch_query_destroy(q.toC())
	})
	return query
}
コード例 #3
0
ファイル: notmuch.go プロジェクト: vlmarek/notmuch-solaris
/* Create a new query for 'database'.
 *
 * Here, 'database' should be an open database, (see
 * notmuch_database_open and notmuch_database_create).
 *
 * For the query string, we'll document the syntax here more
 * completely in the future, but it's likely to be a specialized
 * version of the general Xapian query syntax:
 *
 * http://xapian.org/docs/queryparser.html
 *
 * As a special case, passing either a length-zero string, (that is ""),
 * or a string consisting of a single asterisk (that is "*"), will
 * result in a query that returns all messages in the database.
 *
 * See notmuch_query_set_sort for controlling the order of results.
 * See notmuch_query_search_messages and notmuch_query_search_threads
 * to actually execute the query.
 *
 * User should call notmuch_query_destroy when finished with this
 * query.
 *
 * Will return NULL if insufficient memory is available.
 */
func (self *Database) CreateQuery(query string) *Query {

	var c_query *C.char = C.CString(query)
	defer C.free(unsafe.Pointer(c_query))

	if c_query == nil {
		return nil
	}

	q := C.notmuch_query_create(self.db, c_query)
	if q == nil {
		return nil
	}
	return &Query{query: q}
}