Couchbase Lite C
Couchbase Lite C API
CBLQuery.h
Go to the documentation of this file.
1//
2// CBLQuery.h
3//
4// Copyright (c) 2018 Couchbase, Inc All rights reserved.
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17//
18
19#pragma once
20#include "CBLBase.h"
21#include "CBLQueryTypes.h"
22
24
61 CBLQueryLanguage language,
62 FLString queryString,
63 int* _cbl_nullable outErrorPos,
64 CBLError* _cbl_nullable outError) CBLAPI;
65
67
80 FLDict parameters) CBLAPI;
81
84
91 CBLError* _cbl_nullable outError) CBLAPI;
92
100
103
111 unsigned columnIndex) CBLAPI;
112
142
147 unsigned index) CBLAPI;
148
155 FLString key) CBLAPI;
156
161
166
169
171
194typedef void (*CBLQueryChangeListener)(void* _cbl_nullable context,
195 CBLQuery* query,
196 CBLListenerToken* token);
197
211 CBLQueryChangeListener listener,
212 void* _cbl_nullable context) CBLAPI;
213
223 CBLListenerToken *listener,
224 CBLError* _cbl_nullable outError) CBLAPI;
225
#define CBLAPI
Definition: CBL_Compat.h:104
#define _cbl_nullable
Definition: CBL_Compat.h:92
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:105
#define CBL_CAPI_END
Definition: CBL_Compat.h:106
#define _cbl_warn_unused
Definition: CBL_Compat.h:40
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:281
CBLQueryLanguage
Supported Query languages.
Definition: CBLQueryTypes.h:28
FLDict _cbl_nullable CBLQuery_Parameters(const CBLQuery *query)
Returns the query's current parameter bindings, if any.
CBLQuery * CBLResultSet_GetQuery(const CBLResultSet *rs)
Returns the Query that created this ResultSet.
void(* CBLQueryChangeListener)(void *_cbl_nullable context, CBLQuery *query, CBLListenerToken *token)
A callback to be invoked after the query's results have changed.
Definition: CBLQuery.h:194
void CBLQuery_SetParameters(CBLQuery *query, FLDict parameters)
Assigns values to the query's parameters.
_cbl_warn_unused FLSliceResult CBLQuery_Explain(const CBLQuery *)
Returns information about the query, including the translated SQLite form, and the search strategy.
FLSlice CBLQuery_ColumnName(const CBLQuery *, unsigned columnIndex)
Returns the name of a column in the result.
FLValue _cbl_nullable CBLResultSet_ValueForKey(const CBLResultSet *, FLString key)
Returns the value of a column of the current result, given its name.
FLArray CBLResultSet_ResultArray(const CBLResultSet *)
Returns the current result as an array of column values.
FLDict CBLResultSet_ResultDict(const CBLResultSet *)
Returns the current result as a dictionary mapping column names to values.
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute(CBLQuery *, CBLError *_cbl_nullable outError)
Runs the query, returning the results.
_cbl_warn_unused bool CBLResultSet_Next(CBLResultSet *)
Moves the result-set iterator to the next result.
struct CBLQuery CBLQuery
A compiled database query.
Definition: CBLBase.h:215
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:218
_cbl_warn_unused CBLQuery *_cbl_nullable CBLDatabase_CreateQuery(const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *_cbl_nullable outErrorPos, CBLError *_cbl_nullable outError)
Creates a new query by compiling the input string.
FLValue _cbl_nullable CBLResultSet_ValueAtIndex(const CBLResultSet *, unsigned index)
Returns the value of a column of the current result, given its (zero-based) numeric index.
_cbl_warn_unused CBLListenerToken * CBLQuery_AddChangeListener(CBLQuery *query, CBLQueryChangeListener listener, void *_cbl_nullable context)
Registers a change listener callback with a query, turning it into a "live query" until the listener ...
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_CopyCurrentResults(const CBLQuery *query, CBLListenerToken *listener, CBLError *_cbl_nullable outError)
Returns the query's entire current result set, after it's been announced via a call to the listener's...
unsigned CBLQuery_ColumnCount(const CBLQuery *)
Returns the number of columns in each result.
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:37
const struct _FLArray * FLArray
A reference to an array value.
Definition: FLBase.h:36
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:35
A struct holding information about an error.
Definition: CBLBase.h:104
A simple reference to a block of memory.
Definition: FLSlice.h:45
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:63