CBL C++ examples

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

From what I found, the Couchbase Lite API is C, but can be called from C++

C++ examples for Couchbase Lite? :slight_smile:

There are now C++ wrappers for the C API, but the only documentation is the header files: couchbase-lite-C/include/cbl++ at 6fbf98af1da3f573fb8cf734a545f0047f2663c1 · couchbase/couchbase-lite-C · GitHub

There is also documentation in the read me which is the first link I gave.

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

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:

1 Like