PTFilterReader

@interface PTFilterReader : NSObject

FilterReader is a utility class providing a convenient way to read data from an input filter (using Filter directly is not very intuitive).

For example:

 StdFile file("my_stream.txt", StdFile::e_read_mode);
 FilterReader reader(file);
 while (reader.Read(...)) ...
  • Declaration

    Objective-C

    - (int)Get;

    Swift

    func get() -> Int32

    Return Value

    - the next character from the stream or EOF (-1) if the end of file is reached.

  • Declaration

    Objective-C

    - (int)Peek;

    Swift

    func peek() -> Int32

    Return Value

    - the next character without extracting it from the stream or or EOF (-1) if the end of file is reached.

  • Declaration

    Objective-C

    - (NSData *)Read:(unsigned long)buf_size;

    Swift

    func read(_ buf_size: UInt) -> Data!

    Return Value

    - returns the number of bytes actually read and stored in buffer (buf), which may be less than buf_size if the end of the stream is encountered before reaching count.

  • Attaches a filter to the this FilterReader.

    Declaration

    Objective-C

    - (void)AttachFilter:(PTFilter *)filter;

    Swift

    func attach(_ filter: PTFilter!)

    Parameters

    filter

    filter object to attach

  • Declaration

    Objective-C

    - (PTFilter *)GetAttachedFilter;

    Swift

    func getAttachedFilter() -> PTFilter!

    Return Value

    - The attached Filter or a NULL filter if no filter is attached.

  • Sets the position within the current stream.

    Note

    - After each Seek() operation the number of consumed bytes (i.e. Count()) is set to 0. @exception - throws an exception if the method is not implemented in the associated filter.

    Declaration

    Objective-C

    - (void)Seek:(unsigned long long)offset origin:(PTReferencePos)origin;

    Swift

    func seek(_ offset: UInt64, origin: PTReferencePos)

    Parameters

    offset

    - A byte offset relative to origin. If offset is negative, the new position will precede the position specified by origin by the number of bytes specified by offset. If offset is zero, the new position will be the position specified by origin. If offset is positive, the new position will follow the position specified by origin by the number of bytes specified by offset.

    origin

    - A value of type ReferencePos indicating the reference point used to obtain the new position

  • Reports the current read position in the stream relative to the stream origin.

    Declaration

    Objective-C

    - (unsigned long long)Tell;

    Swift

    func tell() -> UInt64

    Return Value

    - The current position in the stream @exception - throws an exception if the method is not implemented in the associated filter.

  • Declaration

    Objective-C

    - (unsigned long)Count;

    Swift

    func count() -> UInt

    Return Value

    - the number of bytes consumed since opening the filter or since the last Seek operation.

  • Forces any data remaining in the buffer to be written to input or output filter.

    Declaration

    Objective-C

    - (void)Flush;

    Swift

    func flush()
  • Forces any data remaining in the filter chain to the source or destination.

    Declaration

    Objective-C

    - (void)FlushAll;

    Swift

    func flushAll()
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)init;

    Swift

    init!()
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithFilter: (PTFilter*)filter;

    Swift

    init!(filter: PTFilter!)