~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.cc

  • Committer: Paweł Blokus
  • Date: 2010-06-09 20:36:51 UTC
  • mto: This revision was merged to the branch mainline in revision 1620.
  • Revision ID: pawel@pawel-desktop-20100609203651-mbq5x34bt9m3kv0o
minor style fixes

Show diffs side-by-side

added added

removed removed

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