mirror of
https://github.com/SOCI/soci.git
synced 2026-05-12 22:59:05 -05:00
@@ -121,6 +121,7 @@ jobs:
|
||||
backend: Valgrind
|
||||
runner: ubuntu-24.04
|
||||
name: Valgrind
|
||||
cxxstd: 20
|
||||
- lib_type: shared
|
||||
backend: MySQL
|
||||
runner: ubuntu-24.04
|
||||
|
||||
@@ -22,6 +22,12 @@ class SOCI_DECL soci_error : public std::runtime_error
|
||||
public:
|
||||
explicit soci_error(std::string const & msg);
|
||||
|
||||
// Provide a simple way to construct the message from a format (using fmt
|
||||
// syntax, i.e. with {} placeholders) and one argument of the given type.
|
||||
soci_error(char const* format, std::string const& arg);
|
||||
soci_error(char const* format, int arg);
|
||||
soci_error(char const* format, size_t arg);
|
||||
|
||||
soci_error(soci_error const& e) noexcept;
|
||||
soci_error& operator=(soci_error const& e) noexcept;
|
||||
|
||||
@@ -71,7 +77,7 @@ public:
|
||||
|
||||
private:
|
||||
// Optional extra information (currently just the context data).
|
||||
class soci_error_extra_info* info_;
|
||||
class soci_error_extra_info* info_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace soci
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// Copyright (C) 2026 Vadim Zeitlin
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef SOCI_FMT_H_INCLUDED
|
||||
#define SOCI_FMT_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace soci
|
||||
{
|
||||
|
||||
// Export a couple of overloads of format() used in public headers to allow
|
||||
// using them there without requiring including fmt headers.
|
||||
std::string SOCI_DECL format(const char* fmt, std::string const& arg);
|
||||
std::string SOCI_DECL format(const char* fmt, int arg);
|
||||
std::string SOCI_DECL format(const char* fmt, size_t arg);
|
||||
|
||||
} // namespace soci
|
||||
|
||||
#endif // SOCI_FMT_H_INCLUDED
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "soci/blob.h"
|
||||
#include "soci/error.h"
|
||||
#include "soci/fmt.h"
|
||||
#include "soci/soci-backend.h"
|
||||
#include "soci/soci-types.h"
|
||||
|
||||
@@ -486,7 +485,7 @@ private:
|
||||
}
|
||||
|
||||
// This should be unreachable
|
||||
throw soci_error(format("Created holder with unsupported type {}", static_cast<int>(dt)));
|
||||
throw soci_error("Created holder with unsupported type {}", static_cast<int>(dt));
|
||||
}
|
||||
|
||||
const db_type dt_;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "soci/statement.h"
|
||||
#include "soci/into-type.h"
|
||||
#include "soci/use-type.h"
|
||||
#include "soci/fmt.h"
|
||||
// std
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
@@ -67,7 +66,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
throw soci_error(format("Column at position {} contains NULL value and no default was provided", pos));
|
||||
throw soci_error("Column at position {} contains NULL value and no default was provided", pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
throw soci_error(format("Column at position {} contains NULL value and no default was provided", currentPos_));
|
||||
throw soci_error("Column at position {} contains NULL value and no default was provided", currentPos_);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -290,7 +289,7 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
throw soci_error(format("Value at position {} was set using a different type than the one passed to get()", pos));
|
||||
throw soci_error("Value at position {} was set using a different type than the one passed to get()", pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ target_sources(soci_core
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/error.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/exchange-traits.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/fixed-size-ints.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/fmt.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/into-type.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/into.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/soci/is-detected.h"
|
||||
|
||||
@@ -7,14 +7,11 @@
|
||||
//
|
||||
|
||||
#include "soci/error.h"
|
||||
#include "soci/fmt.h"
|
||||
#include "soci-mktime.h"
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace // anonymous
|
||||
{
|
||||
|
||||
@@ -140,18 +137,3 @@ time_t soci::details::timegm_impl_soci ( struct tm* tb )
|
||||
|
||||
return since_epoch;
|
||||
}
|
||||
|
||||
std::string soci::format(const char* fmt, std::string const& arg)
|
||||
{
|
||||
return fmt::format(fmt, arg);
|
||||
}
|
||||
|
||||
std::string soci::format(const char* fmt, int arg)
|
||||
{
|
||||
return fmt::format(fmt, arg);
|
||||
}
|
||||
|
||||
std::string soci::format(const char* fmt, size_t arg)
|
||||
{
|
||||
return fmt::format(fmt, arg);
|
||||
}
|
||||
|
||||
+17
-1
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace soci
|
||||
{
|
||||
|
||||
@@ -95,7 +97,21 @@ soci_error_extra_info *make_safe_copy(soci_error_extra_info* info)
|
||||
soci_error::soci_error(std::string const & msg)
|
||||
: std::runtime_error(msg)
|
||||
{
|
||||
info_ = nullptr;
|
||||
}
|
||||
|
||||
soci_error::soci_error(char const* format, std::string const& arg)
|
||||
: std::runtime_error(fmt::vformat(format, fmt::make_format_args(arg)))
|
||||
{
|
||||
}
|
||||
|
||||
soci_error::soci_error(char const* format, int arg)
|
||||
: std::runtime_error(fmt::vformat(format, fmt::make_format_args(arg)))
|
||||
{
|
||||
}
|
||||
|
||||
soci_error::soci_error(char const* format, size_t arg)
|
||||
: std::runtime_error(fmt::vformat(format, fmt::make_format_args(arg)))
|
||||
{
|
||||
}
|
||||
|
||||
soci_error::soci_error(soci_error const& e) noexcept
|
||||
|
||||
Reference in New Issue
Block a user