mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-10-31 18:47:48 +00:00
Export symbols on Windows dll builds
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
#include <algorithm>
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -47,7 +48,7 @@ namespace cppkafka {
|
||||
* pointer that this buffer points to will still until the call to Producer::produce
|
||||
* returns.
|
||||
*/
|
||||
class Buffer {
|
||||
class CPPKAFKA_API Buffer {
|
||||
public:
|
||||
/**
|
||||
* The type of data this buffer points to
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "topic_configuration.h"
|
||||
#include "clonable_ptr.h"
|
||||
#include "configuration_base.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -56,7 +57,7 @@ class KafkaHandleBase;
|
||||
*
|
||||
* Some other overloads for Configuration::set are given via ConfigurationBase.
|
||||
*/
|
||||
class Configuration : public ConfigurationBase<Configuration> {
|
||||
class CPPKAFKA_API Configuration : public ConfigurationBase<Configuration> {
|
||||
public:
|
||||
using DeliveryReportCallback = std::function<void(Producer& producer, const Message&)>;
|
||||
using OffsetCommitCallback = std::function<void(Consumer& consumer, rd_kafka_resp_err_t,
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <functional>
|
||||
#include "kafka_handle_base.h"
|
||||
#include "message.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -92,7 +93,7 @@ class TopicConfiguration;
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
class Consumer : public KafkaHandleBase {
|
||||
class CPPKAFKA_API Consumer : public KafkaHandleBase {
|
||||
public:
|
||||
using AssignmentCallback = std::function<void(TopicPartitionList&)>;
|
||||
using RevocationCallback = std::function<void(const TopicPartitionList&)>;
|
||||
|
||||
@@ -33,13 +33,14 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
/**
|
||||
* Base class for all cppkafka exceptions
|
||||
*/
|
||||
class Exception : public std::exception {
|
||||
class CPPKAFKA_API Exception : public std::exception {
|
||||
public:
|
||||
Exception(std::string message);
|
||||
|
||||
@@ -51,7 +52,7 @@ private:
|
||||
/**
|
||||
* A configuration related error
|
||||
*/
|
||||
class ConfigException : public Exception {
|
||||
class CPPKAFKA_API ConfigException : public Exception {
|
||||
public:
|
||||
ConfigException(const std::string& config_name, const std::string& error);
|
||||
};
|
||||
@@ -59,7 +60,7 @@ public:
|
||||
/**
|
||||
* Indicates a configuration option was not set
|
||||
*/
|
||||
class ConfigOptionNotFound : public Exception {
|
||||
class CPPKAFKA_API ConfigOptionNotFound : public Exception {
|
||||
public:
|
||||
ConfigOptionNotFound(const std::string& config_name);
|
||||
};
|
||||
@@ -67,7 +68,7 @@ public:
|
||||
/**
|
||||
* A generic rdkafka handle error
|
||||
*/
|
||||
class HandleException : public Exception {
|
||||
class CPPKAFKA_API HandleException : public Exception {
|
||||
public:
|
||||
HandleException(rd_kafka_resp_err_t error_code);
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "topic_partition_list.h"
|
||||
#include "topic_configuration.h"
|
||||
#include "configuration.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -51,7 +52,7 @@ class TopicMetadata;
|
||||
/**
|
||||
* Base class for kafka consumer/producer
|
||||
*/
|
||||
class KafkaHandleBase {
|
||||
class CPPKAFKA_API KafkaHandleBase {
|
||||
public:
|
||||
using OffsetTuple = std::tuple<int64_t, int64_t>;
|
||||
|
||||
|
||||
46
include/cppkafka/macros.h
Normal file
46
include/cppkafka/macros.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Matias Fontanini
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CPPKAFKA_MACROS_H
|
||||
#define CPPKAFKA_MACROS_H
|
||||
|
||||
// If cppkafka was built into a shared library
|
||||
#if defined(_WIN32) && !defined(CPPKAFKA_STATIC)
|
||||
// Export/import symbols, depending on whether we're compiling or consuming the lib
|
||||
#ifdef cppkafka_EXPORTS
|
||||
#define CPPKAFKA_API __declspec(dllexport)
|
||||
#else
|
||||
#define CPPKAFKA_API __declspec(dllimport)
|
||||
#endif // cppkafka_EXPORTS
|
||||
#else
|
||||
// Otherwise, default this to an empty macro
|
||||
#define CPPKAFKA_API
|
||||
#endif // _WIN32 && !CPPKAFKA_STATIC
|
||||
|
||||
#endif // CPPKAFKA_MACROS_H
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include "buffer.h"
|
||||
#include "topic.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -48,7 +49,7 @@ namespace cppkafka {
|
||||
* necessary when calling Consumer::poll() as any poll operation that returns a null pointer will
|
||||
* return an empty message.
|
||||
*/
|
||||
class Message {
|
||||
class CPPKAFKA_API Message {
|
||||
public:
|
||||
/**
|
||||
* Constructs a message that won't take ownership of the given pointer
|
||||
|
||||
@@ -36,13 +36,14 @@
|
||||
#include <cstdint>
|
||||
#include <unordered_set>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
/**
|
||||
* Represents the metadata for a partition
|
||||
*/
|
||||
class PartitionMetadata {
|
||||
class CPPKAFKA_API PartitionMetadata {
|
||||
public:
|
||||
PartitionMetadata(const rd_kafka_metadata_partition& partition);
|
||||
|
||||
@@ -81,7 +82,7 @@ private:
|
||||
/**
|
||||
* Represents the metadata for a topic
|
||||
*/
|
||||
class TopicMetadata {
|
||||
class CPPKAFKA_API TopicMetadata {
|
||||
public:
|
||||
TopicMetadata(const rd_kafka_metadata_topic& topic);
|
||||
|
||||
@@ -108,7 +109,7 @@ private:
|
||||
/**
|
||||
* Represents a broker's metadata
|
||||
*/
|
||||
class BrokerMetadata {
|
||||
class CPPKAFKA_API BrokerMetadata {
|
||||
public:
|
||||
BrokerMetadata(const rd_kafka_metadata_broker_t& broker);
|
||||
|
||||
@@ -135,7 +136,7 @@ private:
|
||||
/**
|
||||
* Represents metadata for brokers, topics and partitions
|
||||
*/
|
||||
class Metadata {
|
||||
class CPPKAFKA_API Metadata {
|
||||
public:
|
||||
Metadata(const rd_kafka_metadata_t* ptr);
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef CPPKAFKA_PARTITION_H
|
||||
#define CPPKAFKA_PARTITION_H
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ namespace cppkafka {
|
||||
* This class is basically a wrapper over an int that when default constructed will default
|
||||
* to using RD_KAFKA_PARTITION_UA so you don't need to use the macro name.
|
||||
*/
|
||||
class Partition {
|
||||
class CPPKAFKA_API Partition {
|
||||
public:
|
||||
/**
|
||||
* \brief Constructs an unassigned partition
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "buffer.h"
|
||||
#include "topic.h"
|
||||
#include "partition.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -77,7 +78,7 @@ class TopicConfiguration;
|
||||
*
|
||||
* \endcode
|
||||
*/
|
||||
class Producer : public KafkaHandleBase {
|
||||
class CPPKAFKA_API Producer : public KafkaHandleBase {
|
||||
public:
|
||||
enum PayloadPolicy {
|
||||
COPY_PAYLOAD = RD_KAFKA_MSG_F_COPY, ///< Means RD_KAFKA_MSG_F_COPY
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <memory>
|
||||
#include <boost/optional.hpp>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace cppkafka {
|
||||
*
|
||||
* This is a simple wrapper over a rd_kafka_topic_t*
|
||||
*/
|
||||
class Topic {
|
||||
class CPPKAFKA_API Topic {
|
||||
public:
|
||||
/**
|
||||
* \brief Creates a Topic object that doesn't take ownership of the handle
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include "clonable_ptr.h"
|
||||
#include "configuration_base.h"
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -46,7 +47,7 @@ class Buffer;
|
||||
*
|
||||
* ConfigurationBase provides some extra overloads for set
|
||||
*/
|
||||
class TopicConfiguration : public ConfigurationBase<TopicConfiguration> {
|
||||
class CPPKAFKA_API TopicConfiguration : public ConfigurationBase<TopicConfiguration> {
|
||||
public:
|
||||
/**
|
||||
* \brief Partitioner callback
|
||||
|
||||
@@ -33,13 +33,14 @@
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <cstdint>
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
/**
|
||||
* Represents a topic/partition
|
||||
*/
|
||||
class TopicPartition {
|
||||
class CPPKAFKA_API TopicPartition {
|
||||
public:
|
||||
/**
|
||||
* Special offsets enum
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <iosfwd>
|
||||
#include <algorithm>
|
||||
#include <librdkafka/rdkafka.h>
|
||||
#include "macros.h"
|
||||
|
||||
namespace cppkafka {
|
||||
|
||||
@@ -47,12 +48,12 @@ using TopicPartitionsListPtr = std::unique_ptr<rd_kafka_topic_partition_list_t,
|
||||
using TopicPartitionList = std::vector<TopicPartition>;
|
||||
|
||||
// Conversions between rdkafka handles and TopicPartitionList
|
||||
TopicPartitionsListPtr convert(const std::vector<TopicPartition>& topic_partitions);
|
||||
std::vector<TopicPartition> convert(const TopicPartitionsListPtr& topic_partitions);
|
||||
std::vector<TopicPartition> convert(rd_kafka_topic_partition_list_t* topic_partitions);
|
||||
TopicPartitionsListPtr make_handle(rd_kafka_topic_partition_list_t* handle);
|
||||
CPPKAFKA_API TopicPartitionsListPtr convert(const std::vector<TopicPartition>& topic_partitions);
|
||||
CPPKAFKA_API std::vector<TopicPartition> convert(const TopicPartitionsListPtr& topic_partitions);
|
||||
CPPKAFKA_API std::vector<TopicPartition> convert(rd_kafka_topic_partition_list_t* topic_partitions);
|
||||
CPPKAFKA_API TopicPartitionsListPtr make_handle(rd_kafka_topic_partition_list_t* handle);
|
||||
|
||||
std::ostream& operator<<(std::ostream& output, const TopicPartitionList& rhs);
|
||||
CPPKAFKA_API std::ostream& operator<<(std::ostream& output, const TopicPartitionList& rhs);
|
||||
|
||||
} // cppkafka
|
||||
|
||||
|
||||
Reference in New Issue
Block a user