DB-Appgen

 view release on metacpan or  search on metacpan

Appgen.pm  view on Meta::CPAN

234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
{ 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;

Appgen.pm  view on Meta::CPAN

539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
=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;

Appgen.xs  view on Meta::CPAN

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
char *
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;

Appgen.xs  view on Meta::CPAN

129
130
131
132
133
134
135
136
137
138
139
140
141
142
                 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

111
112
113
114
115
116
117
118
119
120
121
122
123
}
 
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

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
int             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

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
int 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 )