objc

Instance Methods | Class Methods | Protected Attributes
NXData Class Reference

The NXData classNXData represents a structure for storing binary data. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXData:
Inheritance graph
[legend]
Collaboration diagram for NXData:
Collaboration graph
[legend]

Instance Methods

(id- initWithCapacity:
 Initializes a new NXData instance with the specified capacity. More...
 
(id- initWithString:
 Initializes a new NXData instance with a copy of the specified string. More...
 
(id- initWithBytes:size:
 Initializes a new NXData instance with a copy of bytes. More...
 
(size_t) - size
 Returns the size of the data in bytes.
 
(size_t) - capacity
 Returns the capacity of the data in bytes.
 
(const void *) - bytes
 Returns a pointer to the raw data bytes. More...
 
(NXData *) - hashWithAlgorithm:
 Creates a new NXData instance with a hash of the data. More...
 
(NXString *) - hexString
 Returns a hexadecimal string representation of the data.
 
(NXString *) - base64String
 Returns a Base64 encoded string representation of the data.
 
(void) - dump
 Prints a hexdump representation of the data to the console.
 
(BOOL- appendString:
 Appends a string to the data. More...
 
(BOOL- appendBytes:size:
 Appends raw bytes to the data. More...
 
(BOOL- appendData:
 Appends another NXData instance to this data, by copying its contents. More...
 
- Instance Methods inherited from NXObject
(id- retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id- autorelease
 Adds the receiver to the autorelease pool.
 
- Instance Methods inherited from Object
(void) - dealloc
 Free resources for an existing instance.
 
(id- init
 Initialize the instance, after allocation. More...
 
(Class- class
 Returns the class of the instance. More...
 
(Class- superclass
 Returns the superclass of the instance. More...
 
(BOOL- isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL- isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL- conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
(NXString *) - description
 Returns a string that represents the instance. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL- respondsToSelector:
 Checks if the receiver responds to a selector. More...
 
- Instance Methods inherited from <JSONProtocol>
(NXString *) - JSONString
 Returns a JSON representation of the instance. More...
 
(size_t) - JSONBytes
 Returns the appropriate capacity for the JSON representation of the instance. More...
 

Class Methods

(NXData *) + new
 Return a new empty NXData instance.
 
(NXData *) + dataWithCapacity:
 Returns a new NXData instance with the specified capacity. More...
 
(NXData *) + dataWithString:
 Returns a new NXData instance with a copy of the specified string. More...
 
(NXData *) + dataWithBytes:size:
 Returns a new NXData instance with a copy of bytes. More...
 
- Class Methods inherited from NXObject
(id+ allocWithZone:
 Allocates a new instance of an object in a specific memory zone. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(id+ alloc
 Allocate a new class instance. More...
 
(Class+ class
 Returns the class object. More...
 
(Class+ superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL+ conformsTo:
 Checks if the class conforms to a protocol. More...
 
(NXString *) + description
 Returns a string that represents the class. More...
 

Protected Attributes

void * _data
 Raw data buffer storing the binary content.
 
size_t _size
 Current size of valid data in bytes.
 
size_t _cap
 Total allocated capacity in bytes.
 
- Protected Attributes inherited from NXObject
id _zone
 The memory zone where the object is allocated.
 
unsigned short _retain
 The retain count of the object.
 
id _next
 The next object in an autorelease pool.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The NXData class

NXData represents a structure for storing binary data.

Definition at line 30 of file NXData.h.

Method Documentation

◆ appendBytes:size:()

- (BOOL) appendBytes: (const void *)  bytes
size: (size_t)  size 

Appends raw bytes to the data.

Parameters
bytesThe bytes to append.
sizeThe number of bytes to append.
Returns
YES if successful, NO otherwise.

◆ appendData:()

- (BOOL) appendData: (NXData *)  data

Appends another NXData instance to this data, by copying its contents.

Parameters
dataThe data to append.
Returns
YES if successful, NO otherwise.

◆ appendString:()

- (BOOL) appendString: (id< NXConstantStringProtocol >)  aString

Appends a string to the data.

Parameters
aStringThe string to append.
Returns
YES if successful, NO otherwise.

◆ bytes()

- (const void *) bytes

Returns a pointer to the raw data bytes.

Returns
A pointer to the raw data bytes, or NULL if the data is empty.

◆ dataWithBytes:size:()

+ (NXData *) dataWithBytes: (const void *)  bytes
size: (size_t)  size 

Returns a new NXData instance with a copy of bytes.

Parameters
bytesThe bytes to copy.
sizeThe number of bytes to copy.
Returns
A new NXData instance containing a copy of the specified bytes.

This method allocates a new NXData instance and copies the contents of the specified bytes into it.

◆ dataWithCapacity:()

+ (NXData *) dataWithCapacity: (size_t)  capacity

Returns a new NXData instance with the specified capacity.

Parameters
capacityThe initial capacity of the data, in bytes.
Returns
A new NXData instance with the specified capacity.

This method allocates a new NXData instance with the specified capacity.

◆ dataWithString:()

+ (NXData *) dataWithString: (id< NXConstantStringProtocol >)  aString

Returns a new NXData instance with a copy of the specified string.

Parameters
aStringThe string to copy.
Returns
A new NXData instance containing a copy of the specified string.

This method allocates a new NXData instance and copies the contents of the specified string into it.

◆ hashWithAlgorithm:()

- (NXData *) hashWithAlgorithm: (NXHashAlgorithm algorithm

Creates a new NXData instance with a hash of the data.

Parameters
algorithmThe hash algorithm to use.
Returns
A new NXData instance containing the hash of the data.

◆ initWithBytes:size:()

- (id) initWithBytes: (const void *)  bytes
size: (size_t)  size 

Initializes a new NXData instance with a copy of bytes.

Parameters
bytesThe bytes to copy.
sizeThe number of bytes to copy.
Returns
A new NXData instance containing a copy of the specified bytes.

◆ initWithCapacity:()

- (id) initWithCapacity: (size_t)  capacity

Initializes a new NXData instance with the specified capacity.

Parameters
capacityThe initial capacity of the data, in bytes.
Returns
A new NXData instance with the specified capacity.

◆ initWithString:()

- (id) initWithString: (id< NXConstantStringProtocol >)  aString

Initializes a new NXData instance with a copy of the specified string.

Parameters
aStringThe string to copy.
Returns
A new NXData instance containing a copy of the specified string.

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