~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/context.cc

  • Committer: Andrew Hutchings
  • Date: 2011-01-21 11:23:19 UTC
  • mto: (2100.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2101.
  • Revision ID: andrew@linuxjedi.co.uk-20110121112319-nj1cvg0yt3nnf2rr
Add errors page to drizzle client docs
Add link to specific error in migration docs
Minor changes to migration docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Monty Taylor
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#include "config.h"
 
21
#include "drizzled/module/context.h"
 
22
#include "drizzled/module/option_map.h"
 
23
#include "drizzled/module/module.h"
 
24
#include "drizzled/drizzled.h"
 
25
#include "drizzled/sys_var.h"
 
26
 
 
27
namespace drizzled
 
28
{
 
29
 
 
30
namespace module
 
31
{
 
32
 
 
33
module::option_map Context::getOptions()
 
34
{
 
35
  return module::option_map(module->getName(), getVariablesMap());
 
36
}
 
37
 
 
38
void Context::registerVariable(sys_var *var)
 
39
{
 
40
  var->setName(prepend_name(module->getName(), var->getName()));
 
41
  module->addMySysVar(var);
 
42
  add_sys_var_to_list(var);
 
43
}
 
44
 
 
45
namespace
 
46
{
 
47
 
 
48
class SwapDashes
 
49
{
 
50
public:
 
51
  char operator()(char a) const
 
52
  {
 
53
    if (a == '-')
 
54
      return '_';
 
55
    return a;
 
56
  }
 
57
};
 
58
 
 
59
} /* namespace */
 
60
 
 
61
std::string Context::prepend_name(std::string module_name,
 
62
                                  const std::string &var_name)
 
63
{
 
64
  module_name.push_back('_');
 
65
  module_name.append(var_name);
 
66
  std::transform(module_name.begin(), module_name.end(),
 
67
                 module_name.begin(), SwapDashes());
 
68
  std::transform(module_name.begin(), module_name.end(),
 
69
                 module_name.begin(), ::tolower);
 
70
  return module_name;
 
71
}
 
72
 
 
73
 
 
74
} /* namespace module */
 
75
} /* namespace drizzled */