~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/charlength/charlength.cc

  • Committer: Brian Aker
  • Date: 2009-08-18 07:20:29 UTC
  • mfrom: (1117.1.9 merge)
  • Revision ID: brian@gaz-20090818072029-s9ch5lcmltxwidn7
Merge of Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
 
20
#include <drizzled/server_includes.h>
22
21
#include <drizzled/function/math/int.h>
23
 
#include <drizzled/plugin.h>
24
 
#include <drizzled/plugin/function.h>
 
22
#include <drizzled/function/create.h>
25
23
 
26
24
using namespace std;
27
 
using namespace drizzled;
28
25
 
29
26
class CharLengthFunction :public Item_int_func
30
27
{
65
62
  return (int64_t) res->numchars();
66
63
}
67
64
 
68
 
plugin::Create_function<CharLengthFunction> *charlengthudf= NULL;
69
 
plugin::Create_function<CharLengthFunction> *characterlengthudf= NULL;
 
65
Create_function<CharLengthFunction> charlengthudf(string("char_length"));
 
66
Create_function<CharLengthFunction> characterlengthudf(string("character_length"));
70
67
 
71
 
static int initialize(drizzled::module::Context &context)
 
68
static int initialize(drizzled::plugin::Registry &registry)
72
69
{
73
 
  charlengthudf= new plugin::Create_function<CharLengthFunction>("char_length");
74
 
  characterlengthudf= new plugin::Create_function<CharLengthFunction>("character_length");
75
 
  context.add(charlengthudf);
76
 
  context.add(characterlengthudf);
 
70
  registry.add(&charlengthudf);
 
71
  registry.add(&characterlengthudf);
77
72
  return 0;
78
73
}
79
74
 
80
 
DRIZZLE_DECLARE_PLUGIN
81
 
{
82
 
  DRIZZLE_VERSION_ID,
 
75
static int finalize(drizzled::plugin::Registry &registry)
 
76
{
 
77
   registry.remove(&charlengthudf);
 
78
   registry.remove(&characterlengthudf);
 
79
   return 0;
 
80
}
 
81
 
 
82
drizzle_declare_plugin(charlength)
 
83
{
83
84
  "charlength",
84
85
  "1.0",
85
86
  "Devananda van der Veen",
86
87
  "Return the number of characters in a string",
87
88
  PLUGIN_LICENSE_GPL,
88
89
  initialize, /* Plugin Init */
89
 
  NULL,   /* depends */
 
90
  finalize,   /* Plugin Deinit */
 
91
  NULL,   /* status variables */
 
92
  NULL,   /* system variables */
90
93
  NULL    /* config options */
91
94
}
92
 
DRIZZLE_DECLARE_PLUGIN_END;
 
95
drizzle_declare_plugin_end;