adamski
November 7, 2024, 11:09pm
1
Are there any usage examples of the C++ API for CBL?
It would be very helpful to have step by step instructions and/or example code to look at.
Thanks
mreiche
November 8, 2024, 12:03am
2
C language bindings for the Couchbase Lite embedded NoSQL database engine
From what I found, the Couchbase Lite API is C, but can be called from C++
Couchbase Lite is our client-side document-database library, Couchbase Lite for C adds an ANSI C API so you can link it into C or C++ apps.
Est. reading time: 4 minutes
C++ examples for Couchbase Lite?
adamski
November 8, 2024, 10:59am
3
There is also documentation in the read me
which is the first link I gave.
C language bindings for the Couchbase Lite embedded NoSQL database engine
jens
November 8, 2024, 6:03pm
5
Those are basically one-for-one wrappers of the C API. What’s different is
they throw exceptions instead of using a C4Error “out” parameter
they automatically manage ref-counting of objects
callbacks are defined using C++ lambdas or std::function instead of C callbacks
The C API documentation should provide the info you’re looking for.
1 Like
jens
November 8, 2024, 6:06pm
6
Some of the unit tests in the CBL-C repo use the C++ API, so you could look at those as examples. Basically anything in the test
dir that has _Cpp
in its name. For example:
//
// DatabaseTest_Cpp.cc
//
// Copyright © 2019 Couchbase. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "CBLTest_Cpp.hh"
#include "fleece/Fleece.hh"
This file has been truncated. show original
1 Like