Kyoto Cabinet

- Main Page
- Namespaces
- Classes
- Files

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

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

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

`#include <kcdb.h>`

List of all members.

## Public Member Functions
virtual | ~Cursor ()
| Destructor.
bool | set_value (const char *vbuf, size_t vsiz, bool step=false)
| Set the value of the current record.
bool | set_value_str (const std::string &value, bool step=false)
| Set the value of the current record.
bool | remove ()
| Remove the current record.
char * | get_key (size_t *sp, bool step=false)
| Get the key of the current record.
bool | get_key (std::string *key, bool step=false)
| Get the key of the current record.
char * | get_value (size_t *sp, bool step=false)
| Get the value of the current record.
bool | get_value (std::string *value, bool step=false)
| Get the value of the current record.
char * | get (size_t *ksp, const char **vbp, size_t *vsp, bool step=false)
| Get a pair of the key and the value of the current record.
bool | get (std::string *key, std::string *value, bool step=false)
| Get a pair of the key and the value of the current record.
char * | seize (size_t *ksp, const char **vbp, size_t *vsp)
| Get a pair of the key and the value of the current record and remove it atomically.
bool | seize (std::string *key, std::string *value)
| Get a pair of the key and the value of the current record and remove it atomically.
virtual BasicDB * | db ()=0
| Get the database object.
Error | error ()
| Get the last happened error.

## Detailed Description

Interface of cursor to indicate a record.

## Constructor & Destructor Documentation

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

Destructor.

Reimplemented from kyotocabinet::DB::Cursor.

Reimplemented 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.

## Member Function Documentation

bool kyotocabinet::BasicDB::Cursor::set_value | ( | const char * | vbuf,
|  | size_t | vsiz,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

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

Set the value of the current record.

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

Implements kyotocabinet::DB::Cursor.

bool kyotocabinet::BasicDB::Cursor::remove | ( |  | ) | `[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.

Implements kyotocabinet::DB::Cursor.

char* kyotocabinet::BasicDB::Cursor::get_key | ( | size_t * | sp,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

bool kyotocabinet::BasicDB::Cursor::get_key | ( | std::string * | key,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

char* kyotocabinet::BasicDB::Cursor::get_value | ( | size_t * | sp,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

bool kyotocabinet::BasicDB::Cursor::get_value | ( | std::string * | value,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

char* kyotocabinet::BasicDB::Cursor::get | ( | size_t * | ksp,
|  | const char ** | vbp,
|  | size_t * | vsp,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

bool kyotocabinet::BasicDB::Cursor::get | ( | std::string * | key,
|  | std::string * | value,
|  | bool | step = `false`
| ) |  | `[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.

Implements kyotocabinet::DB::Cursor.

char* kyotocabinet::BasicDB::Cursor::seize | ( | size_t * | ksp,
|  | const char ** | vbp,
|  | size_t * | vsp
| ) |  |

Get a pair of the key and the value of the current record and remove it atomically.

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.

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. The cursor is moved to the next record implicitly.

bool kyotocabinet::BasicDB::Cursor::seize | ( | std::string * | key,
|  | std::string * | value
| ) |  |

Get a pair of the key and the value of the current record and remove it atomically.

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

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

Get the database object.

Returns:
  the database object.

Implements kyotocabinet::DB::Cursor.

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.

Error kyotocabinet::BasicDB::Cursor::error | ( |  | ) |

Get the last happened error.

Returns:
  the last happened error.