📄 aqmessage.cpp
字号:
#define __OCICPP_INTERNAL_USE_#include "AQMessage.h"#include "OraError.h"
/*! \class OCICPP::AQMessage \brief Advanced Queuing uses this representation of messages This class provides an encapsulation of a message used by the advanced queuing from Oracle. A message consists out of organisatoric data (message id, priority, correlation identifier) and user data (payload). Since the object option is not yet supported, data is stored as RAW data within the database. *//*! Construct a (yet to be filled) message. */OCICPP::AQMessage::AQMessage(){ payload = NULL; payload_sz = 0;}/*! Destroy the message and free locally allocated data. */OCICPP::AQMessage::~AQMessage(){ FreePayload();}/*! Frees the payload part of the message. */void OCICPP::AQMessage::FreePayload(void){ if(payload) { free(payload); payload = NULL; payload_sz = 0; }}/*! Retrieves the payload as string \a Payload. */void OCICPP::AQMessage::getPayload(string &Payload){ if(payload) { Payload.assign((char *)payload, payload_sz); }}/*! Retrieves the payload from this object as a void-pointer. The void-pointer where \a Payload is pointing to is initialized with a copy of the current payload and the \a PayloadSize is being initialized with the current size of the payload. The caller is responsible for freeing the data pointed at \a *Payload. */void OCICPP::AQMessage::getPayload(void **Payload, size_t *PayloadSize){ *Payload = 0; if(payload) { *Payload = calloc(1, payload_sz); if(!*Payload) throw(OraError("Memory allocation failed.", OCICPPERROR)); memcpy(*Payload, payload, payload_sz); *PayloadSize = payload_sz; }}/*! Set the message's payload to the string \a Payload. */void OCICPP::AQMessage::setPayload(string &Payload){ FreePayload(); payload = calloc(1, Payload.size() + 1); if(!payload) throw(OraError("Memory allocation failed.", OCICPPERROR)); memcpy(payload, Payload.c_str(), Payload.size()); payload_sz = Payload.size() + 1;}/*! Sets the payload to a copy of \a Payload (which has the size \a PayloadSize) */void OCICPP::AQMessage::setPayload(void *Payload, size_t PayloadSize){ FreePayload(); payload = calloc(1, PayloadSize); if(!payload) throw(OraError("Memory allocation failed.", OCICPPERROR)); memcpy(payload, Payload, PayloadSize); payload_sz = PayloadSize;}/*! Retrieves the message's id. */string OCICPP::AQMessage::getMessageID(void){ return(MessageID);}/*! Reads the correlation identifier of the message */string OCICPP::AQMessage::getCorrelationIdentifier(void){ return(CorrelationIdentifier);}/*! Answers the name of an exception queue */string OCICPP::AQMessage::getExceptionQueue(void){ return(ExceptionQueue);}int OCICPP::AQMessage::getDelay(void){ return(Delay);}int OCICPP::AQMessage::getExpiration(void){ return(Expiration);}/*! Reads the priority for this message. */int OCICPP::AQMessage::getPriority(void){ return(Priority);}/*! Sets the message's id to \a MessageID. */void OCICPP::AQMessage::setMessageID(string& MessageID){ this->MessageID.assign(MessageID);}/*! Sets the correlation identifier for this message */void OCICPP::AQMessage::setCorrelationIdentifier(string& CorrelationIdentifier){ this->CorrelationIdentifier.assign(CorrelationIdentifier);}/*! Sets an exception queue for this message */void OCICPP::AQMessage::setExceptionQueue(string& ExceptionQueue){ this->ExceptionQueue.assign(ExceptionQueue);}void OCICPP::AQMessage::setDelay(int Delay){ this->Delay = Delay;}void OCICPP::AQMessage::setExpiration(int Expiration){ this->Expiration = Expiration;}/*! Sets the priority for this message. */void OCICPP::AQMessage::setPriority(int Priority){ this->Priority = Priority;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -