diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-12-31 04:04:31 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-05-04 20:44:40 +0100 |
commit | db1e2f066393af3e58814417de5bbe7ea08a145d (patch) | |
tree | 9d01e48d8ef7d63fbcca6aced2461b3f1e234dfd /libmysqlpp/my-connection.cpp | |
parent | Beginnings of embbeded MySQL (diff) | |
download | libdbpp-mysql-db1e2f066393af3e58814417de5bbe7ea08a145d.tar.bz2 libdbpp-mysql-db1e2f066393af3e58814417de5bbe7ea08a145d.tar.xz libdbpp-mysql-db1e2f066393af3e58814417de5bbe7ea08a145d.zip |
Basics working, could do with a tidy up around mocking
Diffstat (limited to 'libmysqlpp/my-connection.cpp')
-rw-r--r-- | libmysqlpp/my-connection.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp index 04c1f8c..2be253b 100644 --- a/libmysqlpp/my-connection.cpp +++ b/libmysqlpp/my-connection.cpp @@ -2,6 +2,7 @@ #include "my-error.h" #include "my-selectcommand.h" #include "my-modifycommand.h" +#include "my-opts.h" #include <nvpParse.h> #include <runtimeContext.h> #include <ucontext.h> @@ -18,35 +19,15 @@ MySQL::ConnectionError::ConnectionError(MYSQL * m) : class Opts { public: Opts() { port = 3306; } - typedef boost::optional<std::string> OptString; - OptString server; - OptString user; - OptString password; - OptString database; + MySQL::OptString server; + MySQL::OptString user; + MySQL::OptString password; + MySQL::OptString database; unsigned int port; - OptString unix_socket; - OptString options; + MySQL::OptString unix_socket; + MySQL::OptString options; }; -const char * -operator~(const Opts::OptString & os) -{ - if (os) { - return os->c_str(); - } - return NULL; -} - -namespace std { - template <typename T> - std::istream & - operator>>(std::istream & s, boost::optional<T> & o) - { - o = T(); - return (s >> *o); - } -} - using namespace AdHoc; NvpTarget(Opts) OptsTargetMap { NvpValue(Opts, server), @@ -143,6 +124,14 @@ MySQL::Connection::newModifyCommand(const std::string & sql, const DB::CommandOp return new ModifyCommand(this, sql); } +void +MySQL::Connection::execute(const std::string & sql) +{ + if (mysql_query(&conn, sql.c_str())) { + throw Error(&conn); + } +} + namespace MySQL { class LoadContext : public AdHoc::System::RuntimeContext { public: |