File: Dialect.pm

package info (click to toggle)
libtangram-perl 2.04-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 572 kB
  • ctags: 495
  • sloc: perl: 5,061; makefile: 36
file content (72 lines) | stat: -rw-r--r-- 984 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use strict;

package Tangram::Dialect;

my @dialects;

sub register
  {
    push @dialects, shift;
  }

sub rate_connect_string
  {
    return 0;
  }

Tangram::Dialect->register();

sub guess
  {
    my ($class, $cs) = @_;
    
    my @rated = sort { $b->[1] <=> $a->[1] }
    grep { $_->[1] }
    map { [ $_, $_->rate_connect_string($cs) ] }
    @dialects;
    
    return @rated if wantarray;
    
    die "cannot select dialect, more than one have equal rating"
      if @rated > 1 && $rated[0][1] == $rated[1][1];
    
    return @rated ? $rated[0][0]->new : undef();
  }

sub new
  {
    my $class = shift;
    return bless { @_ }, $class;
  }

sub expr
  {
    my $self = shift;
    return shift->expr( @_ );
  }

sub make_id
  {
    shift;
    return shift->std_make_id(@_);
  }

sub tx_start
  {
    shift;
    shift->std_tx_start(@_);
  }

sub tx_commit
  {
    shift;
    shift->std_tx_commit(@_);
  }

sub tx_rollback
  {
    shift;
    shift->std_tx_rollback(@_);
  }

1;