# Implement common methods for access to data
#
class BDB1::Common
class << self
#open the database
#
#* name
# The argument name is used as the name of a single physical
# file on disk that will be used to back the database.
#
#* flags
# The flags must be the string "r", "r+", "w", "w+", "a", "a+" or
# and integer value.
#
# The flags value must be set to 0 or by bitwise inclusively
# OR'ing together one or more of the following values
#
# * BDB1::CREATE
# Create any underlying files, as necessary. If the files
# do not already exist and the DB_CREATE flag is not
# specified, the call will fail.
#
# * BDB1::EXCL
# Return an error if the database already exists. Underlying
# filesystem primitives are used to implement this
# flag. For this reason it is only applicable to the
# physical database file and cannot be used to test if a
# subdatabase already exists.
#
# * BDB1::NOMMAP
# Do not map this database into process memory.
#
# * BDB1::RDONLY
# Open the database for reading only. Any attempt to
# modify items in the database will fail regardless of the
# actual permissions of any underlying files.
#
# * BDB1::TRUNCATE
# Physically truncate the underlying database file,
# discarding all previous subdatabases or databases.
# Underlying filesystem primitives are used to implement
# this flag. For this reason it is only applicable to the
# physical database file and cannot be used to discard
# subdatabases.
#
# The DB_TRUNCATE flag cannot be transaction protected,
# and it is an error to specify it in a transaction
# protected environment.
#
# * BDB1::WRITE
# Open the database for writing. Without this flag, any
# attempt to modify items in the database will fail.
#
#
#* mode
# mode to create the file
#
#* options
# Hash, Possible options are (see the documentation of Berkeley DB
# for more informations)
#
# * set_flags: general database configuration
# * set_cachesize: set the database cache size
# * set_pagesize: set the underlying database page size
# * set_lorder: set the database byte order
# * set_store_key: specify a Proc called before a key is stored
# * set_fetch_key: specify a Proc called after a key is read
# * set_store_value: specify a Proc called before a value is stored
# * set_fetch_value: specify a Proc called after a value is read
#
#* options specific to BDB1::Btree
#
# * set_bt_compare: specify a Btree comparison function
# * set_bt_minkey: set the minimum number of keys per Btree page
# * set_bt_prefix: specify a Btree prefix comparison function
#
#* options specific to BDB1::Hash
#
# * set_h_ffactor: set the Hash table density
# * set_h_hash: specify a hashing function
# * set_h_nelem: set the Hash table size
#
#* options specific to BDB1::Recnum
#
# * set_re_delim: set the variable-length record delimiter
# * set_re_len: set the fixed-length record length
# * set_re_pad: set the fixed-length record pad byte
#
# Proc given to set_bt_compare, set_bt_prefix,
# set_h_hash, set_store_key, set_fetch_key,
# set_store_value and set_fetch_value can be also
# specified as a method (replace the prefix set_ with
# bdb1_)
#
# For example
#
# module BDB1
# class Btreesort < Btree
# def bdb1_bt_compare(a, b)
# b.downcase <=> a.downcase
# end
# end
# end
def new(name = nil, flags = "r", mode = 0, options = {})
end
#same than new
def create(name = nil, flags = "r", mode = 0, options = {})
end
#same than new
def open(name = nil, flags = "r", mode = 0, options = {})
yield bdb1
end
#create a new temporary db file, populated with the given object.
#The given object can be an Hash
def [](hash)
end
end
#Returns the value corresponding the key
#
def [](key)
end
#Returns the value correspondind the key
#
def get(key, flags = 0)
end
#Stores the value associating with key
#
#return value
#
def []=(key, value)
end
#Stores the value associating with key
#
#Return the value correspondind the key
#
#flags can have the value DBD::NOOVERWRITE, in this case
#it will return nil if the specified key exist, otherwise
#true
#
def put(key, value, flags = 0)
end
#same than put
def store(key, value, flags = 0)
end
#Append the value associating with key
#
def append(key, value)
end
#Return true if the underlying database is in host order
#
def byteswapped?
end
#same than byteswapped?
def get_byteswapped
end
#Closes the file.
#
def close(flags = 0)
end
#Removes the association from the key.
#
#It return the object deleted or nil if the specified
#key don't exist.
#
def delete(key)
end
#Iterates over associations.
#
def each
yield key, value
end
#same than each { |key, value| ... }
def each_pair
yield key, value
end
#Iterates over keys.
#
def each_key
yield key
end
#Iterates over values.
#
def each_value
yield value
end
#Returns true if the database is empty.
#
def empty?()
end
#Returns true if the association from the key exists.
#
def has_key?(key)
end
#same than has_key?
def key?(key)
end
#same than has_key?
def include?(key)
end
#same than has_key?
def member?(key)
end
#Returns true if the association from key is value
#
def has_both?(key, value)
end
#same than has_both?
def both?(key, value)
end
#Returns true if the association to the value exists.
#
def has_value?(value)
end
#same than has_value?
def value?(value)
end
#Returns the first key associated with value
#
def index(value)
end
#Returns the keys associated with value1, value2, ...
#
def indexes(value1, value2, )
end
#Returns the array of the keys in the database
#
def keys
end
#Returns the number of association in the database.
#
def length
end
#same than length
def size
end
#Create an hash without the associations if the evaluation of the
#block returns true.
#
def reject
yield key, value
end
#Return an array of all associations [key, value]
#
def to_a
end
#Return an hash of all associations {key => value}
#
def to_hash
end
#Empty a database
#
def truncate
end
#same than truncate
def clear
end
#Returns the array of the values in the database.
def values
end
end