1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 2 // This source code is licensed under both the GPLv2 (found in the 3 // COPYING file in the root directory) and Apache 2.0 License 4 // (found in the LICENSE.Apache file in the root directory). 5 #pragma once 6 #ifndef ROCKSDB_LITE 7 #include <string> 8 #include <vector> 9 #include "rocksdb/db.h" 10 #include "rocksdb/options.h" 11 12 namespace ROCKSDB_NAMESPACE { 13 14 // An interface for converting a slice to a readable string 15 class SliceFormatter { 16 public: ~SliceFormatter()17 virtual ~SliceFormatter() {} 18 virtual std::string Format(const Slice& s) const = 0; 19 }; 20 21 // Options for customizing ldb tool (beyond the DB Options) 22 struct LDBOptions { 23 // Create LDBOptions with default values for all fields 24 LDBOptions(); 25 26 // Key formatter that converts a slice to a readable string. 27 // Default: Slice::ToString() 28 std::shared_ptr<SliceFormatter> key_formatter; 29 30 std::string print_help_header = "ldb - RocksDB Tool"; 31 }; 32 33 class LDBTool { 34 public: 35 void Run( 36 int argc, char** argv, Options db_options = Options(), 37 const LDBOptions& ldb_options = LDBOptions(), 38 const std::vector<ColumnFamilyDescriptor>* column_families = nullptr); 39 }; 40 41 } // namespace ROCKSDB_NAMESPACE 42 43 #endif // ROCKSDB_LITE 44