mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-01 11:07:56 +00:00
Add TopicPartition::operator<
This commit is contained in:
@@ -112,6 +112,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void set_offset(int64_t offset);
|
void set_offset(int64_t offset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare the (topic, partition) for less-than equality
|
||||||
|
*/
|
||||||
|
bool operator<(const TopicPartition& rhs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print to a stream
|
* Print to a stream
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,11 +28,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <tuple>
|
||||||
#include <librdkafka/rdkafka.h>
|
#include <librdkafka/rdkafka.h>
|
||||||
#include "topic_partition.h"
|
#include "topic_partition.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
using std::tie;
|
||||||
|
|
||||||
namespace cppkafka {
|
namespace cppkafka {
|
||||||
|
|
||||||
@@ -77,6 +79,10 @@ void TopicPartition::set_offset(int64_t offset) {
|
|||||||
offset_ = offset;
|
offset_ = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TopicPartition::operator<(const TopicPartition& rhs) const {
|
||||||
|
return tie(topic_, partition_) < tie(rhs.topic_, rhs.partition_);
|
||||||
|
}
|
||||||
|
|
||||||
ostream& operator<<(ostream& output, const TopicPartition& rhs) {
|
ostream& operator<<(ostream& output, const TopicPartition& rhs) {
|
||||||
return output << rhs.get_topic() << "[" << rhs.get_partition() << "]";
|
return output << rhs.get_topic() << "[" << rhs.get_partition() << "]";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user