IDBLUE logo
Public Member Functions
ByteQueue Class Reference
Inheritance diagram for ByteQueue:
PacketQueue

Public Member Functions

(id) - initWithMaxCapacity:
(int) - push:withLen:
(int) - pop:withMaxLen:
(int) - pop:
(BOOL) - peek:withIndex:
(int) - peekRange:withIndex:withCount:
(byte) - computeChecksum:withCount:
(int) - size
(int) - capacity
(int) - available
(BOOL) - full
(BOOL) - empty
(int) - flush
(NSString *) - toString

Detailed Description

ByteQueue is a fast circular byte buffer, for pushing and poping bytes quickly. Typically would be used to prcessing IDBLUE responses.


Member Function Documentation

- (int) available

Get the number of bytes that can be added before the queue is full

- (int) capacity

Get the maximum number of bytes that can be held in the queue

- (BOOL) empty

Whether the queue is empty or not

- (int) flush

Brings the ringbuffer back to the default state.

Returns:
RC_SUCCESS successfully flushed.
RC_LOCK_ERROR error obtaining the mutex lock.
RC_UNLOCK_ERROR error releasing the mutex lock.
- (BOOL) full

Whether the queue is full or not

- (id) initWithMaxCapacity: (int)  capacity

Initialize a ByteQueue

Parameters:
capacityThe capacity of the ByteQueue
Returns:
The ByteQueue if initialized, nil otherwise
- (BOOL) peek: (byte*)  val
withIndex: (int)  index 

Get the value in the queue at the specified index.

Parameters:
valThe location of the byte that will be assigned the value
indexThe index in the queue to retrieve the value of
Returns:
True if the byte was read, FALSE otherwise
- (int) peekRange: (byte*)  dest
withIndex: (int)  index
withCount: (int)  count 

Retrieve a range of bytes from the ByteQueue, without removing them from the ByteQueue

Parameters:
destThe pointer to the byte array to copy the bytes into
indexThe index within the ByteQueue to start reading from
countThe number of bytes to read
Returns:
The number of bytes read
- (int) pop: (int)  toRemove

Pop the given number of bytes from the ByteQueue

Parameters:
toRemoveThe number of bytes to remove
Returns:
The number of bytes actually removed
- (int) pop: (byte*)  dest
withMaxLen: (int)  maxlen 

Pop maxlen bytes from the ring buffer into the dest array. Dest must be an initialized buffer of at least maxlen bytes.

Parameters:
destAn initialized buffer of at least maxlen bytes.
maxlenThe number of bytes requested from the ring buffer.
Returns:
The number of bytes written into the dest buffer.
- (int) push: (byte*)  data
withLen: (int)  len 

Push len bytes from data into the ring buffer. If the buffer has insufficient capacity to continue writing, write up to the amount of space available.

Parameters:
dataPointer to an initialized data buffer of at least length len
lenThe length of the data buffer to write
Returns:
The number of bytes written to the buffer
- (int) size

Get the number of bytes held in the queue.

- (NSString *) toString

Get the hex string representation of the ByteQueue

Returns:
a string containing each byte represented in hex.

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

 

Generated on Mon Jan 19 2015 15:47:38
Copyright © 2015 Cathexis Innovations Inc. All Rights Reserved.