1 package Blerg::Database;
11 our @ISA = qw(Exporter);
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
17 # This allows declaration use Blerg::Database ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
20 our %EXPORT_TAGS = ( 'all' => [ qw(
24 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
33 # This AUTOLOAD is used to 'autoload' constants from the constant()
38 ($constname = $AUTOLOAD) =~ s/.*:://;
39 croak "&Blerg::Database::constant not defined" if $constname eq 'constant';
40 my ($error, $val) = constant($constname);
41 if ($error) { croak $error; }
44 # Fixed between 5.005_53 and 5.005_61
45 #XXX if ($] >= 5.00561) {
46 #XXX *$AUTOLOAD = sub () { $val };
49 *$AUTOLOAD = sub { $val };
56 XSLoader::load('Blerg::Database', $VERSION);
58 # Preloaded methods go here.
61 my ($class, $name) = @_;
62 my $ptr = Blerg::Database::_open($name);
67 return bless $obj, $class;
71 my ($class, $name) = @_;
73 if (Blerg::Database::exists($name)) {
74 return Blerg::Database->open($name);
81 if (!defined $obj->{ptr}) {
82 croak "Attempted to use closed Blerg::Database";
88 $obj->_ensure_pointer;
89 Blerg::Database::_close($obj->{ptr});
100 $obj->_ensure_pointer;
101 return Blerg::Database::_get_record_count($obj->{ptr});
104 sub set_subscription_mark {
106 $obj->_ensure_pointer;
107 return Blerg::Database::_set_subscription_mark($obj->{ptr});
110 sub get_subscription_mark {
112 $obj->_ensure_pointer;
113 return Blerg::Database::_get_subscription_mark($obj->{ptr});
116 sub subscription_list {
118 return Blerg::Database::subscription_list($obj->{name});
123 $obj->_ensure_pointer;
125 return Blerg::Database::_set_mute($obj->{ptr}, $v);
127 return Blerg::Database::_get_mute($obj->{ptr});
133 return Blerg::Database::tag_list('@' . $obj->{name}, 50, -1);
137 my ($obj, $data) = @_;
138 $obj->_ensure_pointer;
139 return Blerg::Database::_store($obj->{ptr}, $data);
143 my ($obj, $record) = @_;
144 $obj->_ensure_pointer;
145 return Blerg::Database::_fetch($obj->{ptr}, $record);
149 my ($obj, $record) = @_;
150 $obj->_ensure_pointer;
151 return Blerg::Database::_get_timestamp($obj->{ptr}, $record);
154 # Convenience shortcuts
156 my ($name, $str_offset, $direction) = @_;
157 return Blerg::Database::tag_list("#$name", $str_offset, $direction);
161 my ($name, $str_offset, $direction) = @_;
162 return Blerg::Database::tag_list("@$name", $str_offset, $direction);
165 # Autoload methods go after =cut, and are processed by the autosplit program.
169 # Below is stub documentation for your module. You'd better edit it!
173 Blerg::Database - Perl extension for blah blah blah
182 Stub documentation for Blerg::Database, created by h2xs. It looks like the
183 author of the extension was negligent enough to leave the stub
199 Original version; created by h2xs 1.23 with options
215 Mention other useful documentation such as the documentation of
216 related modules or operating system documentation (such as man pages
217 in UNIX), or any relevant external documentation such as RFCs or
220 If you have a mailing list set up for your module, mention it here.
222 If you have a web site set up for your module, mention it here.
226 Chip Black, E<lt>bytex64@bytex64.netE<gt>
228 =head1 COPYRIGHT AND LICENSE
230 Copyright (C) 2013 by Chip Black
232 This library is free software; you can redistribute it and/or modify
233 it under the same terms as Perl itself, either Perl version 5.16.1 or,
234 at your option, any later version of Perl 5 you may have available.