#import <CC3DataStreams.h>
Instance Methods | |
(id) | - initOnData: |
(BOOL) | - readAll:bytes: |
(char) | - readByte |
(double) | - readDouble |
(float) | - readFloat |
(int) | - readInteger |
(short) | - readShort |
(unsigned char) | - readUnsignedByte |
(unsigned int) | - readUnsignedInteger |
(unsigned short) | - readUnsignedShort |
Class Methods | |
(id) | + readerOnData: |
Properties | |
NSUInteger | bytesRemaining |
NSData * | data |
BOOL | isBigEndian |
NSUInteger | position |
BOOL | wasReadBeyondEOF |
CC3DataReader sequentially reads data from the bytes managed by a NSData object.
Reading starts at the beginning of the data bytes contained in the NSData object. As each element is read, the pointer is advanced to the beginning of the next element.
If an attempt is made to read beyond the end of the contained data, the element reading methods will return a default value, and the value of the wasReadBeyondEOF property is set to YES. You can test the value of this property after each read, or once reading is complete in order to determine if an unexpected end of data was encountered.
- (id) initOnData: | (NSData *) | data |
Initializes this instance on the specified NSData object.
- (BOOL) readAll: | (NSUInteger) | count | |
bytes: | (char *) | bytes | |
Reads the specified number of bytes into the specified byte array, and advances the stream position.
If ALL of the bytes cannot be read, then the entire array of bytes is zeroed, and the stream position, as returned by the postion property, is not advanced.
Returns YES if the requested number of bytes was successfully read into the specified byte array, and the steam position was advanced. Otherwise, returns NO to indicate that none of the bytes were read, the stream position was not advanced, and the byte array was zeroed.
- (char) readByte |
Reads and returns a byte from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
- (double) readDouble |
Reads and returns a double from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
+ (id) readerOnData: | (NSData *) | data |
Allocates and initializes an autoreleased instance on the specified NSData object.
- (float) readFloat |
Reads and returns a float from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
- (int) readInteger |
Reads and returns an integer from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
- (short) readShort |
Reads and returns a short from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
- (unsigned char) readUnsignedByte |
Reads and returns an unsigned byte from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
- (unsigned int) readUnsignedInteger |
Reads and returns an unsigned integer from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
- (unsigned short) readUnsignedShort |
Reads and returns an unsigned short from the current position in the stream, and advances the stream pointer.
If the value could not be read, returns zero, and does not advance the stream position.
|
readnonatomicassign |
Bytes remaining to be read.
|
readnonatomicretain |
Returns the encapsulated data object.
|
readwritenonatomicassign |
Indicates whether the source content was encoded on a big-endian platform.
Most OSX and iOS platforms are little-endian, so this property defaults to NO. You can set the value of this property to YES prior to reading any content if you know the data was encoded on a big-endian platform.
|
readnonatomicassign |
Returns the current position in the stream.
|
readnonatomicassign |
Returns YES if an attempt was made to read beyond the end of the data content.