From d77f801dc01c5e30c0d96e907c8ac14f23d7b630 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 18 Nov 2020 16:54:48 +0000 Subject: Clang format --- libmysqlpp/my-connection.cpp | 136 +++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 69 deletions(-) (limited to 'libmysqlpp/my-connection.cpp') diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp index 63f4932..6e4d1a1 100644 --- a/libmysqlpp/my-connection.cpp +++ b/libmysqlpp/my-connection.cpp @@ -1,31 +1,31 @@ #include "my-connection.h" #include "my-error.h" -#include "my-selectcommand.h" #include "my-modifycommand.h" +#include "my-selectcommand.h" +#include #include +#include #include #include -#include -#include NAMEDFACTORY("mysql", MySQL::Connection, DB::ConnectionFactory); -MySQL::ConnectionError::ConnectionError(MYSQL * m) : - MySQL::Error(m) -{ -} +MySQL::ConnectionError::ConnectionError(MYSQL * m) : MySQL::Error(m) { } class Opts { - public: - Opts() { port = 3306; } - using OptString = std::optional; - OptString server; - OptString user; - OptString password; - OptString database; - unsigned int port; - OptString unix_socket; - OptString options; +public: + Opts() + { + port = 3306; + } + using OptString = std::optional; + OptString server; + OptString user; + OptString password; + OptString database; + unsigned int port; + OptString unix_socket; + OptString options; }; const char * @@ -38,7 +38,7 @@ operator~(const Opts::OptString & os) } namespace std { - template + template std::istream & operator>>(std::istream & s, std::optional & o) { @@ -49,18 +49,16 @@ namespace std { using namespace AdHoc; NvpTarget(Opts) OptsTargetMap { - NvpValue(Opts, server), - NvpValue(Opts, user), - NvpValue(Opts, password), - NvpValue(Opts, database), - NvpValue(Opts, unix_socket), - NvpValue(Opts, port), - NvpValue(Opts, options), + NvpValue(Opts, server), + NvpValue(Opts, user), + NvpValue(Opts, password), + NvpValue(Opts, database), + NvpValue(Opts, unix_socket), + NvpValue(Opts, port), + NvpValue(Opts, options), }; - -MySQL::Connection::Connection(const std::string & str) : - conn({}) +MySQL::Connection::Connection(const std::string & str) : conn({}) { std::stringstream i(str); Opts o; @@ -128,7 +126,6 @@ MySQL::Connection::ping() const } } - DB::SelectCommandPtr MySQL::Connection::select(const std::string & sql, const DB::CommandOptionsCPtr &) { @@ -143,53 +140,55 @@ MySQL::Connection::modify(const std::string & sql, const DB::CommandOptionsCPtr namespace MySQL { class LoadContext : public AdHoc::System::RuntimeContext { - public: - explicit LoadContext(MYSQL * c) : - loadBuf(nullptr), - loadBufLen(0), - bufOff(0), - conn(c), - loadReturn(0) - { - } + public: + explicit LoadContext(MYSQL * c) : loadBuf(nullptr), loadBufLen(0), bufOff(0), conn(c), loadReturn(0) { } - static int local_infile_init(void ** ptr, const char *, void * ctx) { - *ptr = ctx; - return 0; - } + static int + local_infile_init(void ** ptr, const char *, void * ctx) + { + *ptr = ctx; + return 0; + } - static int local_infile_read(void * obj, char * buf, unsigned int bufSize) { - auto ctx = static_cast(obj); - if (ctx->loadBufLen - ctx->bufOff == 0) { - ctx->swapContext(); - if (ctx->loadBufLen - ctx->bufOff <= 0) { - // Nothing to do or error - return ctx->bufOff; - } + static int + local_infile_read(void * obj, char * buf, unsigned int bufSize) + { + auto ctx = static_cast(obj); + if (ctx->loadBufLen - ctx->bufOff == 0) { + ctx->swapContext(); + if (ctx->loadBufLen - ctx->bufOff <= 0) { + // Nothing to do or error + return ctx->bufOff; } - auto copy = std::min(ctx->loadBufLen - ctx->bufOff, bufSize); - memcpy(buf, ctx->loadBuf + ctx->bufOff, copy); - ctx->bufOff += copy; - return copy; } + auto copy = std::min(ctx->loadBufLen - ctx->bufOff, bufSize); + memcpy(buf, ctx->loadBuf + ctx->bufOff, copy); + ctx->bufOff += copy; + return copy; + } - static void local_infile_end(void *) { - } + static void + local_infile_end(void *) + { + } - static int local_infile_error(void *, char*, unsigned int) { - return 0; - } + static int + local_infile_error(void *, char *, unsigned int) + { + return 0; + } - void callback() override - { - loadReturn = mysql_read_query_result(conn); - } + void + callback() override + { + loadReturn = mysql_read_query_result(conn); + } - const char * loadBuf; - size_t loadBufLen; - size_t bufOff; - MYSQL * conn; - int loadReturn; + const char * loadBuf; + size_t loadBufLen; + size_t bufOff; + MYSQL * conn; + int loadReturn; }; } @@ -242,4 +241,3 @@ MySQL::Connection::insertId() { return mysql_insert_id(&conn); } - -- cgit v1.2.3