objc

NXData.h
Go to the documentation of this file.
1 
5 #pragma once
6 
8 // TYPE DEFINITIONS
9 
14 typedef enum {
15  NXHashAlgorithmMD5 = sys_hash_md5, // MD5 hash (128-bit)
16  NXHashAlgorithmSHA256 = sys_hash_sha256, // SHA-256 hash (256-bit)
18 
20 // CLASS DEFINITIONS
21 
30 @interface NXData : NXObject <JSONProtocol> {
31  void *_data;
32  size_t _size;
33  size_t _cap;
34 }
35 
39 + (NXData *)new;
40 
46 - (id)initWithCapacity:(size_t)capacity;
47 
53 - (id)initWithString:(id<NXConstantStringProtocol>)aString;
54 
61 - (id)initWithBytes:(const void *)bytes size:(size_t)size;
62 
70 + (NXData *)dataWithCapacity:(size_t)capacity;
71 
80 + (NXData *)dataWithString:(id<NXConstantStringProtocol>)aString;
81 
91 + (NXData *)dataWithBytes:(const void *)bytes size:(size_t)size;
92 
96 - (size_t)size;
97 
101 - (size_t)capacity;
102 
107 - (const void *)bytes;
108 
114 - (NXData *)hashWithAlgorithm:(NXHashAlgorithm)algorithm;
115 
119 - (NXString *)hexString;
120 
125 
129 - (void)dump;
130 
136 - (BOOL)appendString:(id<NXConstantStringProtocol>)aString;
137 
144 - (BOOL)appendBytes:(const void *)bytes size:(size_t)size;
145 
151 - (BOOL)appendData:(NXData *)data;
152 
153 @end
size_t capacity()
Returns the capacity of the data in bytes.
size_t _cap
Total allocated capacity in bytes.
Definition: NXData.h:33
size_t size()
Returns the size of the data in bytes.
NXString * base64String()
Returns a Base64 encoded string representation of the data.
NXHashAlgorithm
Hash algorithms supported by NXData.
Definition: NXData.h:14
size_t _size
Current size of valid data in bytes.
Definition: NXData.h:32
MD5 hash algorithm (128-bit output, not cryptographically secure)
Definition: hash.h:57
Protocol for constant string objects.
void dump()
Prints a hexdump representation of the data to the console.
void * _data
Raw data buffer storing the binary content.
Definition: NXData.h:31
SHA-256 hash algorithm (256-bit output, cryptographically secure)
Definition: hash.h:59
bool BOOL
A Boolean value.
Definition: runtime.h:60
const void * bytes()
Returns a pointer to the raw data bytes.
A class for managing and manipulating string objects.
Definition: NXString.h:20
NXString * hexString()
Returns a hexadecimal string representation of the data.
The base class for objects in the Foundation framework.
Definition: NXObject.h:21
NXData * new()
Return a new empty NXData instance.
struct objc_object * id
A pointer to an instance of a class.
Definition: runtime.h:18
A protocol that defines JSON methods for an Object.
Definition: JSON+Protocol.h:14
The NXData classNXData represents a structure for storing binary data.
Definition: NXData.h:30