HexFiend: HFByteSlice Class Reference

HexFiend

Instance Methods | List of all members
HFByteSlice Class Reference
Model

A class representing a source of data for an HFByteArray. More...

Inheritance diagram for HFByteSlice:

## Instance Methods
(unsigned long long) | - length
(void) | - copyBytes:range:
(HFByteSlice *) | - subsliceWithRange:
(HFByteSlice *) | - byteSliceByAppendingSlice:
(BOOL) | - isSourcedFromFile
(HFRange) | - sourceRangeForFile:
(HFByteRangeAttributeArray *) | - attributesForBytesInRange:

## Detailed Description

HFByteSlice is an abstract class encapsulating primitive data sources (files, memory buffers, etc.). Each source must support random access reads, and have a well defined length. All HFByteSlices are immutable.

The two principal subclasses of HFByteSlice are HFSharedMemoryByteSlice and HFFileByteSlice, which respectively encapsulate data from memory and from a file.

## Method Documentation

## § length()

- (unsigned long long) length |  |  |

Return the length of the byte slice as a 64 bit value. This is an abstract method that concrete subclasses must override.

## § copyBytes:range:()

- (void) copyBytes: |  | (unsigned char *) | dst
range: |  | (HFRange) | range

Copies a range of data from the byte slice into an in-memory buffer. This is an abstract method that concrete subclasses must override.

## § subsliceWithRange:()

- (HFByteSlice *) subsliceWithRange: |  | (HFRange) | range |

Returns a new slice containing a subrange of the given slice. This is an abstract method that concrete subclasses must override.

## § byteSliceByAppendingSlice:()

- (HFByteSlice *) byteSliceByAppendingSlice: |  | (HFByteSlice *) | slice |

Attempts to create a new byte slice by appending one byte slice to another. This does not modify the receiver or the slice argument (after all, both are immutable). This is provided as an optimization, and is allowed to return nil if the appending cannot be done efficiently. The default implementation returns nil.

## § isSourcedFromFile()

- (BOOL) isSourcedFromFile |  |  |

Returns YES if the receiver is sourced from a file. The default implementation returns NO. This is used to estimate cost when writing to a file.

## § sourceRangeForFile:()

- (HFRange) sourceRangeForFile: |  | (HFFileReference *) | reference |

For a given file reference, returns the range within the file that the receiver is sourced from. If the receiver is not sourced from this file, returns {ULLONG_MAX, ULLONG_MAX}. The default implementation returns {ULLONG_MAX, ULLONG_MAX}. This is used during file saving to to determine how to properly overwrite a given file.

## § attributesForBytesInRange:()

- (HFByteRangeAttributeArray *) attributesForBytesInRange: |  | (HFRange) | range |

Returns the attributes for the bytes in the given range.

Provided by category HFByteSlice(HFAttributes).

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

- HFByteSlice.h