diff --git a/include/leveldb/db.h b/include/leveldb/db.h index a13d147..5b40018 100644 --- a/include/leveldb/db.h +++ b/include/leveldb/db.h @@ -66,6 +66,12 @@ class LEVELDB_EXPORT DB { virtual Status Put(const WriteOptions& options, const Slice& key, const Slice& value) = 0; + // Convenience wrapper + Status Put(const Slice& key, const Slice& value, + const WriteOptions& options = WriteOptions()) { + return Put(options, key, value); + }; + // Remove the database entry (if any) for "key". Returns OK on // success, and a non-OK status on error. It is not an error if "key" // did not exist in the database. diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h index 37cb821..e6f9657 100644 --- a/include/leveldb/slice.h +++ b/include/leveldb/slice.h @@ -35,6 +35,10 @@ class LEVELDB_EXPORT Slice { // Create a slice that refers to the contents of "s" Slice(const std::string& s) : data_(s.data()), size_(s.size()) {} + // For any object + template + Slice(const T& s) : data_(reinterpret_cast(&s)), size_(sizeof(T)) {} + // Create a slice that refers to s[0,strlen(s)-1] Slice(const char* s) : data_(s), size_(strlen(s)) {}