Skip to content

Commit 1e8d4dc

Browse files
style: reformat with clang-format-22
clang-format 22 changed line-break heuristics; CI's "Check C++ style" job caught the drift. Reformat the affected files (BasicStringBinder.hpp, SqlVariant.cpp, SqlError.cpp, SqlOdbcWide.hpp, SqlScopedTraceLogger.hpp, DataBinderTests.cpp, Utils.hpp) to match the version pinned in CI. Signed-off-by: Christian Parpart <christian@parpart.family>
1 parent 84864b3 commit 1e8d4dc

7 files changed

Lines changed: 21 additions & 35 deletions

File tree

src/Lightweight/DataBinder/BasicStringBinder.hpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ namespace detail
157157
{
158158
if (*indicator != SQL_NULL_DATA && *indicator != SQL_NO_TOTAL)
159159
{
160-
auto const syntheticIndicator =
161-
static_cast<SQLLEN>(StringTraits::Size(result) * sizeof(CharType));
160+
auto const syntheticIndicator = static_cast<SQLLEN>(StringTraits::Size(result) * sizeof(CharType));
162161
StringTraits::PostProcessOutputColumn(result, syntheticIndicator);
163162
}
164163
}
@@ -201,9 +200,8 @@ struct SqlDataBinder<AnsiStringType>
201200
// call path in the library produces (file readers, query formatters, etc.).
202201
if (cb.ServerType() == SqlServerType::POSTGRESQL)
203202
{
204-
auto u16String = std::make_shared<std::u16string>(
205-
ToUtf16(std::u8string_view { reinterpret_cast<char8_t const*>(StringTraits::Data(&value)),
206-
StringTraits::Size(&value) }));
203+
auto u16String = std::make_shared<std::u16string>(ToUtf16(std::u8string_view {
204+
reinterpret_cast<char8_t const*>(StringTraits::Data(&value)), StringTraits::Size(&value) }));
207205
cb.PlanPostExecuteCallback([u16String = u16String]() {}); // keep buffer alive
208206
auto const charCount = u16String->size();
209207
auto const byteCount = charCount * sizeof(char16_t);
@@ -440,8 +438,7 @@ struct SqlDataBinder<Utf16StringType>
440438
auto const* data = StringTraits::Data(&value);
441439
auto const sizeInBytes = StringTraits::Size(&value) * sizeof(CharType);
442440
auto const charCount = StringTraits::Size(&value);
443-
auto const sqlType =
444-
static_cast<SQLSMALLINT>(charCount > SqlOptimalMaxColumnSize ? SQL_WLONGVARCHAR : SQL_WVARCHAR);
441+
auto const sqlType = static_cast<SQLSMALLINT>(charCount > SqlOptimalMaxColumnSize ? SQL_WLONGVARCHAR : SQL_WVARCHAR);
445442

446443
SQLLEN* indicator = cb.ProvideInputIndicator();
447444
*indicator = static_cast<SQLLEN>(sizeInBytes);
@@ -538,15 +535,13 @@ struct SqlDataBinder<Utf32StringType>
538535
{
539536
// Always go via UTF-16 + SQL_C_WCHAR; the driver handles encoding conversion
540537
// for the target server.
541-
auto u16String =
542-
std::make_shared<std::u16string>(ToUtf16(detail::SqlViewHelper<Utf32StringType>::View(value)));
538+
auto u16String = std::make_shared<std::u16string>(ToUtf16(detail::SqlViewHelper<Utf32StringType>::View(value)));
543539
cb.PlanPostExecuteCallback([u16String = u16String]() {}); // Keep the string alive
544540
auto const* data = u16String->data();
545541
auto const charCount = u16String->size();
546542
auto const sizeInBytes = u16String->size() * sizeof(char16_t);
547543
auto const CType = SQLSMALLINT { SQL_C_WCHAR };
548-
auto const sqlType =
549-
static_cast<SQLSMALLINT>(charCount > SqlOptimalMaxColumnSize ? SQL_WLONGVARCHAR : SQL_WVARCHAR);
544+
auto const sqlType = static_cast<SQLSMALLINT>(charCount > SqlOptimalMaxColumnSize ? SQL_WLONGVARCHAR : SQL_WVARCHAR);
550545

551546
SQLLEN* indicator = cb.ProvideInputIndicator();
552547
*indicator = static_cast<SQLLEN>(sizeInBytes);
@@ -612,15 +607,13 @@ struct SqlDataBinder<Utf8StringType>
612607
{
613608
// Always go via UTF-16 + SQL_C_WCHAR; the driver handles encoding conversion
614609
// for the target server.
615-
auto u16String =
616-
std::make_shared<std::u16string>(ToUtf16(detail::SqlViewHelper<Utf8StringType>::View(value)));
610+
auto u16String = std::make_shared<std::u16string>(ToUtf16(detail::SqlViewHelper<Utf8StringType>::View(value)));
617611
cb.PlanPostExecuteCallback([u16String = u16String]() {}); // Keep the string alive
618612

619613
auto const CType = SQL_C_WCHAR;
620614
auto const charCount = u16String->size();
621615
auto const byteCount = u16String->size() * sizeof(char16_t);
622-
auto const sqlType =
623-
static_cast<SQLSMALLINT>(charCount > SqlOptimalMaxColumnSize ? SQL_WLONGVARCHAR : SQL_WVARCHAR);
616+
auto const sqlType = static_cast<SQLSMALLINT>(charCount > SqlOptimalMaxColumnSize ? SQL_WLONGVARCHAR : SQL_WVARCHAR);
624617

625618
SQLLEN* indicator = cb.ProvideInputIndicator();
626619
*indicator = static_cast<SQLLEN>(byteCount);

src/Lightweight/DataBinder/SqlVariant.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ SQLRETURN SqlDataBinder<SqlVariant>::GetColumn(
2525
// Use the W variant — the call passes nullptr for the string buffer (we only fetch
2626
// the numeric SQL_DESC_TYPE), so it's a near-pure rename, but it keeps the entire
2727
// ODBC call surface on the Unicode-app path the rest of the library is using.
28-
SQLRETURN returnCode =
29-
SQLColAttributeW(stmt, column, SQL_DESC_TYPE, nullptr, 0, nullptr, &columnType);
28+
SQLRETURN returnCode = SQLColAttributeW(stmt, column, SQL_DESC_TYPE, nullptr, 0, nullptr, &columnType);
3029
if (!SQL_SUCCEEDED(returnCode))
3130
return returnCode;
3231

src/Lightweight/SqlError.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SqlErrorInfo SqlErrorInfo::FromHandle(SQLSMALLINT handleType, SQLHANDLE handle)
3737
{
3838
SqlErrorInfo info {};
3939

40-
constexpr SQLSMALLINT SqlStateLen = 6; // 5 SQLSTATE chars + NUL
40+
constexpr SQLSMALLINT SqlStateLen = 6; // 5 SQLSTATE chars + NUL
4141
constexpr SQLSMALLINT MessageBufferLen = 1024;
4242
std::array<SQLWCHAR, SqlStateLen> sqlStateBuffer {};
4343
std::array<SQLWCHAR, MessageBufferLen> messageBuffer {};
@@ -57,14 +57,14 @@ SqlErrorInfo SqlErrorInfo::FromHandle(SQLSMALLINT handleType, SQLHANDLE handle)
5757
// The SQLWCHAR ↔ char16_t layout invariant lives in SqlOdbcWide.hpp; the buffers
5858
// we just filled are reinterpretable as char16_t under that same assumption.
5959
auto const sqlStateChars = static_cast<size_t>(SqlStateLen - 1); // SQLSTATE is exactly 5 chars
60-
auto const sqlStateUtf8 = ToUtf8(std::u16string_view {
61-
reinterpret_cast<char16_t const*>(sqlStateBuffer.data()), sqlStateChars });
60+
auto const sqlStateUtf8 =
61+
ToUtf8(std::u16string_view { reinterpret_cast<char16_t const*>(sqlStateBuffer.data()), sqlStateChars });
6262
info.sqlState.assign(reinterpret_cast<char const*>(sqlStateUtf8.data()), sqlStateUtf8.size());
6363

6464
auto const messageChars =
6565
msgLen > 0 ? std::min(static_cast<SQLSMALLINT>(MessageBufferLen - 1), msgLen) : SQLSMALLINT { 0 };
66-
auto const messageUtf8 = ToUtf8(std::u16string_view {
67-
reinterpret_cast<char16_t const*>(messageBuffer.data()), static_cast<size_t>(messageChars) });
66+
auto const messageUtf8 = ToUtf8(
67+
std::u16string_view { reinterpret_cast<char16_t const*>(messageBuffer.data()), static_cast<size_t>(messageChars) });
6868
info.message.assign(reinterpret_cast<char const*>(messageUtf8.data()), messageUtf8.size());
6969

7070
return info;

src/Lightweight/SqlOdbcWide.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ namespace Lightweight::detail
1616
// ODBC W variants assume `SQLWCHAR` is layout-compatible with `char16_t` (true on
1717
// Windows where it's `wchar_t`, and on Linux unixODBC where it's `unsigned short` —
1818
// both 16-bit). Anything else and the reinterpret_casts below would silently corrupt.
19-
static_assert(sizeof(SQLWCHAR) == sizeof(char16_t),
20-
"ODBC W variants require a 16-bit code unit; SQLWCHAR shape mismatch");
19+
static_assert(sizeof(SQLWCHAR) == sizeof(char16_t), "ODBC W variants require a 16-bit code unit; SQLWCHAR shape mismatch");
2120

2221
/// @brief Converts a UTF-8 string view into a `std::u16string` for ODBC W variants.
2322
/// Use this rather than `ToUtf16(std::string const&)` from `UnicodeConverter.hpp`:

src/Lightweight/SqlScopedTraceLogger.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ class LIGHTWEIGHT_API SqlScopedTraceLogger
5555
// unnecessarily. `path::u16string()` does the platform-correct conversion (UTF-16
5656
// is path's native form on Windows; UTF-8 → UTF-16 on POSIX).
5757
auto wLogFile = logFile.u16string();
58-
SQLSetConnectAttrW(
59-
m_nativeConnection, SQL_ATTR_TRACEFILE, detail::AsSqlWChar(wLogFile.data()), SQL_NTS);
58+
SQLSetConnectAttrW(m_nativeConnection, SQL_ATTR_TRACEFILE, detail::AsSqlWChar(wLogFile.data()), SQL_NTS);
6059
SQLSetConnectAttrW(m_nativeConnection, SQL_ATTR_TRACE, (SQLPOINTER) SQL_OPT_TRACE_ON, SQL_IS_UINTEGER);
6160
}
6261

src/tests/DataBinderTests.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,9 +1409,7 @@ struct UnicodeAcrossDynamicStringTypes
14091409
Field<SqlDynamicWideString<256>> stringWide {};
14101410
};
14111411

1412-
TEST_CASE_METHOD(SqlTestFixture,
1413-
"Unicode round-trip across DataMapper dynamic string types",
1414-
"[DataMapper][Unicode]")
1412+
TEST_CASE_METHOD(SqlTestFixture, "Unicode round-trip across DataMapper dynamic string types", "[DataMapper][Unicode]")
14151413
{
14161414
auto dm = DataMapper {};
14171415
dm.CreateTable<UnicodeAcrossDynamicStringTypes>();
@@ -1436,9 +1434,7 @@ struct UnicodeTrimmedFixedRow
14361434
Field<SqlTrimmedWideFixedString<32>> stringWide {};
14371435
};
14381436

1439-
TEST_CASE_METHOD(SqlTestFixture,
1440-
"Trimmed fixed strings strip trailing padding through DataMapper",
1441-
"[DataMapper][Unicode]")
1437+
TEST_CASE_METHOD(SqlTestFixture, "Trimmed fixed strings strip trailing padding through DataMapper", "[DataMapper][Unicode]")
14421438
{
14431439
auto dm = DataMapper {};
14441440
dm.CreateTable<UnicodeTrimmedFixedRow>();

src/tests/Utils.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
#pragma once
44

55
#if defined(_WIN32) || defined(_WIN64)
6+
#include <cstdlib>
7+
68
#include <Windows.h>
79
#include <crtdbg.h>
8-
#include <cstdlib>
910
#endif
1011

1112
#include <Lightweight/Lightweight.hpp>
@@ -535,8 +536,7 @@ class SqlTestFixture
535536
auto wTraceFile = std::u16string { u"CONOUT$" };
536537
#endif
537538
SQLHDBC handle = connection.NativeHandle();
538-
SQLSetConnectAttrW(
539-
handle, SQL_ATTR_TRACEFILE, Lightweight::detail::AsSqlWChar(wTraceFile.data()), SQL_NTS);
539+
SQLSetConnectAttrW(handle, SQL_ATTR_TRACEFILE, Lightweight::detail::AsSqlWChar(wTraceFile.data()), SQL_NTS);
540540
SQLSetConnectAttrW(handle, SQL_ATTR_TRACE, (SQLPOINTER) SQL_OPT_TRACE_ON, SQL_IS_UINTEGER);
541541
}
542542

0 commit comments

Comments
 (0)