diff options
author | Gil <mcg@google.com> | 2018-03-21 18:43:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-21 18:43:29 -0700 |
commit | cf630bfee60694f9bf1577972df169badda0b6e0 (patch) | |
tree | 2b815ec0e241666aa04da5e58e7c85ce23518e50 /Firestore/core/src/firebase/firestore/local/leveldb_util.h | |
parent | 5f49b2f3f9866e4db13d09857eb3b548239cc62e (diff) |
Port FSTLevelDBKey to C++ (#937)
Diffstat (limited to 'Firestore/core/src/firebase/firestore/local/leveldb_util.h')
-rw-r--r-- | Firestore/core/src/firebase/firestore/local/leveldb_util.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_util.h b/Firestore/core/src/firebase/firestore/local/leveldb_util.h new file mode 100644 index 0000000..5738d65 --- /dev/null +++ b/Firestore/core/src/firebase/firestore/local/leveldb_util.h @@ -0,0 +1,43 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_LOCAL_LEVELDB_UTIL_H_ +#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_LOCAL_LEVELDB_UTIL_H_ + +#include <string> + +#include "absl/strings/string_view.h" +#include "leveldb/slice.h" + +namespace firebase { +namespace firestore { +namespace local { + +/** Creates a Slice from a string_view. */ +inline leveldb::Slice MakeSlice(absl::string_view view) { + return leveldb::Slice{view.data(), view.size()}; +} + +/** Creates a string_view from a Slice. */ +inline absl::string_view MakeStringView(leveldb::Slice slice) { + return absl::string_view{slice.data(), slice.size()}; +} + +} // namespace local +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_LOCAL_LEVELDB_UTIL_H_ |