use epics_throws macro
This commit is contained in:
168
src/ca/comBuf.h
168
src/ca/comBuf.h
@@ -34,7 +34,7 @@
|
||||
#include "tsFreeList.h"
|
||||
#include "tsDLList.h"
|
||||
#include "osiWireFormat.h"
|
||||
#include "cxxCompilerDepPlacementDelete.h"
|
||||
#include "cxxCompilerDependencies.h"
|
||||
|
||||
static const unsigned comBufSize = 0x4000;
|
||||
|
||||
@@ -43,130 +43,128 @@ class comBufMemoryManager {
|
||||
public:
|
||||
virtual ~comBufMemoryManager ();
|
||||
virtual void * allocate ( size_t )
|
||||
throw ( std::bad_alloc ) = 0;
|
||||
epics_throws (( std::bad_alloc )) = 0;
|
||||
virtual void release ( void * )
|
||||
throw () = 0;
|
||||
epics_throws (()) = 0;
|
||||
};
|
||||
|
||||
class wireSendAdapter { // X aCC 655
|
||||
public:
|
||||
virtual unsigned sendBytes ( const void *pBuf,
|
||||
unsigned nBytesInBuf ) throw () = 0;
|
||||
unsigned nBytesInBuf ) epics_throws (()) = 0;
|
||||
};
|
||||
|
||||
class wireRecvAdapter { // X aCC 655
|
||||
public:
|
||||
virtual unsigned recvBytes ( void *pBuf,
|
||||
unsigned nBytesInBuf ) throw () = 0;
|
||||
unsigned nBytesInBuf ) epics_throws (()) = 0;
|
||||
};
|
||||
|
||||
class comBuf : public tsDLNode < comBuf > {
|
||||
public:
|
||||
class insufficentBytesAvailable {};
|
||||
comBuf () throw();
|
||||
unsigned unoccupiedBytes () const throw();
|
||||
unsigned occupiedBytes () const throw();
|
||||
unsigned uncommittedBytes () const throw();
|
||||
static unsigned capacityBytes () throw();
|
||||
void clear () throw ();
|
||||
unsigned copyInBytes ( const void *pBuf, unsigned nBytes ) throw();
|
||||
unsigned push ( comBuf & ) throw();
|
||||
bool push ( const epicsInt8 & value ) throw();
|
||||
bool push ( const epicsUInt8 & value ) throw();
|
||||
bool push ( const epicsInt16 & value ) throw();
|
||||
bool push ( const epicsUInt16 & value ) throw();
|
||||
bool push ( const epicsInt32 & value ) throw();
|
||||
bool push ( const epicsUInt32 & value ) throw();
|
||||
bool push ( const epicsFloat32 & value ) throw();
|
||||
bool push ( const epicsFloat64 & value ) throw();
|
||||
bool push ( const epicsOldString & value ) throw();
|
||||
unsigned push ( const epicsInt8 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsUInt8 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsInt16 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsUInt16 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsInt32 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsUInt32 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsFloat32 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsFloat64 *pValue, unsigned nElem ) throw();
|
||||
unsigned push ( const epicsOldString *pValue, unsigned nElem ) throw();
|
||||
void commitIncomming () throw();
|
||||
void clearUncommittedIncomming () throw();
|
||||
bool copyInAllBytes ( const void *pBuf, unsigned nBytes ) throw();
|
||||
unsigned copyOutBytes ( void *pBuf, unsigned nBytes ) throw();
|
||||
bool copyOutAllBytes ( void *pBuf, unsigned nBytes ) throw();
|
||||
unsigned removeBytes ( unsigned nBytes ) throw();
|
||||
bool flushToWire ( wireSendAdapter & ) throw ();
|
||||
unsigned fillFromWire ( wireRecvAdapter & ) throw ();
|
||||
comBuf () epics_throws (());
|
||||
unsigned unoccupiedBytes () const epics_throws (());
|
||||
unsigned occupiedBytes () const epics_throws (());
|
||||
unsigned uncommittedBytes () const epics_throws (());
|
||||
static unsigned capacityBytes () epics_throws (());
|
||||
void clear () epics_throws (());
|
||||
unsigned copyInBytes ( const void *pBuf, unsigned nBytes ) epics_throws (());
|
||||
unsigned push ( comBuf & ) epics_throws (());
|
||||
bool push ( const epicsInt8 & value ) epics_throws (());
|
||||
bool push ( const epicsUInt8 & value ) epics_throws (());
|
||||
bool push ( const epicsInt16 & value ) epics_throws (());
|
||||
bool push ( const epicsUInt16 & value ) epics_throws (());
|
||||
bool push ( const epicsInt32 & value ) epics_throws (());
|
||||
bool push ( const epicsUInt32 & value ) epics_throws (());
|
||||
bool push ( const epicsFloat32 & value ) epics_throws (());
|
||||
bool push ( const epicsFloat64 & value ) epics_throws (());
|
||||
bool push ( const epicsOldString & value ) epics_throws (());
|
||||
unsigned push ( const epicsInt8 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsUInt8 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsInt16 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsUInt16 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsInt32 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsUInt32 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsFloat32 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsFloat64 *pValue, unsigned nElem ) epics_throws (());
|
||||
unsigned push ( const epicsOldString *pValue, unsigned nElem ) epics_throws (());
|
||||
void commitIncomming () epics_throws (());
|
||||
void clearUncommittedIncomming () epics_throws (());
|
||||
bool copyInAllBytes ( const void *pBuf, unsigned nBytes ) epics_throws (());
|
||||
unsigned copyOutBytes ( void *pBuf, unsigned nBytes ) epics_throws (());
|
||||
bool copyOutAllBytes ( void *pBuf, unsigned nBytes ) epics_throws (());
|
||||
unsigned removeBytes ( unsigned nBytes ) epics_throws (());
|
||||
bool flushToWire ( wireSendAdapter & ) epics_throws (());
|
||||
unsigned fillFromWire ( wireRecvAdapter & ) epics_throws (());
|
||||
epicsUInt8 popUInt8 ()
|
||||
throw ( comBuf::insufficentBytesAvailable );
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ));
|
||||
epicsUInt16 popUInt16 ()
|
||||
throw ( comBuf::insufficentBytesAvailable );
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ));
|
||||
epicsUInt32 popUInt32 ()
|
||||
throw ( comBuf::insufficentBytesAvailable );
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ));
|
||||
static void throwInsufficentBytesException ()
|
||||
throw ( comBuf::insufficentBytesAvailable );
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ));
|
||||
void * operator new ( size_t size,
|
||||
comBufMemoryManager & ) throw ( std::bad_alloc );
|
||||
comBufMemoryManager & ) epics_throws (( std::bad_alloc ));
|
||||
# ifdef CXX_PLACEMENT_DELETE
|
||||
void operator delete ( void *,
|
||||
comBufMemoryManager & ) throw ();
|
||||
comBufMemoryManager & ) epics_throws (());
|
||||
# endif
|
||||
private:
|
||||
unsigned commitIndex;
|
||||
unsigned nextWriteIndex;
|
||||
unsigned nextReadIndex;
|
||||
epicsUInt8 buf [ comBufSize ];
|
||||
unsigned unoccupiedElem ( unsigned elemSize, unsigned nElem ) throw ();
|
||||
unsigned occupiedElem ( unsigned elemSize, unsigned nElem ) throw ();
|
||||
void * operator new ( size_t size ) throw ( std::bad_alloc );
|
||||
void operator delete ( void * ) throw ( std::logic_error );
|
||||
void * operator new [] ( size_t size ) throw ( std::bad_alloc );
|
||||
void operator delete [] ( void * ) throw ( std::logic_error );
|
||||
unsigned unoccupiedElem ( unsigned elemSize, unsigned nElem ) epics_throws (());
|
||||
unsigned occupiedElem ( unsigned elemSize, unsigned nElem ) epics_throws (());
|
||||
void * operator new ( size_t size ) epics_throws (( std::bad_alloc ));
|
||||
void operator delete ( void * ) epics_throws (());
|
||||
};
|
||||
|
||||
inline void * comBuf::operator new ( size_t size,
|
||||
comBufMemoryManager & mgr )
|
||||
throw ( std::bad_alloc )
|
||||
epics_throws (( std::bad_alloc ))
|
||||
{
|
||||
return mgr.allocate ( size );
|
||||
}
|
||||
|
||||
#ifdef CXX_PLACEMENT_DELETE
|
||||
inline void comBuf::operator delete ( void * pCadaver,
|
||||
comBufMemoryManager & mgr ) throw ()
|
||||
comBufMemoryManager & mgr ) epics_throws (())
|
||||
{
|
||||
mgr.release ( pCadaver );
|
||||
}
|
||||
#endif
|
||||
|
||||
inline comBuf::comBuf () throw () : commitIndex ( 0u ),
|
||||
inline comBuf::comBuf () epics_throws (()) : commitIndex ( 0u ),
|
||||
nextWriteIndex ( 0u ), nextReadIndex ( 0u )
|
||||
{
|
||||
}
|
||||
|
||||
inline void comBuf::clear () throw ()
|
||||
inline void comBuf::clear () epics_throws (())
|
||||
{
|
||||
this->commitIndex = 0u;
|
||||
this->nextWriteIndex = 0u;
|
||||
this->nextReadIndex = 0u;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::unoccupiedBytes () const throw ()
|
||||
inline unsigned comBuf::unoccupiedBytes () const epics_throws (())
|
||||
{
|
||||
return sizeof ( this->buf ) - this->nextWriteIndex;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::occupiedBytes () const throw ()
|
||||
inline unsigned comBuf::occupiedBytes () const epics_throws (())
|
||||
{
|
||||
return this->commitIndex - this->nextReadIndex;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::uncommittedBytes () const throw ()
|
||||
inline unsigned comBuf::uncommittedBytes () const epics_throws (())
|
||||
{
|
||||
return this->nextWriteIndex - this->commitIndex;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::push ( comBuf & bufIn ) throw ()
|
||||
inline unsigned comBuf::push ( comBuf & bufIn ) epics_throws (())
|
||||
{
|
||||
unsigned nBytes = this->copyInBytes (
|
||||
& bufIn.buf[ bufIn.nextReadIndex ],
|
||||
@@ -175,12 +173,12 @@ inline unsigned comBuf::push ( comBuf & bufIn ) throw ()
|
||||
return nBytes;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::capacityBytes () throw ()
|
||||
inline unsigned comBuf::capacityBytes () epics_throws (())
|
||||
{
|
||||
return comBufSize;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::fillFromWire ( wireRecvAdapter & wire ) throw ()
|
||||
inline unsigned comBuf::fillFromWire ( wireRecvAdapter & wire ) epics_throws (())
|
||||
{
|
||||
unsigned nNewBytes = wire.recvBytes (
|
||||
& this->buf[this->nextWriteIndex],
|
||||
@@ -189,7 +187,7 @@ inline unsigned comBuf::fillFromWire ( wireRecvAdapter & wire ) throw ()
|
||||
return nNewBytes;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::unoccupiedElem ( unsigned elemSize, unsigned nElem ) throw ()
|
||||
inline unsigned comBuf::unoccupiedElem ( unsigned elemSize, unsigned nElem ) epics_throws (())
|
||||
{
|
||||
unsigned avail = this->unoccupiedBytes ();
|
||||
if ( elemSize * nElem > avail ) {
|
||||
@@ -198,7 +196,7 @@ inline unsigned comBuf::unoccupiedElem ( unsigned elemSize, unsigned nElem ) thr
|
||||
return nElem;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsInt8 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsInt8 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -208,7 +206,7 @@ inline bool comBuf::push ( const epicsInt8 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsUInt8 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsUInt8 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -217,7 +215,7 @@ inline bool comBuf::push ( const epicsUInt8 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsInt16 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsInt16 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -229,7 +227,7 @@ inline bool comBuf::push ( const epicsInt16 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsUInt16 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsUInt16 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -241,7 +239,7 @@ inline bool comBuf::push ( const epicsUInt16 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsInt32 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsInt32 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -257,7 +255,7 @@ inline bool comBuf::push ( const epicsInt32 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsUInt32 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsUInt32 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -273,7 +271,7 @@ inline bool comBuf::push ( const epicsUInt32 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsFloat32 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsFloat32 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -284,7 +282,7 @@ inline bool comBuf::push ( const epicsFloat32 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsFloat64 & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsFloat64 & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -295,7 +293,7 @@ inline bool comBuf::push ( const epicsFloat64 & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsOldString & value ) throw ()
|
||||
inline bool comBuf::push ( const epicsOldString & value ) epics_throws (())
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -305,17 +303,17 @@ inline bool comBuf::push ( const epicsOldString & value ) throw ()
|
||||
return true;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::push ( const epicsInt8 *pValue, unsigned nElem ) throw ()
|
||||
inline unsigned comBuf::push ( const epicsInt8 *pValue, unsigned nElem ) epics_throws (())
|
||||
{
|
||||
return copyInBytes ( pValue, nElem );
|
||||
}
|
||||
|
||||
inline unsigned comBuf::push ( const epicsUInt8 *pValue, unsigned nElem ) throw ()
|
||||
inline unsigned comBuf::push ( const epicsUInt8 *pValue, unsigned nElem ) epics_throws (())
|
||||
{
|
||||
return copyInBytes ( pValue, nElem );
|
||||
}
|
||||
|
||||
inline unsigned comBuf::push ( const epicsOldString *pValue, unsigned nElem ) throw ()
|
||||
inline unsigned comBuf::push ( const epicsOldString *pValue, unsigned nElem ) epics_throws (())
|
||||
{
|
||||
nElem = this->unoccupiedElem ( sizeof (*pValue), nElem );
|
||||
unsigned size = nElem * sizeof ( *pValue );
|
||||
@@ -324,7 +322,7 @@ inline unsigned comBuf::push ( const epicsOldString *pValue, unsigned nElem ) th
|
||||
return nElem;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::occupiedElem ( unsigned elemSize, unsigned nElem ) throw ()
|
||||
inline unsigned comBuf::occupiedElem ( unsigned elemSize, unsigned nElem ) epics_throws (())
|
||||
{
|
||||
unsigned avail = this->occupiedBytes ();
|
||||
if ( elemSize * nElem > avail ) {
|
||||
@@ -333,17 +331,17 @@ inline unsigned comBuf::occupiedElem ( unsigned elemSize, unsigned nElem ) throw
|
||||
return nElem;
|
||||
}
|
||||
|
||||
inline void comBuf::commitIncomming () throw ()
|
||||
inline void comBuf::commitIncomming () epics_throws (())
|
||||
{
|
||||
this->commitIndex = this->nextWriteIndex;
|
||||
}
|
||||
|
||||
inline void comBuf::clearUncommittedIncomming () throw ()
|
||||
inline void comBuf::clearUncommittedIncomming () epics_throws (())
|
||||
{
|
||||
this->nextWriteIndex = this->commitIndex;
|
||||
}
|
||||
|
||||
inline bool comBuf::copyInAllBytes ( const void *pBuf, unsigned nBytes ) throw ()
|
||||
inline bool comBuf::copyInAllBytes ( const void *pBuf, unsigned nBytes ) epics_throws (())
|
||||
{
|
||||
if ( nBytes <= this->unoccupiedBytes () ) {
|
||||
memcpy ( & this->buf[this->nextWriteIndex], pBuf, nBytes );
|
||||
@@ -353,7 +351,7 @@ inline bool comBuf::copyInAllBytes ( const void *pBuf, unsigned nBytes ) throw (
|
||||
return false;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::copyInBytes ( const void *pBuf, unsigned nBytes ) throw ()
|
||||
inline unsigned comBuf::copyInBytes ( const void *pBuf, unsigned nBytes ) epics_throws (())
|
||||
{
|
||||
if ( nBytes > 0u ) {
|
||||
unsigned available = this->unoccupiedBytes ();
|
||||
@@ -366,7 +364,7 @@ inline unsigned comBuf::copyInBytes ( const void *pBuf, unsigned nBytes ) throw
|
||||
return nBytes;
|
||||
}
|
||||
|
||||
inline bool comBuf::copyOutAllBytes ( void * pBuf, unsigned nBytes ) throw ()
|
||||
inline bool comBuf::copyOutAllBytes ( void * pBuf, unsigned nBytes ) epics_throws (())
|
||||
{
|
||||
if ( nBytes <= this->occupiedBytes () ) {
|
||||
memcpy ( pBuf, &this->buf[this->nextReadIndex], nBytes);
|
||||
@@ -376,7 +374,7 @@ inline bool comBuf::copyOutAllBytes ( void * pBuf, unsigned nBytes ) throw ()
|
||||
return false;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::copyOutBytes ( void *pBuf, unsigned nBytes ) throw ()
|
||||
inline unsigned comBuf::copyOutBytes ( void *pBuf, unsigned nBytes ) epics_throws (())
|
||||
{
|
||||
unsigned occupied = this->occupiedBytes ();
|
||||
if ( nBytes > occupied ) {
|
||||
@@ -387,7 +385,7 @@ inline unsigned comBuf::copyOutBytes ( void *pBuf, unsigned nBytes ) throw ()
|
||||
return nBytes;
|
||||
}
|
||||
|
||||
inline unsigned comBuf::removeBytes ( unsigned nBytes ) throw ()
|
||||
inline unsigned comBuf::removeBytes ( unsigned nBytes ) epics_throws (())
|
||||
{
|
||||
unsigned occupied = this->occupiedBytes ();
|
||||
if ( nBytes > occupied ) {
|
||||
@@ -398,7 +396,7 @@ inline unsigned comBuf::removeBytes ( unsigned nBytes ) throw ()
|
||||
}
|
||||
|
||||
inline epicsUInt8 comBuf::popUInt8 ()
|
||||
throw ( comBuf::insufficentBytesAvailable )
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ))
|
||||
{
|
||||
if ( this->occupiedBytes () < 1u ) {
|
||||
comBuf::throwInsufficentBytesException ();
|
||||
@@ -407,7 +405,7 @@ inline epicsUInt8 comBuf::popUInt8 ()
|
||||
}
|
||||
|
||||
inline epicsUInt16 comBuf::popUInt16 ()
|
||||
throw ( comBuf::insufficentBytesAvailable )
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ))
|
||||
{
|
||||
if ( this->occupiedBytes () < 2u ) {
|
||||
comBuf::throwInsufficentBytesException ();
|
||||
@@ -418,7 +416,7 @@ inline epicsUInt16 comBuf::popUInt16 ()
|
||||
}
|
||||
|
||||
inline epicsUInt32 comBuf::popUInt32 ()
|
||||
throw ( comBuf::insufficentBytesAvailable )
|
||||
epics_throws (( comBuf::insufficentBytesAvailable ))
|
||||
{
|
||||
if ( this->occupiedBytes () < 4u ) {
|
||||
comBuf::throwInsufficentBytesException ();
|
||||
|
||||
Reference in New Issue
Block a user