diff options
author | Chris Mumford <cmumford@google.com> | 2019-05-02 11:01:00 -0700 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2019-05-02 19:04:50 -0700 |
commit | 297e66afc1dda3f3d7a7cc2022030164c302cb7a (patch) | |
tree | c7266d464e3b361a8f580ebe1e67c128e7e2a712 /include/leveldb | |
parent | 3724030179716fd8d95cf79339884c49afade8f9 (diff) | |
download | leveldb-297e66afc1dda3f3d7a7cc2022030164c302cb7a.tar.gz |
Format all files IAW the Google C++ Style Guide.
Use clang-format to correct formatting to be in agreement with the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). Doing this simplifies the process of accepting changes. Also fixed a few warnings flagged by clang-tidy.
PiperOrigin-RevId: 246350737
Diffstat (limited to 'include/leveldb')
-rw-r--r-- | include/leveldb/c.h | 42 | ||||
-rw-r--r-- | include/leveldb/cache.h | 3 | ||||
-rw-r--r-- | include/leveldb/comparator.h | 6 | ||||
-rw-r--r-- | include/leveldb/db.h | 19 | ||||
-rw-r--r-- | include/leveldb/dumpfile.h | 1 | ||||
-rw-r--r-- | include/leveldb/env.h | 18 | ||||
-rw-r--r-- | include/leveldb/filter_policy.h | 5 | ||||
-rw-r--r-- | include/leveldb/iterator.h | 5 | ||||
-rw-r--r-- | include/leveldb/options.h | 3 | ||||
-rw-r--r-- | include/leveldb/slice.h | 29 | ||||
-rw-r--r-- | include/leveldb/status.h | 3 | ||||
-rw-r--r-- | include/leveldb/table.h | 15 | ||||
-rw-r--r-- | include/leveldb/table_builder.h | 1 | ||||
-rw-r--r-- | include/leveldb/write_batch.h | 3 |
14 files changed, 79 insertions, 74 deletions
diff --git a/include/leveldb/c.h b/include/leveldb/c.h index d8aab5b..8e0d592 100644 --- a/include/leveldb/c.h +++ b/include/leveldb/c.h @@ -47,26 +47,27 @@ extern "C" { #include <stdarg.h> #include <stddef.h> #include <stdint.h> + #include "leveldb/export.h" /* Exported types */ -typedef struct leveldb_t leveldb_t; -typedef struct leveldb_cache_t leveldb_cache_t; -typedef struct leveldb_comparator_t leveldb_comparator_t; -typedef struct leveldb_env_t leveldb_env_t; -typedef struct leveldb_filelock_t leveldb_filelock_t; -typedef struct leveldb_filterpolicy_t leveldb_filterpolicy_t; -typedef struct leveldb_iterator_t leveldb_iterator_t; -typedef struct leveldb_logger_t leveldb_logger_t; -typedef struct leveldb_options_t leveldb_options_t; -typedef struct leveldb_randomfile_t leveldb_randomfile_t; -typedef struct leveldb_readoptions_t leveldb_readoptions_t; -typedef struct leveldb_seqfile_t leveldb_seqfile_t; -typedef struct leveldb_snapshot_t leveldb_snapshot_t; -typedef struct leveldb_writablefile_t leveldb_writablefile_t; -typedef struct leveldb_writebatch_t leveldb_writebatch_t; -typedef struct leveldb_writeoptions_t leveldb_writeoptions_t; +typedef struct leveldb_t leveldb_t; +typedef struct leveldb_cache_t leveldb_cache_t; +typedef struct leveldb_comparator_t leveldb_comparator_t; +typedef struct leveldb_env_t leveldb_env_t; +typedef struct leveldb_filelock_t leveldb_filelock_t; +typedef struct leveldb_filterpolicy_t leveldb_filterpolicy_t; +typedef struct leveldb_iterator_t leveldb_iterator_t; +typedef struct leveldb_logger_t leveldb_logger_t; +typedef struct leveldb_options_t leveldb_options_t; +typedef struct leveldb_randomfile_t leveldb_randomfile_t; +typedef struct leveldb_readoptions_t leveldb_readoptions_t; +typedef struct leveldb_seqfile_t leveldb_seqfile_t; +typedef struct leveldb_snapshot_t leveldb_snapshot_t; +typedef struct leveldb_writablefile_t leveldb_writablefile_t; +typedef struct leveldb_writebatch_t leveldb_writebatch_t; +typedef struct leveldb_writeoptions_t leveldb_writeoptions_t; /* DB operations */ @@ -189,10 +190,7 @@ LEVELDB_EXPORT void leveldb_options_set_block_restart_interval( LEVELDB_EXPORT void leveldb_options_set_max_file_size(leveldb_options_t*, size_t); -enum { - leveldb_no_compression = 0, - leveldb_snappy_compression = 1 -}; +enum { leveldb_no_compression = 0, leveldb_snappy_compression = 1 }; LEVELDB_EXPORT void leveldb_options_set_compression(leveldb_options_t*, int); /* Comparator */ @@ -266,7 +264,7 @@ LEVELDB_EXPORT int leveldb_major_version(); LEVELDB_EXPORT int leveldb_minor_version(); #ifdef __cplusplus -} /* end extern "C" */ +} /* end extern "C" */ #endif -#endif /* STORAGE_LEVELDB_INCLUDE_C_H_ */ +#endif /* STORAGE_LEVELDB_INCLUDE_C_H_ */ diff --git a/include/leveldb/cache.h b/include/leveldb/cache.h index e416ea5..7d1a221 100644 --- a/include/leveldb/cache.h +++ b/include/leveldb/cache.h @@ -19,6 +19,7 @@ #define STORAGE_LEVELDB_INCLUDE_CACHE_H_ #include <stdint.h> + #include "leveldb/export.h" #include "leveldb/slice.h" @@ -42,7 +43,7 @@ class LEVELDB_EXPORT Cache { virtual ~Cache(); // Opaque handle to an entry stored in the cache. - struct Handle { }; + struct Handle {}; // Insert a mapping from key->value into the cache and assign it // the specified charge against the total cache capacity. diff --git a/include/leveldb/comparator.h b/include/leveldb/comparator.h index 9b09684..a85b51e 100644 --- a/include/leveldb/comparator.h +++ b/include/leveldb/comparator.h @@ -6,6 +6,7 @@ #define STORAGE_LEVELDB_INCLUDE_COMPARATOR_H_ #include <string> + #include "leveldb/export.h" namespace leveldb { @@ -44,9 +45,8 @@ class LEVELDB_EXPORT Comparator { // If *start < limit, changes *start to a short string in [start,limit). // Simple comparator implementations may return with *start unchanged, // i.e., an implementation of this method that does nothing is correct. - virtual void FindShortestSeparator( - std::string* start, - const Slice& limit) const = 0; + virtual void FindShortestSeparator(std::string* start, + const Slice& limit) const = 0; // Changes *key to a short string >= *key. // Simple comparator implementations may return with *key unchanged, diff --git a/include/leveldb/db.h b/include/leveldb/db.h index 0239593..0b8dc24 100644 --- a/include/leveldb/db.h +++ b/include/leveldb/db.h @@ -7,6 +7,7 @@ #include <stdint.h> #include <stdio.h> + #include "leveldb/export.h" #include "leveldb/iterator.h" #include "leveldb/options.h" @@ -32,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 + 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) { } + Range() {} + Range(const Slice& s, const Slice& l) : start(s), limit(l) {} }; // A DB is a persistent ordered map from keys to values. @@ -49,8 +50,7 @@ class LEVELDB_EXPORT DB { // OK on success. // Stores nullptr in *dbptr and returns a non-OK status on error. // Caller should delete *dbptr when it is no longer needed. - static Status Open(const Options& options, - const std::string& name, + static Status Open(const Options& options, const std::string& name, DB** dbptr); DB() = default; @@ -63,8 +63,7 @@ class LEVELDB_EXPORT DB { // Set the database entry for "key" to "value". Returns OK on success, // and a non-OK status on error. // Note: consider setting options.sync = true. - virtual Status Put(const WriteOptions& options, - const Slice& key, + virtual Status Put(const WriteOptions& options, const Slice& key, const Slice& value) = 0; // Remove the database entry (if any) for "key". Returns OK on @@ -85,8 +84,8 @@ class LEVELDB_EXPORT DB { // a status for which Status::IsNotFound() returns true. // // May return some other Status on an error. - virtual Status Get(const ReadOptions& options, - const Slice& key, std::string* value) = 0; + virtual Status Get(const ReadOptions& options, const Slice& key, + std::string* value) = 0; // Return a heap-allocated iterator over the contents of the database. // The result of NewIterator() is initially invalid (caller must diff --git a/include/leveldb/dumpfile.h b/include/leveldb/dumpfile.h index 6597741..a58bc6b 100644 --- a/include/leveldb/dumpfile.h +++ b/include/leveldb/dumpfile.h @@ -6,6 +6,7 @@ #define STORAGE_LEVELDB_INCLUDE_DUMPFILE_H_ #include <string> + #include "leveldb/env.h" #include "leveldb/export.h" #include "leveldb/status.h" diff --git a/include/leveldb/env.h b/include/leveldb/env.h index ea728c9..112fe96 100644 --- a/include/leveldb/env.h +++ b/include/leveldb/env.h @@ -15,8 +15,10 @@ #include <stdarg.h> #include <stdint.h> + #include <string> #include <vector> + #include "leveldb/export.h" #include "leveldb/status.h" @@ -164,9 +166,7 @@ class LEVELDB_EXPORT Env { // added to the same Env may run concurrently in different threads. // I.e., the caller may not assume that background work items are // serialized. - virtual void Schedule( - void (*function)(void* arg), - void* arg) = 0; + virtual void Schedule(void (*function)(void* arg), void* arg) = 0; // Start a new thread, invoking "function(arg)" within the new thread. // When "function(arg)" returns, the thread will be destroyed. @@ -287,9 +287,9 @@ class LEVELDB_EXPORT FileLock { // Log the specified data to *info_log if info_log is non-null. void Log(Logger* info_log, const char* format, ...) -# if defined(__GNUC__) || defined(__clang__) - __attribute__((__format__ (__printf__, 2, 3))) -# endif +#if defined(__GNUC__) || defined(__clang__) + __attribute__((__format__(__printf__, 2, 3))) +#endif ; // A utility routine: write "data" to the named file. @@ -306,7 +306,7 @@ LEVELDB_EXPORT Status ReadFileToString(Env* env, const std::string& fname, class LEVELDB_EXPORT EnvWrapper : public Env { public: // Initialize an EnvWrapper that delegates all calls to *t. - explicit EnvWrapper(Env* t) : target_(t) { } + explicit EnvWrapper(Env* t) : target_(t) {} virtual ~EnvWrapper(); // Return the target to which this Env forwards all calls. @@ -364,9 +364,7 @@ class LEVELDB_EXPORT EnvWrapper : public Env { Status NewLogger(const std::string& fname, Logger** result) override { return target_->NewLogger(fname, result); } - uint64_t NowMicros() override { - return target_->NowMicros(); - } + uint64_t NowMicros() override { return target_->NowMicros(); } void SleepForMicroseconds(int micros) override { target_->SleepForMicroseconds(micros); } diff --git a/include/leveldb/filter_policy.h b/include/leveldb/filter_policy.h index ba02720..49c8eda 100644 --- a/include/leveldb/filter_policy.h +++ b/include/leveldb/filter_policy.h @@ -17,6 +17,7 @@ #define STORAGE_LEVELDB_INCLUDE_FILTER_POLICY_H_ #include <string> + #include "leveldb/export.h" namespace leveldb { @@ -39,8 +40,8 @@ class LEVELDB_EXPORT FilterPolicy { // // Warning: do not change the initial contents of *dst. Instead, // append the newly constructed filter to *dst. - virtual void CreateFilter(const Slice* keys, int n, std::string* dst) - const = 0; + virtual void CreateFilter(const Slice* keys, int n, + std::string* dst) const = 0; // "filter" contains the data appended by a preceding call to // CreateFilter() on this class. This method must return true if diff --git a/include/leveldb/iterator.h b/include/leveldb/iterator.h index 6c1d91b..447e950 100644 --- a/include/leveldb/iterator.h +++ b/include/leveldb/iterator.h @@ -93,7 +93,10 @@ class LEVELDB_EXPORT Iterator { // True if the node is not used. Only head nodes might be unused. bool IsEmpty() const { return function == nullptr; } // Invokes the cleanup function. - void Run() { assert(function != nullptr); (*function)(arg1, arg2); } + void Run() { + assert(function != nullptr); + (*function)(arg1, arg2); + } }; CleanupNode cleanup_head_; }; diff --git a/include/leveldb/options.h b/include/leveldb/options.h index 90aa19e..7e26dc6 100644 --- a/include/leveldb/options.h +++ b/include/leveldb/options.h @@ -6,6 +6,7 @@ #define STORAGE_LEVELDB_INCLUDE_OPTIONS_H_ #include <stddef.h> + #include "leveldb/export.h" namespace leveldb { @@ -24,7 +25,7 @@ class Snapshot; enum CompressionType { // NOTE: do not change the values of existing entries, as these are // part of the persistent format on disk. - kNoCompression = 0x0, + kNoCompression = 0x0, kSnappyCompression = 0x1 }; diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h index a86e8a6..2df417d 100644 --- a/include/leveldb/slice.h +++ b/include/leveldb/slice.h @@ -18,7 +18,9 @@ #include <assert.h> #include <stddef.h> #include <string.h> + #include <string> + #include "leveldb/export.h" namespace leveldb { @@ -26,16 +28,16 @@ namespace leveldb { class LEVELDB_EXPORT Slice { public: // Create an empty slice. - Slice() : data_(""), size_(0) { } + Slice() : data_(""), size_(0) {} // Create a slice that refers to d[0,n-1]. - Slice(const char* d, size_t n) : data_(d), size_(n) { } + Slice(const char* d, size_t n) : data_(d), size_(n) {} // Create a slice that refers to the contents of "s" - Slice(const std::string& s) : data_(s.data()), size_(s.size()) { } + Slice(const std::string& s) : data_(s.data()), size_(s.size()) {} // Create a slice that refers to s[0,strlen(s)-1] - Slice(const char* s) : data_(s), size_(strlen(s)) { } + Slice(const char* s) : data_(s), size_(strlen(s)) {} // Intentionally copyable. Slice(const Slice&) = default; @@ -58,7 +60,10 @@ class LEVELDB_EXPORT Slice { } // Change this slice to refer to an empty array - void clear() { data_ = ""; size_ = 0; } + void clear() { + data_ = ""; + size_ = 0; + } // Drop the first "n" bytes from this slice. void remove_prefix(size_t n) { @@ -78,8 +83,7 @@ class LEVELDB_EXPORT Slice { // Return true iff "x" is a prefix of "*this" bool starts_with(const Slice& x) const { - return ((size_ >= x.size_) && - (memcmp(data_, x.data_, x.size_) == 0)); + return ((size_ >= x.size_) && (memcmp(data_, x.data_, x.size_) == 0)); } private: @@ -92,21 +96,20 @@ inline bool operator==(const Slice& x, const Slice& y) { (memcmp(x.data(), y.data(), x.size()) == 0)); } -inline bool operator!=(const Slice& x, const Slice& y) { - return !(x == y); -} +inline bool operator!=(const Slice& x, const Slice& y) { return !(x == y); } inline int Slice::compare(const Slice& b) const { const size_t min_len = (size_ < b.size_) ? size_ : b.size_; int r = memcmp(data_, b.data_, min_len); if (r == 0) { - if (size_ < b.size_) r = -1; - else if (size_ > b.size_) r = +1; + if (size_ < b.size_) + r = -1; + else if (size_ > b.size_) + r = +1; } return r; } } // namespace leveldb - #endif // STORAGE_LEVELDB_INCLUDE_SLICE_H_ diff --git a/include/leveldb/status.h b/include/leveldb/status.h index ee9fac2..54cf377 100644 --- a/include/leveldb/status.h +++ b/include/leveldb/status.h @@ -15,6 +15,7 @@ #include <algorithm> #include <string> + #include "leveldb/export.h" #include "leveldb/slice.h" @@ -23,7 +24,7 @@ namespace leveldb { class LEVELDB_EXPORT Status { public: // Create a success status. - Status() noexcept : state_(nullptr) { } + Status() noexcept : state_(nullptr) {} ~Status() { delete[] state_; } Status(const Status& rhs); diff --git a/include/leveldb/table.h b/include/leveldb/table.h index e9f6641..14a6a44 100644 --- a/include/leveldb/table.h +++ b/include/leveldb/table.h @@ -6,6 +6,7 @@ #define STORAGE_LEVELDB_INCLUDE_TABLE_H_ #include <stdint.h> + #include "leveldb/export.h" #include "leveldb/iterator.h" @@ -36,10 +37,8 @@ class LEVELDB_EXPORT Table { // for the duration of the returned table's lifetime. // // *file must remain live while this Table is in use. - static Status Open(const Options& options, - RandomAccessFile* file, - uint64_t file_size, - Table** table); + static Status Open(const Options& options, RandomAccessFile* file, + uint64_t file_size, Table** table); Table(const Table&) = delete; void operator=(const Table&) = delete; @@ -70,11 +69,9 @@ class LEVELDB_EXPORT Table { // 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)); - + 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); diff --git a/include/leveldb/table_builder.h b/include/leveldb/table_builder.h index 8d05d33..f8361fd 100644 --- a/include/leveldb/table_builder.h +++ b/include/leveldb/table_builder.h @@ -14,6 +14,7 @@ #define STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_ #include <stdint.h> + #include "leveldb/export.h" #include "leveldb/options.h" #include "leveldb/status.h" diff --git a/include/leveldb/write_batch.h b/include/leveldb/write_batch.h index 5380c53..21f7c63 100644 --- a/include/leveldb/write_batch.h +++ b/include/leveldb/write_batch.h @@ -22,6 +22,7 @@ #define STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_ #include <string> + #include "leveldb/export.h" #include "leveldb/status.h" @@ -35,7 +36,7 @@ class LEVELDB_EXPORT WriteBatch { // Intentionally copyable. WriteBatch(const WriteBatch&) = default; - WriteBatch& operator =(const WriteBatch&) = default; + WriteBatch& operator=(const WriteBatch&) = default; ~WriteBatch(); |