diff options
author | Chris Mumford <cmumford@google.com> | 2019-05-03 09:31:18 -0700 |
---|---|---|
committer | Chris Mumford <cmumford@google.com> | 2019-05-03 09:48:57 -0700 |
commit | 9bd23c767601a2420478eec158927882b879bada (patch) | |
tree | 1b40c3712c8d882bab5d339a572e56527c145b56 /include | |
parent | c784d63b931d07895833fb80185b10d44ad63cce (diff) | |
download | leveldb-9bd23c767601a2420478eec158927882b879bada.tar.gz |
Correct class/structure declaration order.
1. Correct the class/struct declaration order to be IAW
the Google C++ style guide[1].
2. For non-copyable classes, switched from non-implemented
private methods to explicitly deleted[2] methods.
3. Minor const and member initialization fixes.
[1] https://google.github.io/styleguide/cppguide.html#Declaration_Order
[2] http://eel.is/c++draft/dcl.fct.def.delete
PiperOrigin-RevId: 246521844
Diffstat (limited to 'include')
-rw-r--r-- | include/leveldb/db.h | 6 | ||||
-rw-r--r-- | include/leveldb/iterator.h | 12 | ||||
-rw-r--r-- | include/leveldb/options.h | 14 | ||||
-rw-r--r-- | include/leveldb/status.h | 14 | ||||
-rw-r--r-- | include/leveldb/table.h | 10 | ||||
-rw-r--r-- | include/leveldb/table_builder.h | 2 | ||||
-rw-r--r-- | include/leveldb/write_batch.h | 13 |
7 files changed, 37 insertions, 34 deletions
diff --git a/include/leveldb/db.h b/include/leveldb/db.h index 0b8dc24..e52a5b6 100644 --- a/include/leveldb/db.h +++ b/include/leveldb/db.h @@ -33,11 +33,11 @@ class LEVELDB_EXPORT Snapshot { // A range of keys struct LEVELDB_EXPORT Range { - Slice start; // Included in the range - Slice limit; // Not included in the range - Range() {} Range(const Slice& s, const Slice& l) : start(s), limit(l) {} + + Slice start; // Included in the range + Slice limit; // Not included in the range }; // A DB is a persistent ordered map from keys to values. diff --git a/include/leveldb/iterator.h b/include/leveldb/iterator.h index 447e950..bb9a5df 100644 --- a/include/leveldb/iterator.h +++ b/include/leveldb/iterator.h @@ -84,12 +84,6 @@ class LEVELDB_EXPORT Iterator { // Cleanup functions are stored in a single-linked list. // The list's head node is inlined in the iterator. struct CleanupNode { - // The head node is used if the function pointer is not null. - CleanupFunction function; - void* arg1; - void* arg2; - CleanupNode* next; - // True if the node is not used. Only head nodes might be unused. bool IsEmpty() const { return function == nullptr; } // Invokes the cleanup function. @@ -97,6 +91,12 @@ class LEVELDB_EXPORT Iterator { assert(function != nullptr); (*function)(arg1, arg2); } + + // The head node is used if the function pointer is not null. + CleanupFunction function; + void* arg1; + void* arg2; + CleanupNode* next; }; CleanupNode cleanup_head_; }; diff --git a/include/leveldb/options.h b/include/leveldb/options.h index 7e26dc6..b748772 100644 --- a/include/leveldb/options.h +++ b/include/leveldb/options.h @@ -31,6 +31,9 @@ enum CompressionType { // Options to control the behavior of a database (passed to DB::Open) struct LEVELDB_EXPORT Options { + // Create an Options object with default values for all fields. + Options(); + // ------------------- // Parameters that affect behavior @@ -137,13 +140,12 @@ struct LEVELDB_EXPORT Options { // Many applications will benefit from passing the result of // NewBloomFilterPolicy() here. const FilterPolicy* filter_policy = nullptr; - - // Create an Options object with default values for all fields. - Options(); }; // Options that control read operations struct LEVELDB_EXPORT ReadOptions { + ReadOptions() = default; + // If true, all data read from underlying storage will be // verified against corresponding checksums. bool verify_checksums = false; @@ -157,12 +159,12 @@ struct LEVELDB_EXPORT ReadOptions { // not have been released). If "snapshot" is null, use an implicit // snapshot of the state at the beginning of this read operation. const Snapshot* snapshot = nullptr; - - ReadOptions() = default; }; // Options that control write operations struct LEVELDB_EXPORT WriteOptions { + WriteOptions() = default; + // If true, the write will be flushed from the operating system // buffer cache (by calling WritableFile::Sync()) before the write // is considered complete. If this flag is true, writes will be @@ -178,8 +180,6 @@ struct LEVELDB_EXPORT WriteOptions { // with sync==true has similar crash semantics to a "write()" // system call followed by "fsync()". bool sync = false; - - WriteOptions() = default; }; } // namespace leveldb diff --git a/include/leveldb/status.h b/include/leveldb/status.h index 54cf377..e327314 100644 --- a/include/leveldb/status.h +++ b/include/leveldb/status.h @@ -76,13 +76,6 @@ class LEVELDB_EXPORT Status { std::string ToString() const; private: - // OK status has a null state_. Otherwise, state_ is a new[] array - // of the following form: - // state_[0..3] == length of message - // state_[4] == code - // state_[5..] == message - const char* state_; - enum Code { kOk = 0, kNotFound = 1, @@ -98,6 +91,13 @@ class LEVELDB_EXPORT Status { Status(Code code, const Slice& msg, const Slice& msg2); static const char* CopyState(const char* s); + + // OK status has a null state_. Otherwise, state_ is a new[] array + // of the following form: + // state_[0..3] == length of message + // state_[4] == code + // state_[5..] == message + const char* state_; }; inline Status::Status(const Status& rhs) { diff --git a/include/leveldb/table.h b/include/leveldb/table.h index 14a6a44..25c6013 100644 --- a/include/leveldb/table.h +++ b/include/leveldb/table.h @@ -41,7 +41,7 @@ class LEVELDB_EXPORT Table { uint64_t file_size, Table** table); Table(const Table&) = delete; - void operator=(const Table&) = delete; + Table& operator=(const Table&) = delete; ~Table(); @@ -59,22 +59,24 @@ class LEVELDB_EXPORT Table { uint64_t ApproximateOffsetOf(const Slice& key) const; private: + friend class TableCache; struct Rep; - Rep* rep_; - explicit Table(Rep* rep) { rep_ = rep; } static Iterator* BlockReader(void*, const ReadOptions&, const Slice&); + explicit Table(Rep* rep) : rep_(rep) {} + // Calls (*handle_result)(arg, ...) with the entry found after a call // to Seek(key). May not make such a call if filter policy says // that key is not present. - friend class TableCache; Status InternalGet(const ReadOptions&, const Slice& key, void* arg, void (*handle_result)(void* arg, const Slice& k, const Slice& v)); void ReadMeta(const Footer& footer); void ReadFilter(const Slice& filter_handle_value); + + Rep* const rep_; }; } // namespace leveldb diff --git a/include/leveldb/table_builder.h b/include/leveldb/table_builder.h index f8361fd..7d8896b 100644 --- a/include/leveldb/table_builder.h +++ b/include/leveldb/table_builder.h @@ -33,7 +33,7 @@ class LEVELDB_EXPORT TableBuilder { TableBuilder(const Options& options, WritableFile* file); TableBuilder(const TableBuilder&) = delete; - void operator=(const TableBuilder&) = delete; + TableBuilder& operator=(const TableBuilder&) = delete; // REQUIRES: Either Finish() or Abandon() has been called. ~TableBuilder(); diff --git a/include/leveldb/write_batch.h b/include/leveldb/write_batch.h index 21f7c63..94d4115 100644 --- a/include/leveldb/write_batch.h +++ b/include/leveldb/write_batch.h @@ -32,6 +32,13 @@ class Slice; class LEVELDB_EXPORT WriteBatch { public: + class LEVELDB_EXPORT Handler { + public: + virtual ~Handler(); + virtual void Put(const Slice& key, const Slice& value) = 0; + virtual void Delete(const Slice& key) = 0; + }; + WriteBatch(); // Intentionally copyable. @@ -63,12 +70,6 @@ class LEVELDB_EXPORT WriteBatch { void Append(const WriteBatch& source); // Support for iterating over the contents of a batch. - class LEVELDB_EXPORT Handler { - public: - virtual ~Handler(); - virtual void Put(const Slice& key, const Slice& value) = 0; - virtual void Delete(const Slice& key) = 0; - }; Status Iterate(Handler* handler) const; private: |