~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.cc

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:27:09 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032709-oyvfrc6eb8fzj0mr
fix docs warning: docs/unlock.rst:2: (WARNING/2) Title underline too short.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
/* This implements 'user defined functions' */
22
22
#include "config.h"
 
23
 
 
24
#include <boost/unordered_map.hpp>
 
25
 
23
26
#include <drizzled/gettext.h>
24
 
#include "drizzled/hash.h"
25
27
#include "drizzled/plugin/function.h"
26
28
 
 
29
#include "drizzled/util/string.h"
 
30
 
27
31
using namespace std;
28
32
 
29
33
namespace drizzled
30
34
{
31
35
 
32
 
typedef hash_map<string, const plugin::Function *> UdfMap;
33
 
static UdfMap udf_registry;
 
36
static plugin::Function::UdfMap udf_registry;
 
37
 
 
38
const plugin::Function::UdfMap &plugin::Function::getMap()
 
39
{
 
40
  return udf_registry;
 
41
}
34
42
 
35
43
bool plugin::Function::addPlugin(const plugin::Function *udf)
36
44
{
37
 
  string lower_name(udf->getName());
38
 
  transform(lower_name.begin(), lower_name.end(),
39
 
            lower_name.begin(), ::tolower);
40
 
  if (udf_registry.find(lower_name) != udf_registry.end())
 
45
  if (udf_registry.find(udf->getName()) != udf_registry.end())
41
46
  {
42
47
    errmsg_printf(ERRMSG_LVL_ERROR,
43
48
                  _("A function named %s already exists!\n"),
45
50
    return true;
46
51
  }
47
52
  pair<UdfMap::iterator, bool> ret=
48
 
    udf_registry.insert(make_pair(lower_name, udf));
 
53
    udf_registry.insert(make_pair(udf->getName(), udf));
49
54
  if (ret.second == false)
50
55
  {
51
56
    errmsg_printf(ERRMSG_LVL_ERROR,
58
63
 
59
64
void plugin::Function::removePlugin(const plugin::Function *udf)
60
65
{
61
 
  string lower_name(udf->getName());
62
 
  transform(lower_name.begin(), lower_name.end(),
63
 
            lower_name.begin(), ::tolower);
64
 
  udf_registry.erase(lower_name);
 
66
  udf_registry.erase(udf->getName());
65
67
}
66
68
 
67
69
const plugin::Function *plugin::Function::get(const char *name, size_t length)
68
70
{
69
 
  string lower_name(name, length);
70
 
  transform(lower_name.begin(), lower_name.end(),
71
 
            lower_name.begin(), ::tolower);
72
 
  UdfMap::iterator iter= udf_registry.find(lower_name);
 
71
  UdfMap::iterator iter= udf_registry.find(std::string(name, length));
73
72
  if (iter == udf_registry.end())
74
73
  {
75
74
    return NULL;