leveldb
Public Member Functions | Private Attributes | List of all members
leveldb::Slice Class Reference

#include <slice.h>

Public Member Functions

 Slice ()
 
 Slice (const char *d, size_t n)
 
 Slice (const std::string &s)
 
 Slice (const char *s)
 
const char * data () const
 
size_t size () const
 
bool empty () const
 
char operator[] (size_t n) const
 
void clear ()
 
void remove_prefix (size_t n)
 
std::string ToString () const
 
int compare (const Slice &b) const
 
bool starts_with (const Slice &x) const
 

Private Attributes

const char * data_
 
size_t size_
 

Detailed Description

Definition at line 25 of file slice.h.

Constructor & Destructor Documentation

§ Slice() [1/4]

leveldb::Slice::Slice ( )
inline

Definition at line 28 of file slice.h.

28 : data_(""), size_(0) { }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81

§ Slice() [2/4]

leveldb::Slice::Slice ( const char *  d,
size_t  n 
)
inline

Definition at line 31 of file slice.h.

31 : data_(d), size_(n) { }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81

§ Slice() [3/4]

leveldb::Slice::Slice ( const std::string &  s)
inline

Definition at line 34 of file slice.h.

34 : data_(s.data()), size_(s.size()) { }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81

§ Slice() [4/4]

leveldb::Slice::Slice ( const char *  s)
inline

Definition at line 37 of file slice.h.

37 : data_(s), size_(strlen(s)) { }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81

Member Function Documentation

§ clear()

void leveldb::Slice::clear ( )
inline

Definition at line 56 of file slice.h.

56 { data_ = ""; size_ = 0; }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81
Here is the caller graph for this function:

§ compare()

int leveldb::Slice::compare ( const Slice b) const
inline

Definition at line 96 of file slice.h.

96  {
97  const size_t min_len = (size_ < b.size_) ? size_ : b.size_;
98  int r = memcmp(data_, b.data_, min_len);
99  if (r == 0) {
100  if (size_ < b.size_) r = -1;
101  else if (size_ > b.size_) r = +1;
102  }
103  return r;
104 }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81
Here is the caller graph for this function:

§ data()

const char* leveldb::Slice::data ( ) const
inline

Definition at line 40 of file slice.h.

40 { return data_; }
const char * data_
Definition: slice.h:81

§ empty()

bool leveldb::Slice::empty ( ) const
inline

Definition at line 46 of file slice.h.

46 { return size_ == 0; }
size_t size_
Definition: slice.h:82
Here is the caller graph for this function:

§ operator[]()

char leveldb::Slice::operator[] ( size_t  n) const
inline

Definition at line 50 of file slice.h.

50  {
51  assert(n < size());
52  return data_[n];
53  }
const char * data_
Definition: slice.h:81
size_t size() const
Definition: slice.h:43
Here is the call graph for this function:

§ remove_prefix()

void leveldb::Slice::remove_prefix ( size_t  n)
inline

Definition at line 59 of file slice.h.

59  {
60  assert(n <= size());
61  data_ += n;
62  size_ -= n;
63  }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81
size_t size() const
Definition: slice.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

§ size()

size_t leveldb::Slice::size ( ) const
inline

Definition at line 43 of file slice.h.

43 { return size_; }
size_t size_
Definition: slice.h:82

§ starts_with()

bool leveldb::Slice::starts_with ( const Slice x) const
inline

Definition at line 75 of file slice.h.

75  {
76  return ((size_ >= x.size_) &&
77  (memcmp(data_, x.data_, x.size_) == 0));
78  }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81
Here is the caller graph for this function:

§ ToString()

std::string leveldb::Slice::ToString ( ) const
inline

Definition at line 66 of file slice.h.

66 { return std::string(data_, size_); }
size_t size_
Definition: slice.h:82
const char * data_
Definition: slice.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

§ data_

const char* leveldb::Slice::data_
private

Definition at line 81 of file slice.h.

§ size_

size_t leveldb::Slice::size_
private

Definition at line 82 of file slice.h.


The documentation for this class was generated from the following file: