MySQL 8.3.0
Source Code Documentation
abstract_integer_number_option.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2014, 2023, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef ABSTRACT_INTEGER_NUMBER_OPTION_INCLUDED
26#define ABSTRACT_INTEGER_NUMBER_OPTION_INCLUDED
27
28#include <string>
29
31
32namespace Mysql {
33namespace Tools {
34namespace Base {
35namespace Options {
36
37/**
38 Abstract option to handle integer number option values.
39 */
40template <typename T_type, typename T_value>
42 : public Abstract_number_option<T_type, T_value> {
43 public:
44 /**
45 Sets value for this option. If it is specified before handling commandline
46 options then supplied value is used as default value of this option.
47 */
48 T_type *set_value(T_value value);
49
50 /**
51 Sets required divisor of input value.
52 */
53 T_type *set_value_step(T_value step);
54 /**
55 Sets minimum value boundary for option value. Smaller values passed as
56 option value will be changed to this minimum value.
57 Part of implementation of Abstract_number_option virtual method.
58 */
59 T_type *set_minimum_value(T_value minimum) override;
60 /**
61 Sets maximum value boundary for option value. Greater values passed as
62 option value will be changed to this maximum value.
63 Part of implementation of Abstract_number_option virtual method.
64 */
65 T_type *set_maximum_value(T_value maximum) override;
66
67 protected:
68 /**
69 Constructs new number option.
70 @param value Pointer to object to receive option value.
71 @param var_type my_getopt internal option type.
72 @param name Name of option. It is used in command line option name as
73 --name.
74 @param description Description of option to be printed in --help.
75 */
76 Abstract_integer_number_option(T_value *value, ulong var_type,
77 std::string name, std::string description);
78};
79
80template <typename T_type, typename T_value>
82 T_value *value, ulong var_type, std::string name, std::string description)
83 : Abstract_number_option<T_type, T_value>(value, var_type, name,
84 description, 0) {
85 *value = 0;
86}
87
88template <typename T_type, typename T_value>
90 T_value value) {
91 *(T_value *)this->m_option_structure.value = value;
92 this->m_option_structure.def_value = (longlong)value;
93 return (T_type *)this;
94}
95
96template <typename T_type, typename T_value>
98 T_value step) {
99 this->m_option_structure.block_size = (long)step;
100 return (T_type *)this;
101}
102
103template <typename T_type, typename T_value>
105 T_value minimum) {
106 this->m_option_structure.min_value = (longlong)minimum;
107 return (T_type *)this;
108}
109
110template <typename T_type, typename T_value>
112 T_value maximum) {
113 this->m_option_structure.max_value = (ulonglong)maximum;
114 return (T_type *)this;
115}
116
117} // namespace Options
118} // namespace Base
119} // namespace Tools
120} // namespace Mysql
121
122#endif
Abstract option to handle integer number option values.
Definition: abstract_integer_number_option.h:42
Abstract_integer_number_option(T_value *value, ulong var_type, std::string name, std::string description)
Constructs new number option.
Definition: abstract_integer_number_option.h:81
T_type * set_value_step(T_value step)
Sets required divisor of input value.
Definition: abstract_integer_number_option.h:97
T_type * set_maximum_value(T_value maximum) override
Sets maximum value boundary for option value.
Definition: abstract_integer_number_option.h:111
T_type * set_minimum_value(T_value minimum) override
Sets minimum value boundary for option value.
Definition: abstract_integer_number_option.h:104
T_type * set_value(T_value value)
Sets value for this option.
Definition: abstract_integer_number_option.h:89
Abstract option to handle numeric option values.
Definition: abstract_number_option.h:41
unsigned long long int ulonglong
Definition: my_inttypes.h:55
long long int longlong
Definition: my_inttypes.h:54
constexpr pos_type Options
Definition: http_request.h:260
Definition: abstract_connection_program.h:39
case opt name
Definition: sslopt-case.h:32