~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/context.cc

  • Committer: Monty Taylor
  • Date: 2010-10-15 17:18:02 UTC
  • mto: (1859.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1860.
  • Revision ID: mordred@inaugust.com-20101015171802-qhk6zyfhrkvprr1n
Added support for registering regular sys_var instances via module::Context.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
  return module::option_map(module->getName(), getVariablesMap());
35
35
}
36
36
 
 
37
void Context::registerVariable(sys_var *var)
 
38
{
 
39
  var->setName(prepend_name(module->getName(), var->getName()));
 
40
  add_sys_var_to_list(var);
 
41
}
 
42
 
 
43
namespace
 
44
{
 
45
 
 
46
class SwapDashes
 
47
{
 
48
public:
 
49
  char operator()(char a) const
 
50
  {
 
51
    if (a == '-')
 
52
      return '_';
 
53
    return a;
 
54
  }
 
55
};
 
56
 
 
57
} /* namespace */
 
58
 
 
59
std::string Context::prepend_name(std::string module_name,
 
60
                                  const std::string &var_name)
 
61
{
 
62
  module_name.push_back('_');
 
63
  module_name.append(var_name);
 
64
  std::transform(module_name.begin(), module_name.end(),
 
65
                 module_name.begin(), SwapDashes());
 
66
  std::transform(module_name.begin(), module_name.end(),
 
67
                 module_name.begin(), ::tolower);
 
68
  return module_name;
 
69
}
 
70
 
 
71
 
37
72
} /* namespace module */
38
73
} /* namespace drizzled */