Giter VIP home page Giter VIP logo

libcouchbase-cxx's Introduction

Couchbase++ - C++ Wrappers for libcouchbase

This file contains header-only C++ wrappers for libcouchbase. It is a work in progress.

Requirements

  • libcouchbase
  • A C++11 compiler (Sorry, there is no legacy C++ version yet)

Building/Installing

Since this is a header-only library there is no need to install or build anything. All components are preprocessor headers which are compiled with your own source code.

There is a CMakeLists.txt included, mainly for building examples and tests.

Documentation

Documentation can be generated using Doxygen. To generate the documentation, do the following:

make -f doc/Makefile public

The documentation index will then be available in HTML form in doc/public/html/index.html.

Note that all documentation can also be accessed from within the headers.

Examples

There is an example.cpp file in the repository root.

libcouchbase-cxx's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libcouchbase-cxx's Issues

Multiple redefinition errors still occurring

Hi, sorry to be a pain but I'm still getting multiple redefinition errors in C++. Unfortunately your test does not catch these because you aren't including all of your includes in them, only the top level.

If you update the tests/redef_X.cpp files to include all headers, the test breaks again:

#include <libcouchbase/couchbase++.h>
#include <libcouchbase/couchbase++/views.h>
#include <libcouchbase/couchbase++/query.h>
#include <libcouchbase/couchbase++/endure.h>
#include <libcouchbase/couchbase++/logging.h>
#include <libcouchbase/couchbase++/row_common.h>
#include <libcouchbase/couchbase++/status.h>

Problem including header files in multiple C++ files

When I include the headers in more than one C++ files it gives multiple redefinition errors because the library is header only. I am solving this by marking the functions inline. Please tell me if it is correct approach and if it is I will submit a pull request.

Build fails

Although it is a header only library but when I try to build it, it builds the example.cpp file. Please fine the log below:

rhit@freedom:~/libcouchbase-cxx/build$ cmake ..
-- The C compiler identification is GNU 5.2.1
-- The CXX compiler identification is GNU 5.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rhit/libcouchbase-cxx/build
rhit@freedom:~/libcouchbase-cxx/build$ make -j8
Scanning dependencies of target example                                                                                                                                          
[100%] Building CXX object CMakeFiles/example.dir/example.cpp.o                                                                                                                  
In file included from /home/rhit/libcouchbase-cxx/include/libcouchbase/couchbase++.h:772:0,
                 from /home/rhit/libcouchbase-cxx/example.cpp:1:
/home/rhit/libcouchbase-cxx/include/libcouchbase/couchbase++/client.inl.h: In member function ‘void Couchbase::DurableResponse<T>::handle_response(Couchbase::Client&, int, const lcb_RESPBASE*)’:
/home/rhit/libcouchbase-cxx/include/libcouchbase/couchbase++/client.inl.h:354:36: error: no match for ‘operator*’ (operand type is ‘Couchbase::EndureResponse’)
         EndureContext dctx(client, *m_dur, this, status);
                                    ^
CMakeFiles/example.dir/build.make:54: recipe for target 'CMakeFiles/example.dir/example.cpp.o' failed
make[2]: *** [CMakeFiles/example.dir/example.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/example.dir/all' failed
make[1]: *** [CMakeFiles/example.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2

StoreCommand with LCB_SET and ttl set corrupts key

Say I instantiate StoreCommand template class with LCB_SET or create UpsertCommand object and set a ttl by calling expiry function then it corrupts the key and data is not stored. Sometimes keys also contain binary character which makes document impossible to delete from web UI.

Concurrent issue

Library crashes when used concurrently.
For example, run this ab -n 1000 -c 100 http://localhost/files - if /files is sending a query to couchbase (any any kind of - view, callbackquery, callbackviewquery) - it will crash the server.

class Client has possible design problems

class Client has a method deleted on line no. 766 which is

Client(Client&) = delete;

Now the problem because of this is I was trying to adapt instance pool from libcouchbase library to C++ version. I cannot do a pop because if I write something like

Couchasbe::Client h = instances.pop()

then I cannot do it. I would suggest to change the Client design to allow that to happen. I cannot cache any connected client to bucket because of that. May be my lack of knowledge is in my way.

Pedantic compiler flag generates warnings in row_common.h and couchbase++.h

Adding for example compiler flags "-pedantic -Wall" will generate reorder warnings which is easy to fix. See compiler output below:

Scanning dependencies of target example
[100%] Building CXX object CMakeFiles/example.dir/example.cpp.o
In file included from /usr/include/sched.h:30:0,
                 from /usr/include/pthread.h:25,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/gthr-default.h:35,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/gthr.h:148,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/ext/atomicity.h:35,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/basic_string.h:39,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/string:52,
                 from /home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++.h:9,
                 from /home/vagrant/development/libcouchbase-cxx/example.cpp:1:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h: In instantiation of ‘Couchbase::Internal::RowIterator<TRow>::RowIterator(const Couchbase::Internal::RowIterator<TRow>&) [with TRow = Couchbase::ViewRow]’:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/views.h:207:53:   required from here
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h:86:29: warning: ‘Couchbase::Internal::RowIterator<Couchbase::ViewRow>::rp’ will be initialized after [-Wreorder]
     RowProvider<TRow> *rp = NULL;
                             ^
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h:85:22: warning:   ‘const Couchbase::ViewRow* Couchbase::Internal::RowIterator<Couchbase::ViewRow>::pp’ [-Wreorder]
     const TRow *pp = NULL;
                      ^
In file included from /home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/views.h:9:0,
                 from /home/vagrant/development/libcouchbase-cxx/example.cpp:2:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h:56:5: warning:   when initialized here [-Wreorder]
     RowIterator(const RowIterator& other) : rp(other.rp), pp(other.pp) {
     ^
In file included from /usr/include/sched.h:30:0,
                 from /usr/include/pthread.h:25,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/gthr-default.h:35,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/gthr.h:148,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/ext/atomicity.h:35,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/bits/basic_string.h:39,
                 from /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/string:52,
                 from /home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++.h:9,
                 from /home/vagrant/development/libcouchbase-cxx/example.cpp:1:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h: In instantiation of ‘Couchbase::Internal::RowIterator<TRow>::RowIterator(const Couchbase::Internal::RowIterator<TRow>&) [with TRow = Couchbase::QueryRow]’:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/query.h:194:46:   required from here
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h:86:29: warning: ‘Couchbase::Internal::RowIterator<Couchbase::QueryRow>::rp’ will be initialized after [-Wreorder]
     RowProvider<TRow> *rp = NULL;
                             ^
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h:85:22: warning:   ‘const Couchbase::QueryRow* Couchbase::Internal::RowIterator<Couchbase::QueryRow>::pp’ [-Wreorder]
     const TRow *pp = NULL;
                      ^
In file included from /home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/views.h:9:0,
                 from /home/vagrant/development/libcouchbase-cxx/example.cpp:2:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/row_common.h:56:5: warning:   when initialized here [-Wreorder]
     RowIterator(const RowIterator& other) : rp(other.rp), pp(other.pp) {
     ^
In file included from /home/vagrant/development/libcouchbase-cxx/example.cpp:1:0:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/batch.inl.h: In instantiation of ‘Couchbase::CallbackCommand<C, R>::CallbackCommand(Couchbase::Client&, Couchbase::CallbackCommand<C, R>::CallbackType&) [with C = Couchbase::GetCommand; R = Couchbase::GetResponse; Couchbase::CallbackCommand<C, R>::CallbackType = const std::function<void(Couchbase::GetResponse&)>]’:
/home/vagrant/development/libcouchbase-cxx/example.cpp:70:6:   required from here
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++.h:655:13: warning: ‘Couchbase::CallbackCommand<Couchbase::GetCommand, Couchbase::GetResponse>::m_ctx’ will be initialized after [-Wreorder]
     Context m_ctx;
             ^
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++.h:654:18: warning:   ‘Couchbase::CallbackCommand<Couchbase::GetCommand, Couchbase::GetResponse>::CallbackType Couchbase::CallbackCommand<Couchbase::GetCommand, Couchbase::GetResponse>::m_callback’ [-Wreorder]
     CallbackType m_callback;
                  ^
In file included from /home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++.h:773:0,
                 from /home/vagrant/development/libcouchbase-cxx/example.cpp:1:
/home/vagrant/development/libcouchbase-cxx/include/libcouchbase/couchbase++/batch.inl.h:76:1: warning:   when initialized here [-Wreorder]
 CallbackCommand<C,R>::CallbackCommand(Client& c, CallbackType& cb)
 ^
Linking CXX executable bin/example
[100%] Built target example

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.