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::UseRemoteConnectionOption
Connect to remote server in preference to embedded server.
Definition: options.h:461
mysqlpp::SslOption
Specialized option for handling SSL parameters.
Definition: options.h:415
mysqlpp::UseEmbeddedConnectionOption
Connect to embedded server in preference to remote server.
Definition: options.h:448
mysqlpp::SetCharsetNameOption
Give name of default charset.
Definition: options.h:376
mysqlpp::LocalFilesOption
Enable LOAD DATA LOCAL statement.
Definition: options.h:191
mysqlpp::Option::Error
Error
Types of option setting errors we can diagnose.
Definition: options.h:61
mysqlpp::Option::err_connected
can&#39;t set the given option while connected
Definition: options.h:65
mysqlpp::Option::~Option
virtual ~Option()
Destroy object.
Definition: options.h:69
mysqlpp::ReconnectOption
Enable automatic reconnection to server.
Definition: options.h:323
mysqlpp::DataOption::arg_
T arg_
The argument value.
Definition: options.h:84
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::SetClientIpOption
Fake client IP address when connecting to embedded server.
Definition: options.h:389
mysqlpp::LocalInfileOption
Enable LOAD LOCAL INFILE statement.
Definition: options.h:204
mysqlpp::SharedMemoryBaseNameOption
Set name of shmem segment for IPC.
Definition: options.h:402
mysqlpp::Option
Define abstract interface for all *Option subclasses.
Definition: options.h:57
mysqlpp::IgnoreSpaceOption
Allow spaces after function names in queries.
Definition: options.h:150
mysqlpp::NoSchemaOption
Disable db.tbl.col syntax in queries.
Definition: options.h:256
mysqlpp::DataOption::ArgType
T ArgType
Alias for template param.
Definition: options.h:80
mysqlpp::Option::err_NONE
option was set successfully
Definition: options.h:62
mysqlpp::GuessConnectionOption
Allow C API to guess what kind of connection to use.
Definition: options.h:137
mysqlpp::SecureAuthOption
Enforce use of secure authentication, refusing connection if not available.
Definition: options.h:350
mysqlpp::ConnectTimeoutOption
Change Connection::connect() default timeout.
Definition: options.h:106
mysqlpp::Option::err_api_reject
underlying C API returned error when setting option
Definition: options.h:64
mysqlpp::InteractiveOption
Assert that this is an interactive program.
Definition: options.h:178
mysqlpp::CompressOption
Enable data compression on the connection.
Definition: options.h:93
mysqlpp::Option::err_api_limit
option not supported by underlying C API
Definition: options.h:63
mysqlpp::ReadDefaultFileOption
Override use of my.cnf.
Definition: options.h:284
mysqlpp::FoundRowsOption
Make Query::affected_rows() return number of matched rows.
Definition: options.h:121
mysqlpp::MultiStatementsOption
Enable multiple queries in a request to the server.
Definition: options.h:230
mysqlpp::InitCommandOption
Give SQL executed on connect.
Definition: options.h:163
common.h
This file includes top-level definitions for use both internal to the library, and outside it...
mysqlpp::ReportDataTruncationOption
Set reporting of data truncation errors.
Definition: options.h:336
mysqlpp::SetCharsetDirOption
Give path to charset definition files.
Definition: options.h:363
mysqlpp::NamedPipeOption
Suggest use of named pipes.
Definition: options.h:243
mysqlpp::ReadDefaultGroupOption
Override use of my.cnf.
Definition: options.h:297
mysqlpp::WriteTimeoutOption
Set timeout for IPC data reads.
Definition: options.h:474
mysqlpp::DataOption
Define abstract interface for all *Options that take a lone scalar as an argument.
Definition: options.h:77
mysqlpp::MultiResultsOption
Enable multiple result sets in a reply.
Definition: options.h:217
mysqlpp::DBDriver
Provides a thin abstraction layer over the underlying database client library.
Definition: dbdriver.h:57
mysqlpp::ReadTimeoutOption
Set timeout for IPC data reads.
Definition: options.h:310
mysqlpp::DataOption::DataOption
DataOption(const T &arg)
Construct object.
Definition: options.h:83