CC3DataReader Class Reference
Inherits from | NSObject |
Declared in | CC3DataStreams.h |
Overview
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.
Tasks
-
data
property -
position
property -
bytesRemaining
property -
wasReadBeyondEOF
property -
isBigEndian
property -
– initOnData:
-
+ readerOnData:
-
– readAll:bytes:
-
– readByte
-
– readUnsignedByte
-
– readFloat
-
– readDouble
-
– readInteger
-
– readUnsignedInteger
-
– readShort
-
– readUnsignedShort
Properties
bytesRemaining
Bytes remaining to be read.
@property (nonatomic, readonly) NSUInteger bytesRemaining
Declared In
CC3DataStreams.h
data
Returns the encapsulated data object.
@property (nonatomic, retain, readonly) NSData *data
Declared In
CC3DataStreams.h
isBigEndian
Indicates whether the source content was encoded on a big-endian platform.
@property (nonatomic, assign) BOOL isBigEndian
Discussion
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.
Declared In
CC3DataStreams.h
Instance Methods
initOnData:
Initializes this instance on the specified NSData object.
- (id)initOnData:(NSData *)data
Declared In
CC3DataStreams.h
readAll:bytes:
Reads the specified number of bytes into the specified byte array, and advances the stream position.
- (BOOL)readAll:(NSUInteger)count bytes:(char *)bytes
Discussion
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.
Declared In
CC3DataStreams.h
readByte
Reads and returns a byte from the current position in the stream, and advances the stream pointer.
- (char)readByte
Discussion
If the value could not be read, returns zero, and does not advance the stream position.
Declared In
CC3DataStreams.h
readDouble
Reads and returns a double from the current position in the stream, and advances the stream pointer.
- (double)readDouble
Discussion
If the value could not be read, returns zero, and does not advance the stream position.
Declared In
CC3DataStreams.h
readFloat
Reads and returns a float from the current position in the stream, and advances the stream pointer.
- (float)readFloat
Discussion
If the value could not be read, returns zero, and does not advance the stream position.
Declared In
CC3DataStreams.h
readInteger
Reads and returns an integer from the current position in the stream, and advances the stream pointer.
- (int)readInteger
Discussion
If the value could not be read, returns zero, and does not advance the stream position.
Declared In
CC3DataStreams.h
readShort
Reads and returns a short from the current position in the stream, and advances the stream pointer.
- (short)readShort
Discussion
If the value could not be read, returns zero, and does not advance the stream position.
Declared In
CC3DataStreams.h
readUnsignedByte
Reads and returns an unsigned byte from the current position in the stream, and advances the stream pointer.
- (unsigned char)readUnsignedByte
Discussion
If the value could not be read, returns zero, and does not advance the stream position.
Declared In
CC3DataStreams.h