DB-Appgen
view release on metacpan or search on metacpan
234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275{
my
$self
=
shift
;
my
$args
=get_args(\
@_
);
ag_readnext(
$$self
,
$args
->{
lock
} || 0);
}
##
# Number of attributes
#
sub
attributes_number ($)
{
my
$self
=
shift
;
ag_db_stat(
$$self
,-1,-1);
}
##
# Number of values
#
sub
values_number($%)
{
my
$self
=
shift
;
my
$args
=get_args(\
@_
);
my
$attr
=
$args
->{attribute} ||
$args
->{attr} || 0;
ag_db_stat(
$$self
,
$attr
,-1);
}
##
# Length of field
#
sub
value_length ($%)
{
my
$self
=
shift
;
my
$args
=get_args(\
@_
);
my
$attr
=
$args
->{attribute} ||
$args
->{attr} || 0;
my
$value
=
$args
->{value} ||
$args
->{val} || 0;
ag_db_stat(
$$self
,
$attr
,
$value
);
}
##
# Deletes value
#
sub
delete
($%)
{
my
$self
=
shift
;
my
$args
=get_args(\
@_
);
my
$attr
=
$args
->{attribute} ||
$args
->{attr} || 0;
my
$value
=
$args
->{value} ||
$args
->{val} || 0;
539540541542543544545546547548549550551552553554555556557558559=head2 $db->next(lock => 1);
=head2 ag_readnext($db);
Moves I<current record> to the next record in the database in random
order locking it if required. Returns key text or undef if no more
records exist.
=head1 FIELD LEVEL METHODS
=head2 ag_db_stat($db, $attr, $value);
This method determines the size and composition of a field in the
I<current record>. Consult appgen documentation for details.
A number of methods exists to get the same functionality in more
straight forward way:
=over
=item $db->attributes_number;
100101102103104105106107108109110111112113114115116117118119120char *
ag_extract(dbh,attr,val,maxsz)
unsigned dbh;
int
attr;
int
val;
int
maxsz;
INIT:
char
*buf
=NULL;
CODE:
if
(! maxsz)
maxsz=ag_db_stat(dbh,attr,val);
if
(maxsz <= 0)
RETVAL=NULL;
else
{ New(
'am'
,buf,maxsz+1,char);
if
(!buf)
RETVAL=NULL;
else
{
int
rc=ag_extract(dbh,attr,val,buf,maxsz+1);
if
(rc == -1)
RETVAL=NULL;
129130131132133134135136137138139140141142
Safefree(buf);
int
ag_replace(dbh,attr,val,buf)
unsigned dbh;
int
attr;
int
val;
char* buf;
int
ag_db_stat(dbh,attr,val)
unsigned dbh;
int
attr;
int
val;
aglib/aglib.c view on Meta::CPAN
111112113114115116117118119120121122123}
int
ag_replace(unsigned dbh,
int
attr,
int
val, char
*buf
)
{
return
replace(h2p(dbh),attr,val,buf);
}
int
ag_insert(unsigned dbh,
int
attr,
int
val, char
*buf
)
{
return
insert(h2p(dbh),attr,val,buf);
}
int
ag_db_stat(unsigned dbh,
int
attr,
int
val)
{
return
db_stat(h2p(dbh),attr,val);
}
aglib/aglib.h view on Meta::CPAN
262728293031323334353637383940414243444546int
ag_db_write(unsigned dbh);
int
ag_db_release(unsigned dbh);
int
ag_db_newrec(unsigned dbh, char
*key
, long size);
int
ag_db_delrec(unsigned dbh);
char * ag_readnext(unsigned dbh,
int
foo);
int
ag_drop(unsigned dbh,
int
attr,
int
val);
int
ag_extract(unsigned dbh,
int
attr,
int
val, char
*buf
,
int
maxsz);
int
ag_replace(unsigned dbh,
int
attr,
int
val, char
*buf
);
int
ag_insert(unsigned dbh,
int
attr,
int
val, char
*buf
);
int
ag_db_stat(unsigned dbh,
int
attr,
int
val);
/* APPGEN database library interface.
*
* This is probably bad, but I
do
not want to include standard appgen
* include files.
*/
/* File level
*/
void
*db_open
(char const
*file
);
aglib/aglib.h view on Meta::CPAN
596061626364656667686970717273int
db_newrec(void
*db
, char
*key
, long size);
int
db_delrec(void
*db
);
char
*readnext
(void
*db
,
int
foo);
/* Field level
*/
int
delete
(void
*db
,
int
attr,
int
val);
int
extract(void
*db
,
int
attr,
int
val, char
*buf
,
int
maxsz);
int
replace(void
*db
,
int
attr,
int
val, char
*buf
);
int
insert(void
*db
,
int
attr,
int
val, char
*buf
);
int
db_stat(void
*db
,
int
attr,
int
val);
#ifdef __cplusplus
}
#endif
( run in 1.010 second using v1.01-cache-2.11-cpan-49f99fa48dc )