MySQL 9.5.0
Source Code Documentation
client_program_options.h
Go to the documentation of this file.
1/*
2Copyright (c) 2025, Oracle and/or its affiliates.
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License, version 2.0,
6as published by the Free Software Foundation.
7
8This program is designed to work with certain software (including
9but not limited to OpenSSL) that is licensed under separate terms,
10as designated in a particular file or component or in included license
11documentation. The authors of MySQL hereby grant you an additional
12permission to link the program and your derivative works with the
13separately licensed software that they have either included with
14the program or referenced in the documentation.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License, version 2.0, for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#pragma once
27
28#include <cstddef>
29#include "my_getopt.h" // my_option
30#include "mysql.h" // MYSQL
31
33 public:
34 virtual ~Client_program_options() = default;
35 virtual bool init(int *argc_ptr, char ***argv_ptr) noexcept = 0;
36 virtual bool apply(MYSQL *mysql) noexcept = 0;
37 virtual bool connect(MYSQL *mysql, unsigned long client_flag) noexcept = 0;
38 const char *get_last_error() noexcept { return last_error; }
39 void clear_last_error() { last_error = nullptr; }
40
42 const char *section_name, const char *copyright,
43 const char *extra_args = nullptr, const my_option *opts = nullptr,
44 size_t nopts = 0,
45 bool (*get_one_option_user_arg)(int optid, const struct my_option *opt,
46 char *argument) = nullptr);
47
48 protected:
49 const char *last_error{nullptr};
50 inline static Client_program_options *singleton{nullptr};
56};
Definition: client_program_options.h:32
virtual ~Client_program_options()=default
virtual bool init(int *argc_ptr, char ***argv_ptr) noexcept=0
Client_program_options()=default
Client_program_options(Client_program_options &&)=delete
const char * get_last_error() noexcept
Definition: client_program_options.h:38
virtual bool apply(MYSQL *mysql) noexcept=0
Client_program_options & operator=(Client_program_options &&)=delete
const char * last_error
Definition: client_program_options.h:49
Client_program_options(const Client_program_options &)=delete
static Client_program_options * singleton
Definition: client_program_options.h:50
Client_program_options & operator=(const Client_program_options &)=delete
void clear_last_error()
Definition: client_program_options.h:39
static Client_program_options * create(const char *section_name, const char *copyright, const char *extra_args=nullptr, const my_option *opts=nullptr, size_t nopts=0, bool(*get_one_option_user_arg)(int optid, const struct my_option *opt, char *argument)=nullptr)
Definition: client_program_options.cc:533
virtual bool connect(MYSQL *mysql, unsigned long client_flag) noexcept=0
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
Definition: instrumented_condition_variable.h:32
Definition: mysql.h:300
Definition: my_getopt.h:93