'c4Internal::Database' has protected destructor

19 views
Skip to first unread message

Adam Wilson

unread,
May 27, 2018, 5:07:55 AM5/27/18
to Couchbase Mobile
I'm using LiteCoreStatic lib in a C++ project, and hit this compilation error: 

'c4Internal::Database' has protected destructor

My sample code:

#include "Database.hh"

static const C4DatabaseConfig kDBConfig = {
    .flags = (kC4DB_Create | kC4DB_AutoCompact | kC4DB_SharedKeys),
    .storageEngine = kC4SQLiteStorageEngine,
    .versioning = kC4RevisionTrees,
};


//==============================================================================
int main (int argc, char* argv[])
{
    Database db ("./c4db/db", kDBConfig);

    db.putRawDocument("test", slice("myKey"), slice(""), slice("goldenRatio") );

    Record record = db.getRawDocument("test", slice("myKey"));
    std::cout << record.key().asString() << ":" << record.body().asString();
}

Should I be instantiating the Database class differently?

Adam Wilson

unread,
May 27, 2018, 5:09:36 PM5/27/18
to Couchbase Mobile
Looking into the library code a bit more, I realised I just need to use the C4Database subclass. 

Jens Alfke

unread,
Jun 11, 2018, 12:59:08 PM6/11/18
to mobile-c...@googlegroups.com


On May 27, 2018, at 2:07 AM, Adam Wilson <adam.el...@gmail.com> wrote:

Should I be instantiating the Database class differently?

Database (and its subclass C4Database) are ref-counted, so they can only be allocated on the heap, like this:
Retained<Database> db = new Database(…);

Using LiteCore directly is unsupported, and using its C++ API is doubly unsupported — that’s not even considered a public API of LiteCore, it’s just the internal implementation. Please use the C API instead. (There are some convenience wrappers in c4.hh that make it a lot more convenient to use in C++.)

—Jens

Jens Alfke — Mobile Architect — Couchbase, Inc.

adam wilson

unread,
Jun 12, 2018, 3:31:13 AM6/12/18
to mobile-c...@googlegroups.com
Thanks Jens. I'll reconsider my approach. 

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/YgxDAvueSeI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/45C0F2A0-9D10-4A2B-8B55-4FFE752A7B75%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages