Add operator<< for TopicPartition

This commit is contained in:
Matias Fontanini
2016-06-15 07:44:28 -07:00
parent 6877c4be03
commit 9e79321a1f
5 changed files with 49 additions and 0 deletions

View File

@@ -27,11 +27,13 @@
*
*/
#include <iostream>
#include "topic_partition_list.h"
#include "topic_partition.h"
#include "exceptions.h"
using std::vector;
using std::ostream;
namespace cppkafka {
@@ -65,4 +67,16 @@ TopicPartitionsListPtr make_handle(rd_kafka_topic_partition_list_t* handle) {
return TopicPartitionsListPtr(handle, &rd_kafka_topic_partition_list_destroy);
}
ostream& operator<<(ostream& output, const TopicPartitionList& rhs) {
output << "[ ";
for (auto iter = rhs.begin(); iter != rhs.end(); ++iter) {
if (iter != rhs.begin()) {
output << ", ";
}
output << *iter;
}
output << " ]";
return output;
}
} // cppkafka