MySQL++: options.h Source File
options.h
Go to the documentation of this file.
/***********************************************************************
Copyright (c) 2007-2009 by Educational Technology Resources, Inc.
Others may also hold copyrights on code in this file. See the
CREDITS file in the top directory of the distribution for details.
This file is part of MySQL++.
MySQL++ is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
MySQL++ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MySQL++; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
***********************************************************************/
#if !defined(MYSQLPP_OPTIONS_H)
#define MYSQLPP_OPTIONS_H
#include "common.h"
#include <deque>
#include <string>
namespace mysqlpp {
#if !defined(DOXYGEN_IGNORE)
class DBDriver;
#endif
// Classes
class MYSQLPP_EXPORT Option
{
public:
enum Error {
err_NONE,
err_api_limit,
err_api_reject,
err_connected,
err_disconnected
};
virtual ~Option() { }
virtual Error set(DBDriver* dbd) = 0;
};
template <typename T>
class MYSQLPP_EXPORT DataOption : public Option
{
public:
typedef T ArgType;
protected:
DataOption(const T& arg) : arg_(arg) { }
T arg_;
};
typedef DataOption<unsigned> IntegerOption;
typedef DataOption<bool> BooleanOption;
typedef DataOption<std::string> StringOption;
class MYSQLPP_EXPORT CompressOption : public Option
{
#if !defined(DOXYGEN_IGNORE)
public:
CompressOption() : Option() { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT ConnectTimeoutOption : public IntegerOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ConnectTimeoutOption(ArgType arg) : IntegerOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT FoundRowsOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
FoundRowsOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT GuessConnectionOption : public Option
{
#if !defined(DOXYGEN_IGNORE)
public:
GuessConnectionOption() : Option() { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT IgnoreSpaceOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
IgnoreSpaceOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT InitCommandOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
InitCommandOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT InteractiveOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
InteractiveOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT LocalFilesOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
LocalFilesOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT LocalInfileOption : public IntegerOption
{
#if !defined(DOXYGEN_IGNORE)
public:
LocalInfileOption(ArgType arg) : IntegerOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT MultiResultsOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
MultiResultsOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT MultiStatementsOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
MultiStatementsOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT NamedPipeOption : public Option
{
#if !defined(DOXYGEN_IGNORE)
public:
NamedPipeOption() : Option() { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT NoSchemaOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
NoSchemaOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
#if MYSQL_VERSION_ID > 40000 // only in 4.0 +
class MYSQLPP_EXPORT ProtocolOption : public IntegerOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ProtocolOption(ArgType arg) : IntegerOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
#endif
class MYSQLPP_EXPORT ReadDefaultFileOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ReadDefaultFileOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT ReadDefaultGroupOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ReadDefaultGroupOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT ReadTimeoutOption : public IntegerOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ReadTimeoutOption(ArgType arg) : IntegerOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT ReconnectOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ReconnectOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT ReportDataTruncationOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
ReportDataTruncationOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT SecureAuthOption : public BooleanOption
{
#if !defined(DOXYGEN_IGNORE)
public:
SecureAuthOption(ArgType arg) : BooleanOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT SetCharsetDirOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
SetCharsetDirOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT SetCharsetNameOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
SetCharsetNameOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT SetClientIpOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
SetClientIpOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT SharedMemoryBaseNameOption : public StringOption
{
#if !defined(DOXYGEN_IGNORE)
public:
SharedMemoryBaseNameOption(ArgType arg) : StringOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT SslOption : public Option
{
public:
SslOption(const char* key = 0, const char* cert = 0,
const char* ca = 0, const char* capath = 0,
const char* cipher = 0)
{
if (key) key_.assign(key);
if (cert) cert_.assign(cert);
if (ca) ca_.assign(ca);
if (capath) capath_.assign(capath);
if (cipher) cipher_.assign(cipher);
}
private:
std::string key_, cert_, ca_, capath_, cipher_;
Error set(DBDriver* dbd);
};
class MYSQLPP_EXPORT UseEmbeddedConnectionOption : public Option
{
#if !defined(DOXYGEN_IGNORE)
public:
UseEmbeddedConnectionOption() : Option() { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT UseRemoteConnectionOption : public Option
{
#if !defined(DOXYGEN_IGNORE)
public:
UseRemoteConnectionOption() : Option() { }
private:
Error set(DBDriver* dbd);
#endif
};
class MYSQLPP_EXPORT WriteTimeoutOption : public IntegerOption
{
#if !defined(DOXYGEN_IGNORE)
public:
WriteTimeoutOption(ArgType arg) : IntegerOption(arg) { }
private:
Error set(DBDriver* dbd);
#endif
};
// Typedefs
typedef std::deque<Option*> OptionList;
typedef OptionList::const_iterator OptionListIt;
} // end namespace mysqlpp
#endif // !defined(MYSQLPP_OPTIONS_H)
mysqlpp::CompressOption
Enable data compression on the connection.
Definition: options.h:94
mysqlpp::ConnectTimeoutOption
Change Connection::connect() default timeout.
Definition: options.h:107
mysqlpp::DBDriver
Provides a thin abstraction layer over the underlying database client library.
Definition: dbdriver.h:58
mysqlpp::DataOption
Define abstract interface for all *Options that take a lone scalar as an argument.
Definition: options.h:78
mysqlpp::DataOption::ArgType
T ArgType
Alias for template param.
Definition: options.h:80
mysqlpp::DataOption::DataOption
DataOption(const T &arg)
Construct object.
Definition: options.h:83
mysqlpp::DataOption::arg_
T arg_
The argument value.
Definition: options.h:84
mysqlpp::FoundRowsOption
Make Query::affected_rows() return number of matched rows.
Definition: options.h:122
mysqlpp::GuessConnectionOption
Allow C API to guess what kind of connection to use.
Definition: options.h:138
mysqlpp::IgnoreSpaceOption
Allow spaces after function names in queries.
Definition: options.h:151
mysqlpp::InitCommandOption
Give SQL executed on connect.
Definition: options.h:164
mysqlpp::InteractiveOption
Assert that this is an interactive program.
Definition: options.h:179
mysqlpp::LocalFilesOption
Enable LOAD DATA LOCAL statement.
Definition: options.h:192
mysqlpp::LocalInfileOption
Enable LOAD LOCAL INFILE statement.
Definition: options.h:205
mysqlpp::MultiResultsOption
Enable multiple result sets in a reply.
Definition: options.h:218
mysqlpp::MultiStatementsOption
Enable multiple queries in a request to the server.
Definition: options.h:231
mysqlpp::NamedPipeOption
Suggest use of named pipes.
Definition: options.h:244
mysqlpp::NoSchemaOption
Disable db.tbl.col syntax in queries.
Definition: options.h:257
mysqlpp::Option
Define abstract interface for all *Option subclasses.
Definition: options.h:58
mysqlpp::Option::set
virtual Error set(DBDriver *dbd)=0
Apply option.
mysqlpp::Option::~Option
virtual ~Option()
Destroy object.
Definition: options.h:69
mysqlpp::Option::Error
Error
Types of option setting errors we can diagnose.
Definition: options.h:61
mysqlpp::Option::err_api_reject
@ err_api_reject
underlying C API returned error when setting option
Definition: options.h:64
mysqlpp::Option::err_NONE
@ err_NONE
option was set successfully
Definition: options.h:62
mysqlpp::Option::err_api_limit
@ err_api_limit
option not supported by underlying C API
Definition: options.h:63
mysqlpp::Option::err_connected
@ err_connected
can't set the given option while connected
Definition: options.h:65
mysqlpp::ReadDefaultFileOption
Override use of my.cnf.
Definition: options.h:285
mysqlpp::ReadDefaultGroupOption
Override use of my.cnf.
Definition: options.h:298
mysqlpp::ReadTimeoutOption
Set timeout for IPC data reads.
Definition: options.h:311
mysqlpp::ReconnectOption
Enable automatic reconnection to server.
Definition: options.h:324
mysqlpp::ReportDataTruncationOption
Set reporting of data truncation errors.
Definition: options.h:337
mysqlpp::SecureAuthOption
Enforce use of secure authentication, refusing connection if not available.
Definition: options.h:351
mysqlpp::SetCharsetDirOption
Give path to charset definition files.
Definition: options.h:364
mysqlpp::SetCharsetNameOption
Give name of default charset.
Definition: options.h:377
mysqlpp::SetClientIpOption
Fake client IP address when connecting to embedded server.
Definition: options.h:390
mysqlpp::SharedMemoryBaseNameOption
Set name of shmem segment for IPC.
Definition: options.h:403
mysqlpp::SslOption
Specialized option for handling SSL parameters.
Definition: options.h:416
mysqlpp::SslOption::SslOption
SslOption(const char *key=0, const char *cert=0, const char *ca=0, const char *capath=0, const char *cipher=0)
Create a set of SSL connection option parameters.
Definition: options.h:430
mysqlpp::UseEmbeddedConnectionOption
Connect to embedded server in preference to remote server.
Definition: options.h:449
mysqlpp::UseRemoteConnectionOption
Connect to remote server in preference to embedded server.
Definition: options.h:462
mysqlpp::WriteTimeoutOption
Set timeout for IPC data reads.
Definition: options.h:475
common.h
This file includes top-level definitions for use both internal to the library, and outside it....
mysqlpp::OptionList
std::deque< Option * > OptionList
The data type of the list of connection options.
Definition: options.h:490
mysqlpp::OptionListIt
OptionList::const_iterator OptionListIt
Primary iterator type into List.
Definition: options.h:493