| 1 |
# |
| 2 |
# $Id: Column.pm 852 2007-03-01 20:32:37Z bastian $ |
| 3 |
# |
| 4 |
# Perl module for Kamailio |
| 5 |
# |
| 6 |
# Copyright (C) 2006 Collax GmbH |
| 7 |
# (Bastian Friedrich <[email protected]>) |
| 8 |
# |
| 9 |
# This file is part of Kamailio, a free SIP server. |
| 10 |
# |
| 11 |
# Kamailio is free software; you can redistribute it and/or modify |
| 12 |
# it under the terms of the GNU General Public License as published by |
| 13 |
# the Free Software Foundation; either version 2 of the License, or |
| 14 |
# (at your option) any later version |
| 15 |
# |
| 16 |
# Kamailio is distributed in the hope that it will be useful, |
| 17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
# GNU General Public License for more details. |
| 20 |
# |
| 21 |
# You should have received a copy of the GNU General Public License |
| 22 |
# along with this program; if not, write to the Free Software |
| 23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 24 |
# |
| 25 |
|
| 26 |
=head1 Kamailio::VDB::Column |
| 27 |
|
| 28 |
This package represents database column definition, consisting of a |
| 29 |
column name and its data type. |
| 30 |
|
| 31 |
=head2 Stringification |
| 32 |
|
| 33 |
When accessing a Kamailio::VDB::Column object as a string, it simply returns its |
| 34 |
column name regardless of its type. |
| 35 |
=cut |
| 36 |
|
| 37 |
package Kamailio::VDB::Column; |
| 38 |
|
| 39 |
use overload '""' => \&stringify; |
| 40 |
|
| 41 |
sub stringify { shift->{name} } |
| 42 |
|
| 43 |
use Kamailio; |
| 44 |
use Kamailio::Constants; |
| 45 |
|
| 46 |
our @ISA = qw ( Kamailio::Utils::Debug ); |
| 47 |
|
| 48 |
=head2 new(type,name) |
| 49 |
|
| 50 |
Constructs a new Column object. Its type and the name are passed as |
| 51 |
parameters. |
| 52 |
|
| 53 |
=cut |
| 54 |
|
| 55 |
sub new { |
| 56 |
my $class = shift; |
| 57 |
my $type = shift; |
| 58 |
my $name = shift; |
| 59 |
|
| 60 |
my $self = { |
| 61 |
type => $type, |
| 62 |
name => $name, |
| 63 |
}; |
| 64 |
|
| 65 |
bless $self, $class; |
| 66 |
|
| 67 |
return $self; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
=head2 type( ) |
| 72 |
|
| 73 |
Returns or sets the current type. Please consider using the constants |
| 74 |
from Kamailio::Constants |
| 75 |
|
| 76 |
=cut |
| 77 |
|
| 78 |
sub type { |
| 79 |
my $self = shift; |
| 80 |
if (@_) { |
| 81 |
$self->{type} = shift; |
| 82 |
} |
| 83 |
|
| 84 |
return $self->{type}; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
=head2 name() |
| 89 |
|
| 90 |
Returns or sets the current column name. |
| 91 |
|
| 92 |
=cut |
| 93 |
|
| 94 |
sub name { |
| 95 |
my $self = shift; |
| 96 |
if (@_) { |
| 97 |
$self->{name} = shift; |
| 98 |
} |
| 99 |
|
| 100 |
return $self->{name}; |
| 101 |
} |
| 102 |
|
| 103 |
1; |