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