Skip to content

Commit 709eb4d

Browse files
committed
Replaced boost with cpp17 things in sources + removed undef max because it was useless actually.
1 parent 4430b91 commit 709eb4d

File tree

9 files changed

+21
-22
lines changed

9 files changed

+21
-22
lines changed

include/cppkafka/configuration.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <functional>
3636
#include <initializer_list>
3737
#include <chrono>
38-
#include <boost/optional.hpp>
38+
#include <optional>
3939
#include <librdkafka/rdkafka.h>
4040
#include "topic_partition_list.h"
4141
#include "topic_configuration.h"
@@ -226,12 +226,12 @@ class CPPKAFKA_API Configuration : public ConfigurationBase<Configuration> {
226226
/**
227227
* Gets the default topic configuration
228228
*/
229-
const boost::optional<TopicConfiguration>& get_default_topic_configuration() const;
229+
const std::optional<TopicConfiguration>& get_default_topic_configuration() const;
230230

231231
/**
232232
* Gets the default topic configuration
233233
*/
234-
boost::optional<TopicConfiguration>& get_default_topic_configuration();
234+
std::optional<TopicConfiguration>& get_default_topic_configuration();
235235
private:
236236
using HandlePtr = ClonablePtr<rd_kafka_conf_t, decltype(&rd_kafka_conf_destroy),
237237
decltype(&rd_kafka_conf_dup)>;
@@ -240,7 +240,7 @@ class CPPKAFKA_API Configuration : public ConfigurationBase<Configuration> {
240240
static HandlePtr make_handle(rd_kafka_conf_t* ptr);
241241

242242
HandlePtr handle_;
243-
boost::optional<TopicConfiguration> default_topic_config_;
243+
std::optional<TopicConfiguration> default_topic_config_;
244244
DeliveryReportCallback delivery_report_callback_;
245245
OffsetCommitCallback offset_commit_callback_;
246246
ErrorCallback error_callback_;

include/cppkafka/message.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <cstdint>
3535
#include <chrono>
3636
#include <cassert>
37-
#include <boost/optional.hpp>
37+
#include <optional>
3838
#include <librdkafka/rdkafka.h>
3939
#include "buffer.h"
4040
#include "macros.h"
@@ -189,7 +189,7 @@ class CPPKAFKA_API Message {
189189
*
190190
* If calling rd_kafka_message_timestamp returns -1, then boost::none_t will be returned.
191191
*/
192-
boost::optional<MessageTimestamp> get_timestamp() const;
192+
std::optional<MessageTimestamp> get_timestamp() const;
193193

194194
#if RD_KAFKA_VERSION >= RD_KAFKA_MESSAGE_LATENCY_SUPPORT_VERSION
195195
/**

include/cppkafka/utils/compacted_topic_processor.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <string>
3535
#include <map>
3636
#include <set>
37-
#include <boost/optional.hpp>
37+
#include<optional>
3838
#include "../buffer.h"
3939
#include "../consumer.h"
4040
#include "../macros.h"
@@ -106,8 +106,8 @@ class CPPKAFKA_API CompactedTopicEvent {
106106
EventType type_;
107107
std::string topic_;
108108
int partition_;
109-
boost::optional<Key> key_;
110-
boost::optional<Value> value_;
109+
std::optional<Key> key_;
110+
std::optional<Value> value_;
111111
};
112112

113113
template <typename Key, typename Value>
@@ -121,12 +121,12 @@ class CPPKAFKA_API CompactedTopicProcessor {
121121
/**
122122
* Callback used for decoding key objects
123123
*/
124-
using KeyDecoder = std::function<boost::optional<Key>(const Buffer&)>;
124+
using KeyDecoder = std::function<std::optional<Key>(const Buffer&)>;
125125

126126
/**
127127
* Callback used for decoding value objects
128128
*/
129-
using ValueDecoder = std::function<boost::optional<Value>(const Key& key, const Buffer&)>;
129+
using ValueDecoder = std::function<std::optional<Value>(const Key& key, const Buffer&)>;
130130

131131
/**
132132
* Callback used for event handling
@@ -276,10 +276,10 @@ void CompactedTopicProcessor<Key, Value>::process_event() {
276276
Message message = consumer_.poll();
277277
if (message) {
278278
if (!message.get_error()) {
279-
boost::optional<Key> key = key_decoder_(message.get_key());
279+
std::optional<Key> key = key_decoder_(message.get_key());
280280
if (key) {
281281
if (message.get_payload()) {
282-
boost::optional<Value> value = value_decoder_(*key, message.get_payload());
282+
std::optional<Value> value = value_decoder_(*key, message.get_payload());
283283
if (value) {
284284
// If there's a payload and we managed to parse the value, generate a
285285
// SET_ELEMENT event

include/cppkafka/utils/poll_strategy_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define CPPKAFKA_POLL_STRATEGY_BASE_H
3232

3333
#include <map>
34-
#include <boost/any.hpp>
34+
#include <any>
3535
#include "../queue.h"
3636
#include "../topic_partition_list.h"
3737
#include "poll_interface.h"
@@ -45,7 +45,7 @@ namespace cppkafka {
4545
*/
4646
struct QueueData {
4747
Queue queue;
48-
boost::any metadata;
48+
std::any metadata;
4949
};
5050

5151
/**

src/configuration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using std::move;
4141
using std::vector;
4242
using std::initializer_list;
4343
using std::chrono::milliseconds;
44-
using boost::optional;
44+
using std::optional;
4545

4646
namespace cppkafka {
4747

src/message.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Message& Message::load_internal() {
8484
return *this;
8585
}
8686

87-
boost::optional<MessageTimestamp> Message::get_timestamp() const {
87+
std::optional<MessageTimestamp> Message::get_timestamp() const {
8888
rd_kafka_timestamp_type_t type = RD_KAFKA_TIMESTAMP_NOT_AVAILABLE;
8989
int64_t timestamp = rd_kafka_message_timestamp(handle_.get(), &type);
9090
if (timestamp == -1 || type == RD_KAFKA_TIMESTAMP_NOT_AVAILABLE) {

src/producer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void Producer::do_produce(const Message& message,
143143
const Buffer& payload = message.get_payload();
144144
const Buffer& key = message.get_key();
145145
const int policy = static_cast<int>(message_payload_policy_);
146-
int64_t duration = message.get_timestamp() ? message.get_timestamp().get().get_timestamp().count() : 0;
146+
int64_t duration = message.get_timestamp() ? message.get_timestamp().value().get_timestamp().count() : 0;
147147
auto result = rd_kafka_producev(get_handle(),
148148
RD_KAFKA_V_TOPIC(message.get_topic().data()),
149149
RD_KAFKA_V_PARTITION(message.get_partition()),

src/utils/backoff_performer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*
2828
*/
29-
#include "utils/backoff_performer.h"
30-
#undef max // solves the windows issue which prevents using std::numeric_limits<T>::max()
3129
#include <limits>
3230
#include <algorithm>
31+
#include "utils/backoff_performer.h"
3332

3433
using std::min;
3534
using std::numeric_limits;

src/utils/poll_strategy_base.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace cppkafka {
3636

3737
PollStrategyBase::PollStrategyBase(Consumer& consumer)
3838
: consumer_(consumer),
39-
consumer_queue_(QueueData{consumer.get_consumer_queue(), boost::any()}) {
39+
consumer_queue_(QueueData{consumer.get_consumer_queue(), std::any()}) {
4040
// get all currently active partition assignments
4141
TopicPartitionList assignment = consumer_.get_assignment();
4242
on_assignment(assignment);
@@ -93,7 +93,7 @@ void PollStrategyBase::assign(TopicPartitionList& partitions) {
9393
// populate partition queues
9494
for (const auto& partition : partitions) {
9595
// get the queue associated with this partition
96-
partition_queues_.emplace(partition, QueueData{consumer_.get_partition_queue(partition), boost::any()});
96+
partition_queues_.emplace(partition, QueueData{consumer_.get_partition_queue(partition), std::any()});
9797
}
9898
reset_state();
9999
}

0 commit comments

Comments
 (0)