wikimedia/cdb
CDB functions for PHP
Loading...
Searching...
No Matches
Cdb\Reader\PHP Class Reference

CDB reader class. More...

+ Inheritance diagram for Cdb\Reader\PHP:

Public Member Functions

 __construct (string $fileName)
 
 close ()
 Close the handle on the CDB file.
 
 get ( $key)
 Get the value of a key.
 
 exists ( $key)
 Check if a key exists in the CDB file.
 
 firstkey ()
 Get the first key from the CDB file and reset the key iterator.
 
 nextkey ()
 Get the next key from the CDB file.
 

Protected Member Functions

 read ( $start, $len)
 Read data from the CDB file.
 
 readInt31 ( $pos=0)
 Unpack an unsigned integer and throw an exception if it needs more than 31 bits.
 
 readInt32 ( $pos=0)
 Unpack a 32-bit integer.
 
 find ( $key)
 Search the CDB file for a key.
 

Protected Attributes

 $fileName
 
 $handle
 The file handle.
 
 $index
 
 $dataPos
 
 $dataLen
 
 $keyIterPos = 2048
 
 $keyIterStop
 
 $buf
 
 $bufStart
 
 $filePos = 2048
 

Additional Inherited Members

- Static Public Member Functions inherited from Cdb\Reader
static open ( $fileName)
 Open a file and return a subclass instance.
 
static haveExtension ()
 Returns true if the native extension is available.
 

Detailed Description

CDB reader class.

This is a port of D.J. Bernstein's CDB to PHP. It's based on the copy that appears in PHP 5.3.

Constructor & Destructor Documentation

◆ __construct()

Cdb\Reader\PHP::__construct ( string $fileName)
Parameters
string$fileName
Exceptions
ExceptionIf CDB file cannot be opened or if it contains fewer than 2048 bytes of data.

Member Function Documentation

◆ close()

Cdb\Reader\PHP::close ( )

Close the handle on the CDB file.

Reimplemented from Cdb\Reader.

◆ exists()

Cdb\Reader\PHP::exists ( $key)

Check if a key exists in the CDB file.

Parameters
string | int$key
Returns
bool Whether the key exists.

Reimplemented from Cdb\Reader.

◆ find()

Cdb\Reader\PHP::find ( $key)
protected

Search the CDB file for a key.

Sets dataLen and dataPos properties if successful.

Parameters
string$key
Returns
bool Whether the key was found.

◆ firstkey()

Cdb\Reader\PHP::firstkey ( )

Get the first key from the CDB file and reset the key iterator.

Returns
string|bool Key, or false if no keys in file.

Reimplemented from Cdb\Reader.

◆ get()

Cdb\Reader\PHP::get ( $key)

Get the value of a key.

Parameters
string | int$key
Returns
string|false The key's value or false if not found

Reimplemented from Cdb\Reader.

◆ nextkey()

Cdb\Reader\PHP::nextkey ( )

Get the next key from the CDB file.

Returns
string|bool Key, or false if no more keys.

Reimplemented from Cdb\Reader.

◆ read()

Cdb\Reader\PHP::read ( $start,
$len )
protected

Read data from the CDB file.

Parameters
int$startStart reading from this position
int$lenNumber of bytes to read
Returns
string Read data.

◆ readInt31()

Cdb\Reader\PHP::readInt31 ( $pos = 0)
protected

Unpack an unsigned integer and throw an exception if it needs more than 31 bits.

Parameters
int$posPosition to read from.
Exceptions
ExceptionWhen the integer cannot be represented in 31 bits.
Returns
int

◆ readInt32()

Cdb\Reader\PHP::readInt32 ( $pos = 0)
protected

Unpack a 32-bit integer.

Parameters
int$pos
Returns
int

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