ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference

 


OSData

Inherits from:
Declared In:

Overview

A container class to manage an array of bytes.



Functions

appendByte

Appends a buffer of constant data onto the end of the object's internal data buffer.

appendBytes(const OSData *)

Appends the data contained in an OSData object to the receiver.

appendBytes(const void *, unsigned int)

Appends a buffer of data onto the end of the object's internal data buffer.

ensureCapacity

Expands the size of the collection to a given storage capacity.

free

Releases all resources created or used by the OSData object.

getBytesNoCopy()

Returns a pointer to the OSData object's internal data buffer.

getBytesNoCopy(unsigned int, unsigned int)

Returns a reference into the OSData object's internal data buffer at particular offset and with a particular length.

getCapacity

Returns the capacity of the internal data buffer.

getCapacityIncrement

Returns the size by which the data buffer will grow.

getLength

Returns the length of the internal data buffer.

initWithBytes(const void *, unsigned int)

Initializes an instance of OSData that references a block of data.

initWithBytes(void *, unsigned int)

Initializes an instance of OSData that references a block of data.

initWithBytesNoCopy

Initializes an instance of OSData that references a block of data.

initWithCapacity

Initializes an instance of OSData with a minimum capacity of at least the given size.

initWithData(const OSData *)

Initializes an instance of OSData with the data provided.

initWithData(const OSData *, unsigned int, unsigned int)

Initializes an instance of OSData with a specific range of the data provided.

isEqualTo(const OSData *)

Tests the equality of two OSData objects.

isEqualTo(const OSMetaClassBase *)

Tests the equality between an OSData object and an arbitrary OSObject-derived object.

isEqualTo(const OSString *)

Tests the equality between an OSData object and an OSString object.

isEqualTo(const void *, unsigned int)

Tests the equality of an arbitrary block of data with the OSData object's internal data buffer.

serialize

Archives the receiver.

setCapacityIncrement

Sets the growth size of the data buffer.

withBytes

Creates and initializes an instance of OSData and copies in the provided data.

withBytesNoCopy

Creates and initializes an instance of OSData that references a buffer of data.

withCapacity

Creates and initializes an empty instance of OSData with a given capacity.

withData(const OSData *)

Creates and initializes an instance of OSData with the data provided.

withData(const OSData *, unsigned int, unsigned int)

Creates and initializes an instance of OSData with a specific range of the data provided.


appendByte


Appends a buffer of constant data onto the end of the object's internal data buffer.

public

virtual bool appendByte( unsigned char byte, unsigned int inCount);
Parameters
byte

A byte value to replicate as the added data.

inCount

The length of the data to add.

Return Value

Returns true if the object was able to append the new data, false otherwise.


appendBytes(const OSData *)


Appends the data contained in an OSData object to the receiver.

public

virtual bool appendBytes( const OSData *other);
Parameters
other

An OSData object.

Return Value

Returns true if appending the new data was successful, false otherwise.


appendBytes(const void *, unsigned int)


Appends a buffer of data onto the end of the object's internal data buffer.

public

virtual bool appendBytes( const void *bytes, unsigned int inLength);
Parameters
bytes

A pointer to the block of data. If the value is 0 then append zero-ed memory to the data object.

inLength

The length of the data block.

Return Value

Returns true if the object was able to append the new data, false otherwise.


ensureCapacity


Expands the size of the collection to a given storage capacity.

public

virtual unsigned int ensureCapacity( unsigned int newCapacity);
Parameters
newCapacity

The new capacity for the data buffer.

Return Value

Returns the new capacity of the data buffer or the previous capacity upon error.


free


Releases all resources created or used by the OSData object.

public

virtual void free();
Discussion

Do not call this function directly, use release() instead.


getBytesNoCopy()


Returns a pointer to the OSData object's internal data buffer.

public

virtual const void *getBytesNoCopy() const;
Return Value

Returns a reference to the OSData object's internal data buffer.


getBytesNoCopy(unsigned int, unsigned int)


Returns a reference into the OSData object's internal data buffer at particular offset and with a particular length.

public

virtual const void *getBytesNoCopy(unsigned int start, unsigned int inLength) const;
Parameters
start

The offset from the base of the internal data buffer.

inLength

The length of the data.

Return Value

Returns a pointer at a particular offset into the data buffer, or 0 if the starting offset or length are not valid.


getCapacity


Returns the capacity of the internal data buffer.

public

virtual unsigned int getCapacity() const;
Return Value

Returns an integer value for the size of the object's internal data buffer.


getCapacityIncrement


Returns the size by which the data buffer will grow.

public

virtual unsigned int getCapacityIncrement() const;
Return Value

Returns the size by which the data buffer will grow.


getLength


Returns the length of the internal data buffer.

public

virtual unsigned int getLength() const;
Return Value

Returns an integer value for the length of data in the object's internal data buffer.


initWithBytes(const void *, unsigned int)


Initializes an instance of OSData that references a block of data.

public

virtual bool initWithBytes( const void *bytes, unsigned int inLength);
Parameters
bytes

A reference to a block of data

inLength

The length of the block of data.

Return Value

Returns true if initialization was successful, false otherwise.


initWithBytes(void *, unsigned int)


Initializes an instance of OSData that references a block of data.

public

virtual bool initWithBytesNoCopy( void *bytes, unsigned int inLength);
Parameters
bytes

A reference to a block of data

inLength

The length of the block of data.

Return Value

Returns true if initialization was successful, false otherwise.


initWithBytesNoCopy


Initializes an instance of OSData that references a block of data.

public

virtual bool initWithBytesNoCopy( void *bytes, unsigned int inLength);
Parameters
bytes

A reference to a block of data

inLength

The length of the block of data.

Return Value

Returns true if initialization was successful, false otherwise.


initWithCapacity


Initializes an instance of OSData with a minimum capacity of at least the given size.

public

virtual bool initWithCapacity( unsigned int capacity);
Parameters
capacity

The length of the allocated block of data.

Return Value

Returns true if initialization was successful, false otherwise.

Discussion

Note if this function is called on an object that has been previously used then the length is set down to 0 and a new block of data is allocated if necessary to ensure the given capacity.


initWithData(const OSData *)


Initializes an instance of OSData with the data provided.

public

virtual bool initWithData( const OSData *inData);
Parameters
inData

An OSData object that provides the data to be copied.

Return Value

Returns true if initialization was successful, false otherwise.


initWithData(const OSData *, unsigned int, unsigned int)


Initializes an instance of OSData with a specific range of the data provided.

public

virtual bool initWithData( const OSData *inData, unsigned int start, unsigned int inLength);
Parameters
inData

An OSData object.

start

The starting range of data to be copied.

inLength

The length in bytes of the data to be copied.

Return Value

Returns true if initialization was successful, false otherwise.


isEqualTo(const OSData *)


Tests the equality of two OSData objects.

public

virtual bool isEqualTo( const OSData *aData) const;
Parameters
aData

The OSData object to be compared to the receiver.

Return Value

Returns true if the two objects are equivalent, false otherwise.


isEqualTo(const OSMetaClassBase *)


Tests the equality between an OSData object and an arbitrary OSObject-derived object.

public

virtual bool isEqualTo( const OSMetaClassBase *obj) const;
Parameters
obj

An OSObject-derived object.

Return Value

Returns true if the two objects are equivalent.


isEqualTo(const OSString *)


Tests the equality between an OSData object and an OSString object.

public

virtual bool isEqualTo( const OSString *obj) const;
Parameters
obj

An OSString object

Return Value

Returns true if the two objects are equivalent.


isEqualTo(const void *, unsigned int)


Tests the equality of an arbitrary block of data with the OSData object's internal data buffer.

public

virtual bool isEqualTo( const void *someData, unsigned int inLength) const;
Parameters
someData

A pointer to a block of data.

inLength

The length of the block of data.

Return Value

Returns true if the two blocks of data are equivalent, false otherwise.


serialize


Archives the receiver.

public

virtual bool serialize( OSSerialize *s) const;
Parameters
s

The OSSerialize object.

Return Value

Returns true if serialization was successful, false if not.


setCapacityIncrement


Sets the growth size of the data buffer.

public

virtual unsigned int setCapacityIncrement( unsigned increment);
Return Value

Returns the new growth size.


withBytes


Creates and initializes an instance of OSData and copies in the provided data.

public

static OSData *withBytes( const void *bytes, unsigned int inLength);
Parameters
bytes

A buffer of data.

inLength

The size of the given buffer.

Return Value

Returns an instance of OSData or 0 if a failure occurs.


withBytesNoCopy


Creates and initializes an instance of OSData that references a buffer of data.

public

static OSData *withBytesNoCopy( void *bytes, unsigned int inLength);
Parameters
bytes

A reference to a block of data.

inLength

The size of the data block.

Return Value

Returns an instance of OSData or 0 if a failure occurs.


withCapacity


Creates and initializes an empty instance of OSData with a given capacity.

public

static OSData *withCapacity( unsigned int inCapacity);
Parameters
inCapacity

The initial capacity of the OSData object in bytes.

Return Value

Returns an instance of OSData or 0 if a failure occurs.


withData(const OSData *)


Creates and initializes an instance of OSData with the data provided.

public

static OSData *withData( const OSData *inData);
Parameters
inData

An OSData object that provides the initial data.

Return Value

Returns an instance of OSData or 0 if a failure occurs.


withData(const OSData *, unsigned int, unsigned int)


Creates and initializes an instance of OSData with a specific range of the data provided.

public

static OSData *withData( const OSData *inData, unsigned int start, unsigned int inLength);
Parameters
inData

An OSData object that provides the initial data.

start

The starting index at which the data will be copied.

inLength

The number of bytes to be copied starting at index 'start'.

Return Value

Returns an instance of OSData or 0 if a failure occurs.

Member Data


reserved


protected

ExpansionData *reserved;
Discussion

Reserved for future use. (Internal use only)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.

 

Last Updated: 2008-12-19