| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/leveldb/public/cpp/remote_iterator.h" |
| 6 |
| 7 #include "components/leveldb/public/cpp/util.h" |
| 8 |
| 9 namespace leveldb { |
| 10 |
| 11 RemoteIterator::RemoteIterator(LevelDBDatabase* database, uint64_t iterator_id) |
| 12 : database_(database), |
| 13 iterator_id_(iterator_id), |
| 14 valid_(false), |
| 15 status_(DatabaseError::OK) {} |
| 16 |
| 17 RemoteIterator::~RemoteIterator() { |
| 18 database_->ReleaseIterator(iterator_id_); |
| 19 } |
| 20 |
| 21 bool RemoteIterator::Valid() const { |
| 22 return valid_; |
| 23 } |
| 24 |
| 25 void RemoteIterator::SeekToFirst() { |
| 26 database_->IteratorSeekToFirst(iterator_id_, &valid_, &status_, &key_, |
| 27 &value_); |
| 28 } |
| 29 |
| 30 void RemoteIterator::SeekToLast() { |
| 31 database_->IteratorSeekToLast(iterator_id_, &valid_, &status_, &key_, |
| 32 &value_); |
| 33 } |
| 34 |
| 35 void RemoteIterator::Seek(const Slice& target) { |
| 36 database_->IteratorSeek(iterator_id_, GetArrayFor(target), &valid_, &status_, |
| 37 &key_, &value_); |
| 38 } |
| 39 |
| 40 void RemoteIterator::Next() { |
| 41 database_->IteratorNext(iterator_id_, &valid_, &status_, &key_, &value_); |
| 42 } |
| 43 |
| 44 void RemoteIterator::Prev() { |
| 45 database_->IteratorPrev(iterator_id_, &valid_, &status_, &key_, &value_); |
| 46 } |
| 47 |
| 48 Slice RemoteIterator::key() const { |
| 49 return GetSliceFor(key_); |
| 50 } |
| 51 |
| 52 Slice RemoteIterator::value() const { |
| 53 return GetSliceFor(value_); |
| 54 } |
| 55 |
| 56 Status RemoteIterator::status() const { |
| 57 return DatabaseErrorToStatus(status_, GetSliceFor(key_), GetSliceFor(value_)); |
| 58 } |
| 59 |
| 60 } // namespace leveldb |
| OLD | NEW |