MySQL 8.0.39
Source Code Documentation
Mysql::Tools::Base::Abstract_program Class Referenceabstract

Base class for all MySQL client tools. More...

#include <abstract_program.h>

Inheritance diagram for Mysql::Tools::Base::Abstract_program:
[legend]

Public Member Functions

 ~Abstract_program () override
 
const std::string get_name ()
 Returns null-terminated string with name of current program. More...
 
my_optionget_options_array ()
 Returns pointer to array of options for usage in handle_options. More...
 
void run (int argc, char **argv)
 Does all initialization and exit work, calls execute(). More...
 
virtual std::string get_version ()=0
 Returns string describing current version of this program. More...
 
virtual int get_first_release_year ()=0
 Returns year of first release of this program. More...
 
virtual std::string get_description ()=0
 Returns string describing shortly current program. More...
 
virtual void error (const Message_data &message)=0
 Handles general errors. More...
 
virtual int execute (const std::vector< std::string > &positional_options)=0
 Runs main program code. More...
 
virtual void short_usage ()=0
 Prints program invocation message. More...
 
virtual int get_error_code ()=0
 Return error code. More...
 
- Public Member Functions inherited from Mysql::Tools::Base::Options::Composite_options_provider
void add_providers (I_options_provider *first,...)
 Adds new providers to list. More...
 
void add_provider (I_options_provider *options_provider)
 Adds new provider to list. More...
 
void options_parsed () override
 This callback is to be called after all options were parsed. More...
 
std::vector< my_optiongenerate_options () override
 Aggregates all options from itsself and all contained providers. More...
 
- Public Member Functions inherited from Mysql::Tools::Base::Options::Abstract_options_provider
Simple_optioncreate_new_option (std::string name, std::string description)
 Creates and attach new simple option. More...
 
Disabled_optioncreate_new_disabled_option (std::string name, std::string description)
 Creates and attach new disabled option. More...
 
Char_array_optioncreate_new_option (char **value, std::string name, std::string description)
 Creates and attach new string option stored in char* type object. More...
 
Password_optioncreate_new_password_option (std::optional< std::string > *value, std::string name, std::string description)
 Creates and attach new password option. More...
 
String_optioncreate_new_option (std::optional< std::string > *value, std::string name, std::string description)
 Creates and attach new string option. More...
 
Number_option< int32 > * create_new_option (int32 *value, std::string name, std::string description)
 Creates and attach new 32-bit signed number option. More...
 
Number_option< uint32 > * create_new_option (uint32 *value, std::string name, std::string description)
 Creates and attach new 32-bit unsigned number option. More...
 
Number_option< int64 > * create_new_option (int64 *value, std::string name, std::string description)
 Creates and attach new 64-bit signed number option. More...
 
Number_option< uint64 > * create_new_option (uint64 *value, std::string name, std::string description)
 Creates and attach new 64-bit unsigned number option. More...
 
Number_option< double > * create_new_option (double *value, std::string name, std::string description)
 Creates and attach new floating-point number option. More...
 
Bool_optioncreate_new_option (bool *value, std::string name, std::string description)
 Creates and attach new boolean option with value received from argument. More...
 
template<typename T_type , typename T_typelib >
Enum_option< T_type, T_typelib > * create_new_enum_option (T_type *value, const T_typelib *type, std::string name, std::string description)
 
virtual void create_options ()=0
 Creates all options that will be provided. More...
 
- Public Member Functions inherited from Mysql::Tools::Base::Options::I_option_changed_listener
virtual ~I_option_changed_listener ()=default
 

Protected Member Functions

 Abstract_program ()
 
- Protected Member Functions inherited from Mysql::Tools::Base::Options::Abstract_options_provider
 Abstract_options_provider ()
 
 ~Abstract_options_provider () override
 
void set_option_changed_listener (I_option_changed_listener *listener) override
 Sets optional option changes listener to which all changes in all options contained in this provider should be reported. More...
 

Private Member Functions

void init_name (char *name_from_cmd_line)
 Initializes program name. More...
 
void aggregate_options ()
 Gathers all options from option providers and save in array to be used in my_getopt functionality. More...
 

Static Private Member Functions

static bool options_by_name_comparer (const my_option &a, const my_option &b)
 Compares option structures by long name. More...
 
static bool callback_option_parsed (int optid, const struct my_option *opt, char *argument)
 

Private Attributes

Options::Debug_options m_debug_options
 
Options::Help_options m_help_options
 
std::vector< my_optionm_options
 
MEM_ROOT m_argv_alloc {PSI_NOT_INSTRUMENTED, 512}
 
std::string m_name
 

Friends

class Abstract_connection_program
 

Detailed Description

Base class for all MySQL client tools.

Constructor & Destructor Documentation

◆ ~Abstract_program()

Abstract_program::~Abstract_program ( )
overridedefault

◆ Abstract_program()

Abstract_program::Abstract_program ( )
protected

Member Function Documentation

◆ aggregate_options()

void Abstract_program::aggregate_options ( )
private

Gathers all options from option providers and save in array to be used in my_getopt functionality.

◆ callback_option_parsed()

bool Abstract_program::callback_option_parsed ( int  optid,
const struct my_option opt,
char *  argument 
)
staticprivate

◆ error()

virtual void Mysql::Tools::Base::Abstract_program::error ( const Message_data message)
pure virtual

Handles general errors.

Implemented in Mysql::Tools::Upgrade::Program, and Mysql::Tools::Dump::Program.

◆ execute()

virtual int Mysql::Tools::Base::Abstract_program::execute ( const std::vector< std::string > &  positional_options)
pure virtual

Runs main program code.

Implemented in Mysql::Tools::Dump::Program.

◆ get_description()

virtual std::string Mysql::Tools::Base::Abstract_program::get_description ( )
pure virtual

Returns string describing shortly current program.

Implemented in Mysql::Tools::Dump::Program, and Mysql::Tools::Upgrade::Program.

◆ get_error_code()

virtual int Mysql::Tools::Base::Abstract_program::get_error_code ( )
pure virtual

Return error code.

Implemented in Mysql::Tools::Dump::Program, and Mysql::Tools::Upgrade::Program.

◆ get_first_release_year()

virtual int Mysql::Tools::Base::Abstract_program::get_first_release_year ( )
pure virtual

Returns year of first release of this program.

Implemented in Mysql::Tools::Dump::Program, and Mysql::Tools::Upgrade::Program.

◆ get_name()

const string Abstract_program::get_name ( )

Returns null-terminated string with name of current program.

◆ get_options_array()

my_option * Abstract_program::get_options_array ( )

Returns pointer to array of options for usage in handle_options.

Array has empty sentinel at the end, as handle_options expects.

◆ get_version()

virtual std::string Mysql::Tools::Base::Abstract_program::get_version ( )
pure virtual

Returns string describing current version of this program.

Implemented in Mysql::Tools::Dump::Program, and Mysql::Tools::Upgrade::Program.

◆ init_name()

void Abstract_program::init_name ( char *  name_from_cmd_line)
private

Initializes program name.

◆ options_by_name_comparer()

bool Abstract_program::options_by_name_comparer ( const my_option a,
const my_option b 
)
staticprivate

Compares option structures by long name.

Keeps –help first.

◆ run()

void Abstract_program::run ( int  argc,
char **  argv 
)

Does all initialization and exit work, calls execute().

◆ short_usage()

virtual void Mysql::Tools::Base::Abstract_program::short_usage ( )
pure virtual

Prints program invocation message.

Implemented in Mysql::Tools::Dump::Program, and Mysql::Tools::Upgrade::Program.

Friends And Related Function Documentation

◆ Abstract_connection_program

friend class Abstract_connection_program
friend

Member Data Documentation

◆ m_argv_alloc

MEM_ROOT Mysql::Tools::Base::Abstract_program::m_argv_alloc {PSI_NOT_INSTRUMENTED, 512}
private

◆ m_debug_options

Options::Debug_options Mysql::Tools::Base::Abstract_program::m_debug_options
private

◆ m_help_options

Options::Help_options Mysql::Tools::Base::Abstract_program::m_help_options
private

◆ m_name

std::string Mysql::Tools::Base::Abstract_program::m_name
private

◆ m_options

std::vector<my_option> Mysql::Tools::Base::Abstract_program::m_options
private

The documentation for this class was generated from the following files: