• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 7.1.0.193
GDDirectByteBuffer Class Reference

Buffer for accessing GDSocket and GDHttpRequest data. More...

#import <GDNETiOS.h>

Inherits NSObject.

Description

The BlackBerry Dynamics direct byte buffer interface is used to access a number of in-memory byte buffers within the BlackBerry Dynamics secure communication features.

  • Use it with GDSocket for reading and writing data.
  • Use it with the deprecated GDHttpRequest class for reading response data.

Instance Methods

(instancetype) - init
 Constructor that prepares a new buffer. More...
 
(void) - write:
 Append null-terminated string. More...
 
(void) - writeData:
 Append NSData data. More...
 
(void) - write:withLength:
 Append a number of bytes from a string. More...
 
(int) - bytesUnread
 Number of bytes available. More...
 
(int) - read:toMaxLength:
 Consume data into a char* buffer. More...
 
(NSMutableString *) - unreadDataAsString
 Consume data into a new NSString object. More...
 
(NSMutableData *) - unreadData
 Consume data into a new NSData object. More...
 

Method Documentation

◆ init

- (instancetype) init

Call this function to construct a stand-alone byte buffer. Where a buffer is associated with a GDSocket or GDHttpRequest (deprecated) object, this function will have been called by the BlackBerry Dynamics runtime, and need not be called by the application.

◆ write:

- (void) write: (const char *)  data

Call this function to append data to the buffer. This would be used on the outbound buffer of a GDSocket.

Calling this function doesn't cause data to be sent. See write (GDSocket). The buffer allocates itself more memory as necessary to accomodate unsent data.

Parameters
dataNull-terminated string, containing the data to be appended. The terminating null is not written to the buffer.

◆ writeData:

- (void) writeData: (NSData *)  data

Call this function to append data to the buffer. This would be used on the outbound buffer of a GDSocket.

Calling this function doesn't cause data to be sent. See write (GDSocket). The buffer allocates itself more memory as necessary to accomodate unsent data.

Parameters
dataNSData object containing the data to be appended.

◆ write:withLength:

- (void) write: (const char *)  data
withLength: (int)  length 

Call this function to append data to the buffer. This would be used on the outbound buffer of a GDSocket.

Calling this function doesn't cause data to be sent. See write (GDSocket). The buffer allocates itself more memory as necessary to accomodate unsent data.

Parameters
dataBuffer containing the data to be appended.
lengthNumber of bytes to be written from the buffer.

◆ bytesUnread

- (int) bytesUnread
Returns
Number of bytes available to read from the buffer.

◆ read:toMaxLength:

- (int) read: (char *)  data
toMaxLength: (int)  maxLength 

Call this function to read and consume a specified amount of raw data from the buffer. This would be used on the inbound buffer of a GDSocket, or on the response data of a GDHttpRequest (deprecated).

This function would typically be called in a delegated event handler, such as one of the following.

Calling this function causes data to be written to a char buffer supplied by the caller. The caller specifies the maximum amount of data to be written to the buffer, as a number of bytes.

The function returns the number of bytes actually written. This will be the lesser of the specified maximum, and the amount of unread data available.

The data written to the caller's buffer is, in effect, deleted from the byte buffer, and will not be returned by future calls to any reading functions.

Parameters
dataPointer to a char buffer to which data is to be written.
maxLengthMaximum number of bytes to be written to the char buffer.
Returns
Number of bytes actually written to the char buffer.

◆ unreadDataAsString

- (NSMutableString*) unreadDataAsString

Call this function to create an NSString object, populated with data consumed from the buffer. This would be used on the inbound buffer of a GDSocket, or on the response data of a GDHttpRequest (deprecated).

This function would typically be called in a delegated event handler, such as one of the following.

Calling this function first causes a UTF-8 NSString object to be allocated, by the BlackBerry Dynamics runtime. All unread data from the buffer is then written into the new object. The data written is, in effect, deleted from the buffer, and will not be returned by future calls to any reading functions.

Returns
New NSString object, populated with data consumed from the buffer.

◆ unreadData

- (NSMutableData*) unreadData

Call this function to create an NSData object, populated with data consumed from the buffer. This would be used on the inbound buffer of a GDSocket, or on the response data of a GDHttpRequest (deprecated).

This function would typically be called in a delegated event handler, such as one of the following.

Calling this function first causes an NSData object to be allocated, by the BlackBerry Dynamics runtime. All unread data from the buffer is then written into the new object. The data written is, in effect, deleted from the buffer, and will not be returned by future calls to any reading functions.

Returns
New NSData object, populated with data consumed from the buffer.

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