Avoid MSVC warnings about truncating "int" to "short"

Switch to using the same "ub2" type as OCI uses for charset codes to
avoid warnings about implicitly truncating "int" to "ub2" when passing
charset parameters to various OCI functions.
This commit is contained in:
Vadim Zeitlin
2025-06-08 00:08:48 +02:00
parent 7ee9beadc4
commit 5d3e3acfc2
3 changed files with 7 additions and 7 deletions

View File

@@ -324,8 +324,8 @@ struct SOCI_ORACLE_DECL oracle_session_backend : details::session_backend
std::string const & password,
int mode,
bool decimals_as_strings = false,
int charset = 0,
int ncharset = 0);
ub2 charset = 0,
ub2 ncharset = 0);
~oracle_session_backend() override;

View File

@@ -25,12 +25,12 @@ using namespace soci;
using namespace soci::details;
// decode charset and ncharset names
int charset_code(const std::string & name)
static ub2 charset_code(const std::string & name)
{
// Note: unofficial reference for charset ids is:
// http://www.mydul.net/charsets.html
int code;
ub2 code;
if (name == "utf8")
{
@@ -96,13 +96,13 @@ oracle_session_backend * oracle_backend_factory::make_session(
decimals_as_strings = value == "1" || value == "Y" || value == "y";
}
int charset = 0;
ub2 charset = 0;
if (params.get_option("charset", value))
{
charset = charset_code(value);
}
int ncharset = 0;
ub2 ncharset = 0;
if (params.get_option("ncharset", value))
{
ncharset = charset_code(value);

View File

@@ -124,7 +124,7 @@ sb4 fo_callback(void * /* svchp */, void * /* envhp */, void * fo_ctx,
oracle_session_backend::oracle_session_backend(std::string const & serviceName,
std::string const & userName, std::string const & password, int mode,
bool decimals_as_strings, int charset, int ncharset)
bool decimals_as_strings, ub2 charset, ub2 ncharset)
: envhp_(NULL), srvhp_(NULL), errhp_(NULL), svchp_(NULL), usrhp_(NULL),
decimals_as_strings_(decimals_as_strings)
{