diff options
Diffstat (limited to 'libmysqlpp')
-rw-r--r-- | libmysqlpp/my-column.cpp | 4 | ||||
-rw-r--r-- | libmysqlpp/my-command.cpp | 16 | ||||
-rw-r--r-- | libmysqlpp/my-connection.cpp | 18 | ||||
-rw-r--r-- | libmysqlpp/my-error.cpp | 4 | ||||
-rw-r--r-- | libmysqlpp/my-error.h | 2 | ||||
-rw-r--r-- | libmysqlpp/my-modifycommand.cpp | 6 | ||||
-rw-r--r-- | libmysqlpp/my-modifycommand.h | 1 | ||||
-rw-r--r-- | libmysqlpp/my-selectcommand.cpp | 6 | ||||
-rw-r--r-- | libmysqlpp/unittests/testmysql.cpp | 6 |
9 files changed, 29 insertions, 34 deletions
diff --git a/libmysqlpp/my-column.cpp b/libmysqlpp/my-column.cpp index c5521c7..488538e 100644 --- a/libmysqlpp/my-column.cpp +++ b/libmysqlpp/my-column.cpp @@ -1,7 +1,7 @@ #include "my-column.h" #include "my-selectcommand.h" #include "my-error.h" -#include <string.h> +#include <cstring> #include <boost/date_time/gregorian/gregorian_types.hpp> MySQL::ColumnBase::ColumnBase(const char * name, unsigned int i) : @@ -48,7 +48,7 @@ MySQL::NullColumn::NullColumn(const char * name, unsigned int field, MYSQL_BIND { b->is_null = &is_null; b->buffer_type = MYSQL_TYPE_NULL; - b->buffer = NULL; + b->buffer = nullptr; b->buffer_length = 0; } diff --git a/libmysqlpp/my-command.cpp b/libmysqlpp/my-command.cpp index 4ad00fc..c296be4 100644 --- a/libmysqlpp/my-command.cpp +++ b/libmysqlpp/my-command.cpp @@ -1,7 +1,7 @@ #include "my-command.h" #include "my-connection.h" -#include <stdlib.h> -#include <string.h> +#include <cstdlib> +#include <cstring> MySQL::Command::Command(const Connection * conn, const std::string & sql) : DB::Command(sql), @@ -18,17 +18,17 @@ MySQL::Command::Command(const Connection * conn, const std::string & sql) : binds.resize(mysql_stmt_param_count(stmt)); if (binds.size()) { paramsNeedBinding = true; - for (Binds::iterator i = binds.begin(); i != binds.end(); ++i) { - memset(&*i, 0, sizeof(MYSQL_BIND)); - i->buffer_type = MYSQL_TYPE_NULL; + for (auto & b : binds) { + memset(&b, 0, sizeof(MYSQL_BIND)); + b.buffer_type = MYSQL_TYPE_NULL; } } } MySQL::Command::~Command() { - for (Binds::const_iterator i = binds.begin(); i != binds.end(); ++i) { - free(i->buffer); + for (auto & b : binds) { + free(b.buffer); } mysql_stmt_close(stmt); } @@ -162,7 +162,7 @@ void MySQL::Command::bindNull(unsigned int n) { binds[n].buffer_type = MYSQL_TYPE_NULL; - binds[n].buffer = NULL; + binds[n].buffer = nullptr; free(binds[n].buffer); } diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp index da3f3c6..8ab2d08 100644 --- a/libmysqlpp/my-connection.cpp +++ b/libmysqlpp/my-connection.cpp @@ -5,7 +5,7 @@ #include <nvpParse.h> #include <runtimeContext.h> #include <ucontext.h> -#include <boost/optional.hpp> +#include <optional> #include <compileTimeFormatter.h> NAMEDFACTORY("mysql", MySQL::Connection, DB::ConnectionFactory); @@ -18,7 +18,7 @@ MySQL::ConnectionError::ConnectionError(MYSQL * m) : class Opts { public: Opts() { port = 3306; } - typedef boost::optional<std::string> OptString; + using OptString = std::optional<std::string>; OptString server; OptString user; OptString password; @@ -34,13 +34,13 @@ operator~(const Opts::OptString & os) if (os) { return os->c_str(); } - return NULL; + return nullptr; } namespace std { template <typename T> std::istream & - operator>>(std::istream & s, boost::optional<T> & o) + operator>>(std::istream & s, std::optional<T> & o) { o = T(); return (s >> *o); @@ -68,8 +68,8 @@ MySQL::Connection::Connection(const std::string & str) if (o.options) { mysql_options(&conn, MYSQL_READ_DEFAULT_GROUP, ~o.options); } - if (mysql_real_connect(&conn, ~o.server, ~o.user, ~o.password, ~o.database, - o.port, ~o.unix_socket, CLIENT_LOCAL_FILES | CLIENT_MULTI_STATEMENTS) == NULL) { + if (!mysql_real_connect(&conn, ~o.server, ~o.user, ~o.password, ~o.database, + o.port, ~o.unix_socket, CLIENT_LOCAL_FILES | CLIENT_MULTI_STATEMENTS)) { throw ConnectionError(&conn); } if (mysql_set_character_set(&conn, "utf8")) { @@ -143,7 +143,7 @@ namespace MySQL { class LoadContext : public AdHoc::System::RuntimeContext { public: LoadContext(MYSQL * c) : - loadBuf(NULL), + loadBuf(nullptr), loadBufLen(0), bufOff(0), conn(c) @@ -156,7 +156,7 @@ namespace MySQL { } static int local_infile_read(void * obj, char * buf, unsigned int bufSize) { - LoadContext * ctx = static_cast<LoadContext *>(obj); + auto ctx = static_cast<LoadContext *>(obj); if (ctx->loadBufLen - ctx->bufOff == 0) { ctx->swapContext(); if (ctx->loadBufLen - ctx->bufOff <= 0) { @@ -208,7 +208,7 @@ MySQL::Connection::beginBulkUpload(const char * table, const char * extra) void MySQL::Connection::endBulkUpload(const char * msg) { - ctx->loadBuf = NULL; + ctx->loadBuf = nullptr; ctx->loadBufLen = 0; ctx->bufOff = msg ? -1 : 0; // switch context with empty buffer fires finished diff --git a/libmysqlpp/my-error.cpp b/libmysqlpp/my-error.cpp index 4867e0d..f563236 100644 --- a/libmysqlpp/my-error.cpp +++ b/libmysqlpp/my-error.cpp @@ -1,5 +1,5 @@ #include "my-error.h" -#include <string.h> +#include <cstring> MySQL::Error::Error(MYSQL * m) : msg(mysql_error(m)) @@ -12,7 +12,7 @@ MySQL::Error::Error(MYSQL_STMT * m) : } std::string -MySQL::Error::message() const throw() +MySQL::Error::message() const noexcept { return msg; } diff --git a/libmysqlpp/my-error.h b/libmysqlpp/my-error.h index b694843..d1dbe68 100644 --- a/libmysqlpp/my-error.h +++ b/libmysqlpp/my-error.h @@ -10,7 +10,7 @@ namespace MySQL { public: Error(MYSQL_STMT *); Error(MYSQL *); - std::string message() const throw() override; + std::string message() const noexcept override; private: std::string msg; diff --git a/libmysqlpp/my-modifycommand.cpp b/libmysqlpp/my-modifycommand.cpp index 9326afe..083603f 100644 --- a/libmysqlpp/my-modifycommand.cpp +++ b/libmysqlpp/my-modifycommand.cpp @@ -1,6 +1,6 @@ #include "my-modifycommand.h" #include "my-error.h" -#include <stdlib.h> +#include <cstdlib> #include "connection.h" MySQL::ModifyCommand::ModifyCommand(const Connection * conn, const std::string & sql) : @@ -10,10 +10,6 @@ MySQL::ModifyCommand::ModifyCommand(const Connection * conn, const std::string & { } -MySQL::ModifyCommand::~ModifyCommand() -{ -} - unsigned int MySQL::ModifyCommand::execute(bool anc) { diff --git a/libmysqlpp/my-modifycommand.h b/libmysqlpp/my-modifycommand.h index 0f635cd..d760f93 100644 --- a/libmysqlpp/my-modifycommand.h +++ b/libmysqlpp/my-modifycommand.h @@ -9,7 +9,6 @@ namespace MySQL { class ModifyCommand : public DB::ModifyCommand, public Command { public: ModifyCommand(const Connection *, const std::string & sql); - virtual ~ModifyCommand(); unsigned int execute(bool) override; diff --git a/libmysqlpp/my-selectcommand.cpp b/libmysqlpp/my-selectcommand.cpp index 596c9a0..893f79f 100644 --- a/libmysqlpp/my-selectcommand.cpp +++ b/libmysqlpp/my-selectcommand.cpp @@ -2,7 +2,7 @@ #include "my-connection.h" #include "my-column.h" #include "my-error.h" -#include <string.h> +#include <cstring> MySQL::SelectCommand::SelectCommand(const Connection * conn, const std::string & sql) : DB::Command(sql), @@ -19,8 +19,8 @@ MySQL::SelectCommand::execute() if (!prepared) { bindParams(); fields.resize(mysql_stmt_field_count(stmt)); - for (Binds::iterator i = fields.begin(); i != fields.end(); ++i) { - memset(&*i, 0, sizeof(MYSQL_BIND)); + for (auto & b : fields) { + memset(&b, 0, sizeof(MYSQL_BIND)); } MYSQL_RES * prepare_meta_result = mysql_stmt_result_metadata(stmt); MYSQL_FIELD * fieldDefs = mysql_fetch_fields(prepare_meta_result); diff --git a/libmysqlpp/unittests/testmysql.cpp b/libmysqlpp/unittests/testmysql.cpp index 434ce40..ca4cbc0 100644 --- a/libmysqlpp/unittests/testmysql.cpp +++ b/libmysqlpp/unittests/testmysql.cpp @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE( bindAndSelectOther ) assertColumnValueHelper(*select, 1, 123.45); assertColumnValueHelper(*select, 2, std::string_view("some text")); assertColumnValueHelper(*select, 3, true); - assertColumnValueHelper(*select, 4, boost::posix_time::ptime_from_tm({ 3, 6, 23, 27, 3, 115, 0, 0, 0, 0, 0})); + assertColumnValueHelper(*select, 4, boost::posix_time::ptime_from_tm({ 3, 6, 23, 27, 3, 115, 0, 0, 0, 0, nullptr})); assertColumnValueHelper(*select, 5, boost::posix_time::time_duration(38, 13, 12)); rows += 1; } @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE( bulkload ) auto count = ro->select("SELECT COUNT(*) FROM bulktest"); // Test empty ro->beginBulkUpload("bulktest", ""); - ro->endBulkUpload(NULL); + ro->endBulkUpload(nullptr); assertScalarValueHelper(*count, 0); // Test sample file ro->beginBulkUpload("bulktest", ""); @@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE( bulkload ) for (std::streamsize r; (r = in.readsome(buf, sizeof(buf))) > 0; ) { ro->bulkUploadData(buf, r); } - ro->endBulkUpload(NULL); + ro->endBulkUpload(nullptr); assertScalarValueHelper(*count, 800); } |