Feathercoin
0.5.0
P2P Digital Currency
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
src
leveldb
table
iterator.cc
Go to the documentation of this file.
1
// Copyright (c) 2011 The LevelDB 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. See the AUTHORS file for names of contributors.
4
5
#include "
leveldb/iterator.h
"
6
7
namespace
leveldb
{
8
9
Iterator::Iterator
() {
10
cleanup_
.
function
= NULL;
11
cleanup_
.
next
= NULL;
12
}
13
14
Iterator::~Iterator
() {
15
if
(
cleanup_
.
function
!= NULL) {
16
(*
cleanup_
.
function
)(
cleanup_
.
arg1
,
cleanup_
.
arg2
);
17
for
(
Cleanup
* c =
cleanup_
.
next
; c != NULL; ) {
18
(*c->function)(c->arg1, c->arg2);
19
Cleanup
*
next
= c->next;
20
delete
c;
21
c =
next
;
22
}
23
}
24
}
25
26
void
Iterator::RegisterCleanup
(CleanupFunction
func
,
void
* arg1,
void
* arg2) {
27
assert(func != NULL);
28
Cleanup
* c;
29
if
(
cleanup_
.
function
== NULL) {
30
c = &
cleanup_
;
31
}
else
{
32
c =
new
Cleanup
;
33
c->
next
=
cleanup_
.
next
;
34
cleanup_
.
next
= c;
35
}
36
c->
function
=
func
;
37
c->
arg1
= arg1;
38
c->
arg2
= arg2;
39
}
40
41
namespace
{
42
class
EmptyIterator :
public
Iterator
{
43
public
:
44
EmptyIterator(
const
Status
& s) :
status_
(s) { }
45
virtual
bool
Valid()
const
{
return
false
; }
46
virtual
void
Seek(
const
Slice& target) { }
47
virtual
void
SeekToFirst() { }
48
virtual
void
SeekToLast() { }
49
virtual
void
Next() { assert(
false
); }
50
virtual
void
Prev() { assert(
false
); }
51
Slice key()
const
{ assert(
false
);
return
Slice(); }
52
Slice
value
()
const
{ assert(
false
);
return
Slice(); }
53
virtual
Status status()
const
{
return
status_
; }
54
private
:
55
Status
status_
;
56
};
57
}
// namespace
58
59
Iterator
*
NewEmptyIterator
() {
60
return
new
EmptyIterator(
Status::OK
());
61
}
62
63
Iterator
*
NewErrorIterator
(
const
Status
& status) {
64
return
new
EmptyIterator(status);
65
}
66
67
}
// namespace leveldb
leveldb
Definition:
builder.cc:15
value
std::string * value
Definition:
version_set.cc:270
leveldb::Status
Definition:
status.h:21
leveldb::Iterator::Iterator
Iterator()
Definition:
iterator.cc:9
status_
Status status_
Definition:
iterator.cc:55
leveldb::Status::OK
static Status OK()
Definition:
status.h:32
next
LRUHandle * next
Definition:
cache.cc:29
leveldb::NewErrorIterator
Iterator * NewErrorIterator(const Status &status)
Definition:
iterator.cc:63
leveldb::Iterator::~Iterator
virtual ~Iterator()
Definition:
iterator.cc:14
leveldb::NewEmptyIterator
Iterator * NewEmptyIterator()
Definition:
iterator.cc:59
leveldb::Iterator::RegisterCleanup
void RegisterCleanup(CleanupFunction function, void *arg1, void *arg2)
Definition:
iterator.cc:26
leveldb::Iterator::Cleanup
Definition:
iterator.h:79
func
void(* func)()
Definition:
testharness.cc:19
leveldb::Iterator::cleanup_
Cleanup cleanup_
Definition:
iterator.h:85
leveldb::Iterator
Definition:
iterator.h:23
leveldb::Iterator::Cleanup::next
Cleanup * next
Definition:
iterator.h:83
leveldb::Iterator::Cleanup::arg2
void * arg2
Definition:
iterator.h:82
iterator.h
leveldb::Iterator::Cleanup::function
CleanupFunction function
Definition:
iterator.h:80
leveldb::Iterator::Cleanup::arg1
void * arg1
Definition:
iterator.h:81
Generated on Thu Sep 11 2014 10:57:07 for Feathercoin by
1.8.8