Skip to content

Commit

Permalink
renamed apple.h to endian.h because it turns out that it is also used…
Browse files Browse the repository at this point in the history
… for linux systems, and removed double implemented ChannelImpl::get() function
  • Loading branch information
EmielBruijntjes committed Aug 14, 2014
1 parent 3e47191 commit 328820f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 56 deletions.
4 changes: 1 addition & 3 deletions amqpcpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
#include <stdint.h>
#include <math.h>

// include compatibilities for apple
#include <amqpcpp/apple.h>

// forward declarations
#include <amqpcpp/classes.h>

// utility classes
#include <amqpcpp/endian.h>
#include <amqpcpp/buffer.h>
#include <amqpcpp/bytebuffer.h>
#include <amqpcpp/receivedframe.h>
Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ callbacks.h
channel.h
channelimpl.h
classes.h
compat_endian.h
endian.h
connection.h
connectionhandler.h
connectionimpl.h
Expand Down
29 changes: 24 additions & 5 deletions include/apple.h → include/endian.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
#ifndef __AMQP_CPP_COMPAT_ENDIAN_H__
#define __AMQP_CPP_COMPAT_ENDIAN_H__

/**
* Endian.h
*
* On Apple systems, there are no macro's to convert between little
* and big endian byte orders. This header file adds the missing macros
*
* @author madmongo1 <https://github.com/madmongo1>
*/

/**
* Include guard
*/
#pragma once

/**
* The contents of the file are only relevant for Apple
*/
#if defined(__APPLE__)

// dependencies
#include <machine/endian.h>

#include <libkern/OSByteOrder.h>

// define 16 bit macros
#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)

// define 32 bit macros
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)

// define 64 but macros
#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)

// not on apple
#else

// non-apple systems have their own endian header file
#include <endian.h>

// end of "#if defined(__APPLE__)"
#endif

#endif
47 changes: 0 additions & 47 deletions src/channelimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,53 +589,6 @@ DeferredGet &ChannelImpl::get(const std::string &queue, int flags)
return *deferred;
}

/**
* Retrieve a single message from RabbitMQ
*
* When you call this method, you can get one single message from the queue (or none
* at all if the queue is empty). The deferred object that is returned, should be used
* to install a onEmpty() and onSuccess() callback function that will be called
* when the message is consumed and/or when the message could not be consumed.
*
* The following flags are supported:
*
* - noack if set, consumed messages do not have to be acked, this happens automatically
*
* @param queue name of the queue to consume from
* @param flags optional flags
*
* The object returns a deferred handler. Callbacks can be installed
* using onSuccess(), onEmpty(), onError() and onFinalize() methods.
*
* The onSuccess() callback has the following signature:
*
* void myCallback(const Message &message, uint64_t deliveryTag, bool redelivered);
*
* For example: channel.get("myqueue").onSuccess([](const Message &message, uint64_t deliveryTag, bool redelivered) {
*
* std::cout << "Message fetched" << std::endl;
*
* }).onEmpty([]() {
*
* std::cout << "Queue is empty" << std::endl;
*
* });
*/
DeferredGet &ChannelImpl::get(const std::string &queue, int flags)
{
// the get frame to send
BasicGetFrame frame(_id, queue, flags & noack);

// send the frame, and create deferred object
auto *deferred = new DeferredGet(this, send(frame));

// push to list
push(deferred);

// done
return *deferred;
}

/**
* Acknowledge a message
* @param deliveryTag the delivery tag
Expand Down

0 comments on commit 328820f

Please sign in to comment.