File: pgsql_fm.cpp

package info (click to toggle)
falconpl 0.9.6.9-git20120606-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 46,176 kB
  • sloc: cpp: 181,389; ansic: 109,025; yacc: 2,310; xml: 1,218; sh: 403; objc: 245; makefile: 82; sql: 20
file content (64 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (2)
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
/*
 * FALCON - The Falcon Programming Language.
 * FILE: pgsql_fm.cpp
 *
 * PgSQL Falcon service/driver
 * -------------------------------------------------------------------
 * Author: Jeremy Cowgar, Stanislas Marquis
 * Begin: Sun Dec 23 21:54:42 2007
 *
 * -------------------------------------------------------------------
 * (C) Copyright 2007: the FALCON developers (see list in AUTHORS file)
 *
 * See LICENSE file for licensing details.
 */

#include "pgsql_ext.h"
#include "pgsql_mod.h"
#include "version.h"

/*#
   @module dbi.pgsql Postgre SQL database driver module
   @brief DBI extension supporting Postgre SQL database

   Directly importable as @b dbi.pgsql, it is usually loaded through
   the @a dbi module.

*/

// Instantiate the driver service
Falcon::DBIServicePgSQL thePgSQLService;

// the main module
FALCON_MODULE_DECL
{
    // Module declaration
    Falcon::Module *self = new Falcon::Module();
    self->name( "pgsql" );
    self->engineVersion( FALCON_VERSION_NUM );
    self->version( VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION );

    // first of all, we need to declare our dependency from the DBI module.
    self->addDepend( "dbi", "dbi", true, false );

    // also, we declare a PgSQL class, which derives from DBIHandler which
    // is in the DBI module.
    Falcon::Symbol *dbh_class = self->addExternalRef( "dbi.%Handle" ); // it's external
    dbh_class->imported( true );
    Falcon::Symbol *pgsql_class = self->addClass( "PgSQL", Falcon::Ext::PgSQL_init );
    pgsql_class->getClassDef()->addInheritance( new Falcon::InheritDef( dbh_class ) );
    pgsql_class->setWKS( true );

    // we don't have extra functions for the dbhandler of mysql. If whe had,
    // this would be the right place to store them.

    // named prepared statements
    self->addClassMethod( pgsql_class, "prepareNamed", Falcon::Ext::PgSQL_prepareNamed )
            .asSymbol()->addParam( "name" )->addParam( "query" );

    // service publication
    self->publishService( &thePgSQLService );

    // we're done
    return self;
}