Skip to content

Commit 1f49790

Browse files
authored
Replace boost::variant with std::variant
* Remove `boost-optional` and `boost-variant` dependencies from vcpkg.json * Replace boost::variant with std::variant
1 parent f7fcd50 commit 1f49790

11 files changed

Lines changed: 25 additions & 26 deletions

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_auth_method.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ class UserPasswordAuthMethod : public FlightSqlAuthMethod {
7777
FlightCallOptions auth_call_options;
7878
const std::optional<Connection::Attribute>& login_timeout =
7979
connection.GetAttribute(Connection::LOGIN_TIMEOUT);
80-
if (login_timeout && boost::get<uint32_t>(*login_timeout) > 0) {
80+
if (login_timeout && std::get<uint32_t>(*login_timeout) > 0) {
8181
// ODBC's LOGIN_TIMEOUT attribute and FlightCallOptions.timeout use
8282
// seconds as time unit.
83-
double timeout_seconds = static_cast<double>(boost::get<uint32_t>(*login_timeout));
83+
double timeout_seconds = static_cast<double>(std::get<uint32_t>(*login_timeout));
8484
if (timeout_seconds > 0) {
8585
auth_call_options.timeout = TimeoutDuration{timeout_seconds};
8686
}

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ const FlightCallOptions& FlightSqlConnection::PopulateCallOptions(
257257
// is the first request.
258258
const std::optional<Connection::Attribute>& connection_timeout =
259259
closed_ ? GetAttribute(LOGIN_TIMEOUT) : GetAttribute(CONNECTION_TIMEOUT);
260-
if (connection_timeout && boost::get<uint32_t>(*connection_timeout) > 0) {
260+
if (connection_timeout && std::get<uint32_t>(*connection_timeout) > 0) {
261261
call_options_.timeout =
262-
TimeoutDuration{static_cast<double>(boost::get<uint32_t>(*connection_timeout))};
262+
TimeoutDuration{static_cast<double>(std::get<uint32_t>(*connection_timeout))};
263263
}
264264

265265
for (auto prop : props) {
@@ -416,7 +416,7 @@ Connection::Info FlightSqlConnection::GetInfo(uint16_t info_type) {
416416
if (info_type == SQL_DBMS_NAME || info_type == SQL_SERVER_NAME) {
417417
// Update the database component reported in error messages.
418418
// We do this lazily for performance reasons.
419-
diagnostics_.SetDataSourceComponent(boost::get<std::string>(result));
419+
diagnostics_.SetDataSourceComponent(std::get<std::string>(result));
420420
}
421421
return result;
422422
}

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_connection_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ TEST(AttributeTests, SetAndGetAttribute) {
3838

3939
EXPECT_TRUE(first_value);
4040

41-
EXPECT_EQ(boost::get<uint32_t>(*first_value), static_cast<uint32_t>(200));
41+
EXPECT_EQ(std::get<uint32_t>(*first_value), static_cast<uint32_t>(200));
4242

4343
connection.SetAttribute(Connection::CONNECTION_TIMEOUT, static_cast<uint32_t>(300));
4444

4545
const std::optional<Connection::Attribute> change_value =
4646
connection.GetAttribute(Connection::CONNECTION_TIMEOUT);
4747

4848
EXPECT_TRUE(change_value);
49-
EXPECT_EQ(boost::get<uint32_t>(*change_value), static_cast<uint32_t>(300));
49+
EXPECT_EQ(std::get<uint32_t>(*change_value), static_cast<uint32_t>(300));
5050

5151
connection.Close();
5252
}
@@ -58,7 +58,7 @@ TEST(AttributeTests, GetAttributeWithoutSetting) {
5858
connection.GetAttribute(Connection::CONNECTION_TIMEOUT);
5959
connection.SetClosed(false);
6060

61-
EXPECT_EQ(0, boost::get<uint32_t>(*optional));
61+
EXPECT_EQ(0, std::get<uint32_t>(*optional));
6262

6363
connection.Close();
6464
}

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_statement.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ bool FlightSqlStatement::SetAttribute(StatementAttributeId attribute,
9696
case MAX_LENGTH:
9797
return CheckIfSetToOnlyValidValue(value, static_cast<size_t>(0));
9898
case QUERY_TIMEOUT:
99-
if (boost::get<size_t>(value) > 0) {
99+
if (std::get<size_t>(value) > 0) {
100100
call_options_.timeout =
101-
TimeoutDuration{static_cast<double>(boost::get<size_t>(value))};
101+
TimeoutDuration{static_cast<double>(std::get<size_t>(value))};
102102
} else {
103103
call_options_.timeout = TimeoutDuration{-1};
104104
// Intentional fall-through.

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_connection.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ SQLRETURN ODBCConnection::GetInfo(SQLUSMALLINT info_type, SQLPOINTER value,
259259
case SQL_SPECIAL_CHARACTERS:
260260
case SQL_XOPEN_CLI_YEAR: {
261261
const auto& info = spi_connection_->GetInfo(info_type);
262-
const std::string& info_value = boost::get<std::string>(info);
262+
const std::string& info_value = std::get<std::string>(info);
263263
return GetStringAttribute(is_unicode, info_value, true, value, buffer_length,
264264
output_length, GetDiagnostics());
265265
}
@@ -349,7 +349,7 @@ SQLRETURN ODBCConnection::GetInfo(SQLUSMALLINT info_type, SQLPOINTER value,
349349
case SQL_SQL92_VALUE_EXPRESSIONS:
350350
case SQL_STANDARD_CLI_CONFORMANCE: {
351351
const auto& info = spi_connection_->GetInfo(info_type);
352-
uint32_t info_value = boost::get<uint32_t>(info);
352+
uint32_t info_value = std::get<uint32_t>(info);
353353
GetAttribute(info_value, value, buffer_length, output_length);
354354
return SQL_SUCCESS;
355355
}
@@ -384,7 +384,7 @@ SQLRETURN ODBCConnection::GetInfo(SQLUSMALLINT info_type, SQLPOINTER value,
384384
case SQL_ODBC_SQL_CONFORMANCE:
385385
case SQL_ODBC_SAG_CLI_CONFORMANCE: {
386386
const auto& info = spi_connection_->GetInfo(info_type);
387-
uint16_t info_value = boost::get<uint16_t>(info);
387+
uint16_t info_value = std::get<uint16_t>(info);
388388
GetAttribute(info_value, value, buffer_length, output_length);
389389
return SQL_SUCCESS;
390390
}
@@ -395,7 +395,7 @@ SQLRETURN ODBCConnection::GetInfo(SQLUSMALLINT info_type, SQLPOINTER value,
395395
if (!attr) {
396396
throw DriverException("Optional feature not supported.", "HYC00");
397397
}
398-
const std::string& info_value = boost::get<std::string>(*attr);
398+
const std::string& info_value = std::get<std::string>(*attr);
399399
return GetStringAttribute(is_unicode, info_value, true, value, buffer_length,
400400
output_length, GetDiagnostics());
401401
}
@@ -591,7 +591,7 @@ SQLRETURN ODBCConnection::GetConnectAttr(SQLINTEGER attribute, SQLPOINTER value,
591591
if (!catalog) {
592592
throw DriverException("Optional feature not supported.", "HYC00");
593593
}
594-
const std::string& info_value = boost::get<std::string>(*catalog);
594+
const std::string& info_value = std::get<std::string>(*catalog);
595595
return GetStringAttribute(is_unicode, info_value, true, value, buffer_length,
596596
output_length, GetDiagnostics());
597597
}
@@ -620,7 +620,7 @@ SQLRETURN ODBCConnection::GetConnectAttr(SQLINTEGER attribute, SQLPOINTER value,
620620
throw DriverException("Invalid attribute", "HY092");
621621
}
622622

623-
GetAttribute(static_cast<SQLUINTEGER>(boost::get<uint32_t>(*spi_attribute)), value,
623+
GetAttribute(static_cast<SQLUINTEGER>(std::get<uint32_t>(*spi_attribute)), value,
624624
buffer_length, output_length);
625625
return SQL_SUCCESS;
626626
}

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_statement.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ void ODBCStatement::GetStmtAttr(SQLINTEGER statement_attribute, SQLPOINTER outpu
522522
}
523523

524524
if (spi_attribute) {
525-
GetAttribute(static_cast<SQLULEN>(boost::get<size_t>(*spi_attribute)), output,
525+
GetAttribute(static_cast<SQLULEN>(std::get<size_t>(*spi_attribute)), output,
526526
buffer_size, str_len_ptr);
527527
return;
528528
}

cpp/src/arrow/flight/sql/odbc/odbc_impl/spi/connection.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <map>
2424
#include <optional>
2525
#include <string>
26+
#include <variant>
2627
#include <vector>
2728

2829
#include "arrow/flight/sql/odbc/odbc_impl/diagnostics.h"
@@ -61,8 +62,8 @@ class Connection {
6162
PACKET_SIZE, // uint32_t - The Packet Size
6263
};
6364

64-
typedef boost::variant<std::string, void*, uint64_t, uint32_t> Attribute;
65-
typedef boost::variant<std::string, uint32_t, uint16_t> Info;
65+
typedef std::variant<std::string, void*, uint64_t, uint32_t> Attribute;
66+
typedef std::variant<std::string, uint32_t, uint16_t> Info;
6667
typedef PropertyMap ConnPropertyMap;
6768

6869
/// \brief Establish the connection.

cpp/src/arrow/flight/sql/odbc/odbc_impl/spi/statement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#pragma once
1919

20-
#include <boost/variant.hpp>
2120
#include <map>
2221
#include <optional>
22+
#include <variant>
2323
#include <vector>
2424

2525
namespace arrow::flight::sql::odbc {
@@ -51,7 +51,7 @@ class Statement {
5151
// have no timeout.
5252
};
5353

54-
typedef boost::variant<size_t> Attribute;
54+
typedef std::variant<size_t> Attribute;
5555

5656
/// \brief Set a statement attribute (may be called at any time)
5757
///

cpp/src/arrow/flight/sql/odbc/odbc_impl/ui/dsn_configuration_window.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ std::string TestConnection(
4646
// This should have been checked before enabling the Test button.
4747
assert(missing_properties.empty());
4848
std::string server_name =
49-
boost::get<std::string>(flight_sql_conn->GetInfo(SQL_SERVER_NAME));
49+
std::get<std::string>(flight_sql_conn->GetInfo(SQL_SERVER_NAME));
5050
std::string server_version =
51-
boost::get<std::string>(flight_sql_conn->GetInfo(SQL_DBMS_VER));
51+
std::get<std::string>(flight_sql_conn->GetInfo(SQL_DBMS_VER));
5252
return "Server Name: " + server_name + "\n" + "Server Version: " + server_version;
5353
}
5454
} // namespace

cpp/src/arrow/flight/sql/odbc/odbc_impl/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ inline void ThrowIfNotOK(const arrow::Status& status) {
4444

4545
template <typename T, typename AttributeTypeT>
4646
inline bool CheckIfSetToOnlyValidValue(const AttributeTypeT& value, T allowed_value) {
47-
return boost::get<T>(value) == allowed_value;
47+
return std::get<T>(value) == allowed_value;
4848
}
4949

5050
template <typename BUILDER, typename T>

0 commit comments

Comments
 (0)