Kyoto Cabinet

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
kyotocabinet::DB::Cursor Class Reference

Interface of cursor to indicate a record. More...

`#include <kcdb.h>`

List of all members.

## Public Member Functions

virtual | ~Cursor ()
| Destructor.
virtual bool | accept (Visitor *visitor, bool writable=true, bool step=false)=0
| Accept a visitor to the current record.
virtual bool | set_value (const char *vbuf, size_t vsiz, bool step=false)=0
| Set the value of the current record.
virtual bool | set_value_str (const std::string &value, bool step=false)=0
| Set the value of the current record.
virtual bool | remove ()=0
| Remove the current record.
virtual char * | get_key (size_t *sp, bool step=false)=0
| Get the key of the current record.
virtual bool | get_key (std::string *key, bool step=false)=0
| Get the key of the current record.
virtual char * | get_value (size_t *sp, bool step=false)=0
| Get the value of the current record.
virtual bool | get_value (std::string *value, bool step=false)=0
| Get the value of the current record.
virtual char * | get (size_t *ksp, const char **vbp, size_t *vsp, bool step=false)=0
| Get a pair of the key and the value of the current record.
virtual bool | get (std::string *key, std::string *value, bool step=false)=0
| Get a pair of the key and the value of the current record.
virtual bool | jump ()=0
| Jump the cursor to the first record for forward scan.
virtual bool | jump (const char *kbuf, size_t ksiz)=0
| Jump the cursor to a record for forward scan.
virtual bool | jump (const std::string &key)=0
| Jump the cursor to a record for forward scan.
virtual bool | jump_back ()=0
| Jump the cursor to the last record for backward scan.
virtual bool | jump_back (const char *kbuf, size_t ksiz)=0
| Jump the cursor to a record for backward scan.
virtual bool | jump_back (const std::string &key)=0
| Jump the cursor to a record for backward scan.
virtual bool | step ()=0
| Step the cursor to the next record.
virtual bool | step_back ()=0
| Step the cursor to the previous record.
virtual DB * | db ()=0
| Get the database object.

## Detailed Description

Interface of cursor to indicate a record.

## Constructor & Destructor Documentation

virtual kyotocabinet::DB::Cursor::~Cursor | ( |  | ) | `[virtual]`

Destructor.

Reimplemented in kyotocabinet::BasicDB::Cursor, kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::PolyDB::Cursor, and kyotocabinet::TextDB::Cursor.

## Member Function Documentation

virtual bool kyotocabinet::DB::Cursor::accept | ( | Visitor * | visitor,
|  | bool | writable = `true`,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Accept a visitor to the current record.

Parameters:

  visitor | a visitor object.
  writable | true for writable operation, or false for read-only operation.
  step | true to move the cursor to the next record, or false for no move.

Returns:
  true on success, or false on failure.

Note:
  The operation for each record is performed atomically and other threads accessing the same record are blocked. To avoid deadlock, any explicit database operation must not be performed in this function.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::PolyDB::Cursor, and kyotocabinet::TextDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::set_value | ( | const char * | vbuf,
|  | size_t | vsiz,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Set the value of the current record.

Parameters:

  vbuf | the pointer to the value region.
  vsiz | the size of the value region.
  step | true to move the cursor to the next record, or false for no move.

Returns:
  true on success, or false on failure.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::set_value_str | ( | const std::string & | value,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Set the value of the current record.

Note:
  Equal to the original Cursor::set_value method except that the parameter is std::string.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::remove | ( |  | ) | `[pure virtual]`

Remove the current record.

Returns:
  true on success, or false on failure.

Note:
  If no record corresponds to the key, false is returned. The cursor is moved to the next record implicitly.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual char* kyotocabinet::DB::Cursor::get_key | ( | size_t * | sp,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Get the key of the current record.

Parameters:

  sp | the pointer to the variable into which the size of the region of the return value is assigned.
  step | true to move the cursor to the next record, or false for no move.

Returns:
  the pointer to the key region of the current record, or NULL on failure.

Note:
  If the cursor is invalidated, NULL is returned. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a C-style string. Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::get_key | ( | std::string * | key,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Get the key of the current record.

Note:
  Equal to the original Cursor::get_key method except that a parameter is a string to contain the result and the return value is bool for success.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual char* kyotocabinet::DB::Cursor::get_value | ( | size_t * | sp,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Get the value of the current record.

Parameters:

  sp | the pointer to the variable into which the size of the region of the return value is assigned.
  step | true to move the cursor to the next record, or false for no move.

Returns:
  the pointer to the value region of the current record, or NULL on failure.

Note:
  If the cursor is invalidated, NULL is returned. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a C-style string. Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::get_value | ( | std::string * | value,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Get the value of the current record.

Note:
  Equal to the original Cursor::get_value method except that a parameter is a string to contain the result and the return value is bool for success.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual char* kyotocabinet::DB::Cursor::get | ( | size_t * | ksp,
|  | const char ** | vbp,
|  | size_t * | vsp,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Get a pair of the key and the value of the current record.

Parameters:

  ksp | the pointer to the variable into which the size of the region of the return value is assigned.
  vbp | the pointer to the variable into which the pointer to the value region is assigned.
  vsp | the pointer to the variable into which the size of the value region is assigned.
  step | true to move the cursor to the next record, or false for no move.

Returns:
  the pointer to the key region, or NULL on failure.

Note:
  If the cursor is invalidated, NULL is returned. Because an additional zero code is appended at the end of each region of the key and the value, each region can be treated as a C-style string. The return value should be deleted explicitly by the caller with the detele[] operator.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::get | ( | std::string * | key,
|  | std::string * | value,
|  | bool | step = `false`
| ) |  | `[pure virtual]`

Get a pair of the key and the value of the current record.

Note:
  Equal to the original Cursor::get method except that parameters are strings to contain the result and the return value is bool for success.

Implemented in kyotocabinet::BasicDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::jump | ( |  | ) | `[pure virtual]`

Jump the cursor to the first record for forward scan.

Returns:
  true on success, or false on failure.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::PolyDB::Cursor, and kyotocabinet::TextDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::jump | ( | const char * | kbuf,
|  | size_t | ksiz
| ) |  | `[pure virtual]`

Jump the cursor to a record for forward scan.

Parameters:

  kbuf | the pointer to the key region.
  ksiz | the size of the key region.

Returns:
  true on success, or false on failure.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::jump | ( | const std::string & | key | ) | `[pure virtual]`

Jump the cursor to a record for forward scan.

Note:
  Equal to the original Cursor::jump method except that the parameter is std::string.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::jump_back | ( |  | ) | `[pure virtual]`

Jump the cursor to the last record for backward scan.

Returns:
  true on success, or false on failure.

Note:
  This method is dedicated to tree databases. Some database types, especially hash databases, will provide a dummy implementation.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::jump_back | ( | const char * | kbuf,
|  | size_t | ksiz
| ) |  | `[pure virtual]`

Jump the cursor to a record for backward scan.

Parameters:

  kbuf | the pointer to the key region.
  ksiz | the size of the key region.

Returns:
  true on success, or false on failure.

Note:
  This method is dedicated to tree databases. Some database types, especially hash databases, will provide a dummy implementation.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::jump_back | ( | const std::string & | key | ) | `[pure virtual]`

Jump the cursor to a record for backward scan.

Note:
  Equal to the original Cursor::jump_back method except that the parameter is std::string.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::step | ( |  | ) | `[pure virtual]`

Step the cursor to the next record.

Returns:
  true on success, or false on failure.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual bool kyotocabinet::DB::Cursor::step_back | ( |  | ) | `[pure virtual]`

Step the cursor to the previous record.

Returns:
  true on success, or false on failure.

Note:
  This method is dedicated to tree databases. Some database types, especially hash databases, will provide a dummy implementation.

Implemented in kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.

virtual DB* kyotocabinet::DB::Cursor::db | ( |  | ) | `[pure virtual]`

Get the database object.

Returns:
  the database object.

Implemented in kyotocabinet::BasicDB::Cursor, kyotocabinet::HashDB::Cursor, kyotocabinet::PlantDB< BASEDB, DBTYPE >::Cursor, kyotocabinet::DirDB::Cursor, kyotocabinet::CacheDB::Cursor, kyotocabinet::ProtoDB< STRMAP, DBTYPE >::Cursor, kyotocabinet::StashDB::Cursor, kyotocabinet::TextDB::Cursor, and kyotocabinet::PolyDB::Cursor.