~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/option_context.h

  • Committer: Monty Taylor
  • Date: 2010-06-19 21:25:32 UTC
  • mfrom: (1627.2.5 build)
  • Revision ID: mordred@inaugust.com-20100619212532-2e4bd11tm4plya7q
Rollup patch featuring: boost::program_options support for plugins, a
valgrind fix, a bugfix for password processing and a few build fixes.

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
/**
 
21
 * @file
 
22
 * @brief An Proxy Wrapper around options_description_easy_init
 
23
 */
 
24
 
 
25
#ifndef DRIZZLED_MODULE_OPTION_CONTEXT_H
 
26
#define DRIZZLED_MODULE_OPTION_CONTEXT_H
 
27
 
 
28
#include "drizzled/visibility.h"
 
29
 
 
30
#include <boost/program_options.hpp>
 
31
 
 
32
#include <string>
 
33
 
 
34
namespace drizzled
 
35
{
 
36
namespace module
 
37
{
 
38
 
 
39
namespace po=boost::program_options;
 
40
 
 
41
/**
 
42
 * Options proxy wrapper. Provides pre-pending of module name to each option
 
43
 * which is added.
 
44
 */
 
45
class DRIZZLED_API option_context
 
46
{
 
47
  const std::string &module_name;
 
48
  po::options_description_easy_init po_options;
 
49
 
 
50
  std::string prepend_name(const char *name) const;
 
51
 
 
52
public:
 
53
 
 
54
  option_context(const std::string &module_name_in,
 
55
                 po::options_description_easy_init po_options_in);
 
56
 
 
57
  option_context& operator()(const char* name,
 
58
                             const char* description);
 
59
 
 
60
  option_context& operator()(const char* name,
 
61
                             const po::value_semantic* s);
 
62
 
 
63
  option_context& operator()(const char* name,
 
64
                             const po::value_semantic* s,
 
65
                             const char* description);
 
66
 
 
67
private:
 
68
  
 
69
  /**
 
70
   * Don't allow default construction.
 
71
   */
 
72
  option_context();
 
73
 
 
74
  /**
 
75
   * Don't allow copying of objects.
 
76
   */
 
77
  option_context(const option_context &);
 
78
 
 
79
  /**
 
80
   * Don't allow assignment of objects.
 
81
   */
 
82
  option_context& operator=(const option_context &);
 
83
};
 
84
 
 
85
/*
 
86
 * Private methods.
 
87
 */
 
88
inline std::string option_context::prepend_name(const char *name_in) const
 
89
{
 
90
  std::string new_name(module_name);
 
91
  new_name.push_back('.');
 
92
  new_name.append(name_in);
 
93
  return new_name;
 
94
}
 
95
 
 
96
} /* namespace module */
 
97
} /* namespace drizzled */
 
98
 
 
99
 
 
100
#endif /* DRIZZLED_MODULE_OPTION_CONTEXT_H */