~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
/* This implements 'user defined functions' */
22
 
#include <config.h>
 
22
#include "config.h"
23
23
 
24
24
#include <boost/unordered_map.hpp>
25
25
 
26
26
#include <drizzled/gettext.h>
27
 
#include <drizzled/plugin/function.h>
 
27
#include "drizzled/plugin/function.h"
28
28
#include <drizzled/function_container.h>
29
 
#include <drizzled/util/find_ptr.h>
30
 
#include <drizzled/util/string.h>
 
29
 
 
30
#include "drizzled/util/string.h"
31
31
 
32
32
namespace drizzled
33
33
{
41
41
 
42
42
bool plugin::Function::addPlugin(const plugin::Function *udf)
43
43
{
44
 
  if (FunctionContainer::getMap().count(udf->getName()))
 
44
  if (FunctionContainer::getMap().find(udf->getName()) != FunctionContainer::getMap().end())
45
45
  {
46
46
    errmsg_printf(error::ERROR,
47
47
                  _("A function named %s already exists!\n"),
49
49
    return true;
50
50
  }
51
51
 
52
 
  if (udf_registry.count(udf->getName()))
 
52
  if (udf_registry.find(udf->getName()) != udf_registry.end())
53
53
  {
54
54
    errmsg_printf(error::ERROR,
55
55
                  _("A function named %s already exists!\n"),
59
59
 
60
60
  std::pair<UdfMap::iterator, bool> ret=
61
61
    udf_registry.insert(make_pair(udf->getName(), udf));
62
 
 
63
62
  if (ret.second == false)
64
63
  {
65
64
    errmsg_printf(error::ERROR,
76
75
  udf_registry.erase(udf->getName());
77
76
}
78
77
 
79
 
const plugin::Function *plugin::Function::get(const std::string &name)
 
78
const plugin::Function *plugin::Function::get(const char *name, size_t length)
80
79
{
81
 
  UdfMap::mapped_type* ptr= find_ptr(udf_registry, name);
82
 
  return ptr ? *ptr : NULL;
 
80
  UdfMap::iterator iter= udf_registry.find(std::string(name, length));
 
81
  if (iter == udf_registry.end())
 
82
  {
 
83
    return NULL;
 
84
  }
 
85
  return (*iter).second;
83
86
}
84
87
 
85
88
} /* namespace drizzled */