drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
option_context.cc
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 <boost/algorithm/string.hpp>
23
24namespace drizzled {
25namespace module {
26
27option_context::option_context(const std::string &module_name_in,
28 po::options_description_easy_init po_options_in) :
29 module_name(module_name_in),
30 po_options(po_options_in)
31{ }
32
33option_context& option_context::operator()(const char* name, const char* description)
34{
35 po_options(prepend_name(module_name, name).c_str(), description);
36 return *this;
37}
38
39option_context& option_context::operator()(const char* name, const po::value_semantic* s)
40{
41 po_options(prepend_name(module_name, name).c_str(), s);
42 return *this;
43}
44
45option_context& option_context::operator()(const char* name, const po::value_semantic* s, const char* description)
46{
47 po_options(prepend_name(module_name, name).c_str(), s, description);
48 return *this;
49}
50
51std::string option_context::prepend_name(std::string in_module_name, const char *name_in)
52{
53 in_module_name.push_back('.');
54 std::replace(in_module_name.begin(), in_module_name.end(), '_', '-');
55 boost::to_lower(in_module_name);
56 in_module_name.append(name_in);
57 return in_module_name;
58}
59
60} /* namespace module */
61} /* namespace drizzled */
62
TODO: Rename this file - func.h is stupid.
An Proxy Wrapper around options_description_easy_init.