lmdb-safe icon indicating copy to clipboard operation
lmdb-safe copied to clipboard

Lots of minor changes

Open geiseri opened this issue 5 years ago • 2 comments

First of all a big thanks to you for this library. I was able to remove about 1k lines of questionable code. I did make a few changes though to adapt it to my codebase:

  1. Move the lmdb safe classes into their own namespace.
  2. Allow boost serialization to be optional. I use cbor from jsoncons, so I wanted to keep using that.
  3. Changed keyConv to use setToString for anything that was not a number or string. (I needed this to index on a uuid data type)
  4. Made iterator derive from std::iterator as a std::input_iterator_tag. Even though it is really bidirectional there are some features that it doesn't support to tag it as a bidirectional. Since I only did this so that I could use it with range-v3 I only needed forward.
  5. Added needed -- and != operators to iter_t and eiter_t to satisfy std::range requirements.

I attempted to keep the changes to a minimum, but my text editor was set to automatically trim trailing whitespace. I can back that out if you need me to. I await your feedback. Thanks!

geiseri avatar Apr 20 '20 16:04 geiseri

I tried building this branch with c++17 and NO_BOOST_SERIALIZATION defined, but I am getting build errors:

g++ -std=c++17 -DNO_BOOST_SERIALIZATION -Wall -O2 -MMD -MP -ggdb -pthread -I../ -Iext    -c -o typed-example.o typed-example.cc
In file included from typed-example.cc:1:
lmdb-typed.hh: In instantiation of ‘std::pair<lmdb_safe::TypedDBI<T, I1, I2, I3, I4>::ReadonlyOperations<Parent>::iter_t, lmdb_safe::TypedDBI<T, I1, I2, I3, I4>::ReadonlyOperations<Parent>::eiter_t> lmdb_safe::TypedDBI<T, I1, I2, I3, I4>::ReadonlyOperations<Parent>::equal_range(const typename std::tuple_element<N, std::tuple<I1, I2, I3, I4> >::type::type&) [with int N = 0; Parent = lmdb_safe::TypedDBI<DNSResourceRecord, lmdb_safe::index_on<DNSResourceRecord, std::__cxx11::basic_string<char>, &DNSResourceRecord::qname>, lmdb_safe::index_on<DNSResourceRecord, unsigned int, &DNSResourceRecord::domain_id>, lmdb_safe::index_on_function<DNSResourceRecord, std::__cxx11::basic_string<char>, compound> >::ROTransaction; T = DNSResourceRecord; I1 = lmdb_safe::index_on<DNSResourceRecord, std::__cxx11::basic_string<char>, &DNSResourceRecord::qname>; I2 = lmdb_safe::index_on<DNSResourceRecord, unsigned int, &DNSResourceRecord::domain_id>; I3 = lmdb_safe::index_on_function<DNSResourceRecord, std::__cxx11::basic_string<char>, compound>; I4 = lmdb_safe::nullindex_t; typename std::tuple_element<N, std::tuple<I1, I2, I3, I4> >::type::type = std::__cxx11::basic_string<char>]’:
typed-example.cc:79:53:   required from here
lmdb-typed.hh:537:36: error: call of overloaded ‘keyConv(const type&)’ is ambiguous
  537 |       std::string keyString=keyConv(key);
      |                             ~~~~~~~^~~~~
lmdb-typed.hh:83:13: note: candidate: ‘std::string lmdb_safe::keyConv(const T&) [with T = std::__cxx11::basic_string<char>; std::string = std::__cxx11::basic_string<char>]’
   83 | std::string keyConv(const T& t)
      |             ^~~~~~~
lmdb-typed.hh:96:13: note: candidate: ‘std::string lmdb_safe::keyConv(const T&) [with T = std::__cxx11::basic_string<char>; typename std::enable_if<is_convertible_v<T, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, int>::type <anonymous> = 0; std::string = std::__cxx11::basic_string<char>]’
   96 | std::string keyConv(const T& t)

CharlesJQuarra avatar Feb 24 '23 15:02 CharlesJQuarra

I've created my own fork at some point because this repo is not maintained at all anymore. The "custom" branch on that fork builds for me on recent C++ versions so you might want to give it a try.

I've also moved Boost.Serialization into its own header (as I'm using a different library). So this shouldn't get in the way anymore as well.

Martchus avatar Feb 24 '23 15:02 Martchus