CPKIFBuffer Class Reference

#include <Buffer.h>

Collaboration diagram for CPKIFBuffer:

Collaboration graph
[legend]

List of all members.


Detailed Description

The CPKIFBuffer class provides the means by which PKIF classes accept and return binary data. The class provides a thin wrapper for an unsigned char* buffer and its length.

TSP-enforcing: Yes

Definition at line 31 of file Buffer.h.


Public Member Functions

 CPKIFBuffer ()
 CPKIFBuffer (const unsigned char *buf, unsigned int bufLen)
 CPKIFBuffer (bool takeOwnership, unsigned char *buf, unsigned int bufLen)
 CPKIFBuffer (const CPKIFBuffer &data)
virtual ~CPKIFBuffer ()
unsigned char * AllocateBuffer (int len)
 added implementation 05/06/2003
const unsigned char * GetBuffer () const
unsigned int GetLength () const
bool operator== (const CPKIFBuffer &rhs)
bool operator!= (const CPKIFBuffer &rhs)

Constructor & Destructor Documentation

CPKIFBuffer::CPKIFBuffer (  ) 

Interface: External

Several constructors are provided. The first creates an empty CPKIFBuffer object. The second, third and fourth create a CPKIFBuffer containing a copy of the data passed as parameters. The fifth provides a means of transferring (or not) ownership of an existing buffer to a CPKIFBuffer object. When takeOwnership is set to true, the new instance of CPKIFBuffer will assume responsibility for the pointer passed via buf an will free the pointer by a call to delete when the CPKIFBuffer object is destroyed (and, thus, must have been allocated on the same heap). When takeOwnership is set to false, the new instance of CPKIFBuffer simply copies the pointer value and references the application-provided buffer directly without calling delete upon destruction.

Callers must ensure that a correct length value is provided to constructor variants that accept parameters. If NULL is passed as a buffer value or 0 is passed as a buffer length value, the new instance will be created with NULL for the Buffer property and 0 for the Length property.

Returns:
None

Definition at line 40 of file Buffer.cpp.

CPKIFBuffer::CPKIFBuffer ( const unsigned char *  buf,
unsigned int  bufLen 
)

Interface: External

Several constructors are provided. The first creates an empty CPKIFBuffer object. The second, third and fourth create a CPKIFBuffer containing a copy of the data passed as parameters. The fifth provides a means of transferring (or not) ownership of an existing buffer to a CPKIFBuffer object. When takeOwnership is set to true, the new instance of CPKIFBuffer will assume responsibility for the pointer passed via buf an will free the pointer by a call to delete when the CPKIFBuffer object is destroyed (and, thus, must have been allocated on the same heap). When takeOwnership is set to false, the new instance of CPKIFBuffer simply copies the pointer value and references the application-provided buffer directly without calling delete upon destruction.

Callers must ensure that a correct length value is provided to constructor variants that accept parameters. If NULL is passed as a buffer value or 0 is passed as a buffer length value, the new instance will be created with NULL for the Buffer property and 0 for the Length property.

Returns:
None
Parameters:
buf  [in] The data to store in the new CPKIFBuffer
bufLen  [in] The length of buf

Definition at line 110 of file Buffer.cpp.

CPKIFBuffer::CPKIFBuffer ( bool  takeOwnership,
unsigned char *  buf,
unsigned int  bufLen 
)

takeOwnership = true means the CPKIFBuffer class will destroy the buffer takeOwnership = false means the CPKIFBuffer class will make a copy

Interface: External

Several constructors are provided. The first creates an empty CPKIFBuffer object. The second, third and fourth create a CPKIFBuffer containing a copy of the data passed as parameters. The fifth provides a means of transferring (or not) ownership of an existing buffer to a CPKIFBuffer object. When takeOwnership is set to true, the new instance of CPKIFBuffer will assume responsibility for the pointer passed via buf an will free the pointer by a call to delete when the CPKIFBuffer object is destroyed (and, thus, must have been allocated on the same heap). When takeOwnership is set to false, the new instance of CPKIFBuffer simply copies the pointer value and references the application-provided buffer directly without calling delete upon destruction.

Callers must ensure that a correct length value is provided to constructor variants that accept parameters. If NULL is passed as a buffer value or 0 is passed as a buffer length value, the new instance will be created with NULL for the Buffer property and 0 for the Length property.

Returns:
None
Parameters:
takeOwnership  [in] Boolean indicating whether to transfer ownership of the buffer pointed to by buf to the new object
buf  [in] The data to store in the new CPKIFBuffer
bufLen  [in] The length of buf

Definition at line 63 of file Buffer.cpp.

CPKIFBuffer::CPKIFBuffer ( const CPKIFBuffer data  ) 

Interface: External

Several constructors are provided. The first creates an empty CPKIFBuffer object. The second, third and fourth create a CPKIFBuffer containing a copy of the data passed as parameters. The fifth provides a means of transferring (or not) ownership of an existing buffer to a CPKIFBuffer object. When takeOwnership is set to true, the new instance of CPKIFBuffer will assume responsibility for the pointer passed via buf an will free the pointer by a call to delete when the CPKIFBuffer object is destroyed (and, thus, must have been allocated on the same heap). When takeOwnership is set to false, the new instance of CPKIFBuffer simply copies the pointer value and references the application-provided buffer directly without calling delete upon destruction.

Callers must ensure that a correct length value is provided to constructor variants that accept parameters. If NULL is passed as a buffer value or 0 is passed as a buffer length value, the new instance will be created with NULL for the Buffer property and 0 for the Length property.

Returns:
None
Parameters:
data  [in] A CPKIFBuffer object to copy

Definition at line 147 of file Buffer.cpp.

References m_impl.

CPKIFBuffer::~CPKIFBuffer (  )  [virtual]

Interface: External

The function destroys an instance of CPKIFBuffer

Returns:
None

Definition at line 171 of file Buffer.cpp.


Member Function Documentation

unsigned char * CPKIFBuffer::AllocateBuffer ( int  len  ) 

added implementation 05/06/2003

Interface: External

This function allocates a buffer inside a CPKIFBuffer object and returns a pointer to that buffer. Care must be taken when using this function, particularly if the object is shared as a CPKIFBufferPtr.

Destroys previously allocated buffer and allocates a new buffer of desired size. All pointers to the buffer are effected when this function is invoked, i.e. if there are two smart pointers to the same CPKIFBuffer object both will be effected when allocateBuffer is invoked on one of them.

Returns:
A pointer to the allocated buffer
Parameters:
len  [in] The length of the buffer to allocate

Definition at line 260 of file Buffer.cpp.

Referenced by WriteCB().

const unsigned char * CPKIFBuffer::GetBuffer (  )  const

Interface: External

This function returns a const pointer to the internal buffer managed by the instance of CPKIFBuffer. This pointer is valid only for the life of the CPKIFBuffer object from which it was obtained, or until allocateBuffer is called on that object.

Returns:
A const pointer to a buffer or NULL if no buffer has been allocated or specified

Definition at line 193 of file Buffer.cpp.

Referenced by WriteCB().

unsigned int CPKIFBuffer::GetLength (  )  const

Interface: External

This function returns the length of the data maintained in the internal buffer, e.g. the buffer available via a call to GetBuffer.

Returns:
the length of the buffer returned by calls to GetBuffer or 0 if no buffer has been allocated or specified

Definition at line 204 of file Buffer.cpp.

Referenced by WriteCB().

bool CPKIFBuffer::operator== ( const CPKIFBuffer rhs  ) 

Interface: External

This function returns true if the value held by the object passed via the rhs parameter is the same, i.e. binary comparison, as the value held by the object on which this function was invoked and false otherwise.

Returns:
true if compared buffers do match and false otherwise

added 12/6/2003

both equal zero

Parameters:
rhs  [in] Reference to a smart pointer to a CPKIFBuffer object containing the buffer to compare

Definition at line 218 of file Buffer.cpp.

References m_impl.

Referenced by operator!=().

bool CPKIFBuffer::operator!= ( const CPKIFBuffer rhs  ) 

Interface: External

This function returns true if the value held by the object passed via the rhs parameter is not the same as the value held by the object on which this function was invoked and false otherwise.

Returns:
true if compared buffers do not match and false otherwise
Parameters:
rhs  [in] Reference to a smart pointer to a CPKIFBuffer object containing the buffer to compare

Definition at line 240 of file Buffer.cpp.

References operator==().


The documentation for this class was generated from the following files:

Generated on Mon Nov 15 11:19:53 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6