PTFilterWriter

@interface PTFilterWriter : NSObject

FilterWriter is a utility class providing a convenient way to write data to an output filter (using Filter directly is not very intuitive).

For example:

 StdFile outfile("file.dat", StdFile::e_write_mode);
 FilterWriter fwriter(outfile);
 fwriter.WriteBuffer(buf, buf_sz);
 fwriter.Flush();
  • Write a single character to the output stream.

    Declaration

    Objective-C

    - (void)WriteUChar:(unsigned char)ch;

    Swift

    func writeUChar(_ ch: UInt8)

    Parameters

    ch

    An unsigned character to write to the output stream.

  • Write an integer to the output stream.

    Declaration

    Objective-C

    - (void)WriteInt16:(short)num;

    Swift

    func write(_ num: Int16)

    Parameters

    num

    An integer to write to the output stream.

  • Undocumented

    Declaration

    Objective-C

    - (void)WriteUInt16: (unsigned short)num;

    Swift

    func write(_ num: UInt16)
  • Undocumented

    Declaration

    Objective-C

    - (void)WriteInt32: (int)num;

    Swift

    func write(_ num: Int32)
  • Undocumented

    Declaration

    Objective-C

    - (void)WriteUInt32: (unsigned int)num;

    Swift

    func write(_ num: UInt32)
  • Undocumented

    Declaration

    Objective-C

    - (void)WriteInt64: (long long)num;

    Swift

    func write(_ num: Int64)
  • Undocumented

    Declaration

    Objective-C

    - (void)WriteUInt64: (unsigned long long)num;

    Swift

    func write(_ num: UInt64)
  • Write a string to the output stream.

    Declaration

    Objective-C

    - (void)WriteString:(NSString *)str;

    Swift

    func write(_ str: String!)

    Parameters

    str

    A string to write to the output stream.

  • Write the entire input stream to the output stream (i.e. to this FilterWriter).

    Declaration

    Objective-C

    - (void)WriteFilter:(PTFilterReader *)reader;

    Swift

    func writeFilter(_ reader: PTFilterReader!)

    Parameters

    reader

    A FilterReader attached to an input stream.

  • Write out a null terminated ‘line’ followed by a end of line character default end of line character is carriage return.

    Declaration

    Objective-C

    - (void)WriteLine:(NSString *)line eol:(char)eol;

    Swift

    func writeLine(_ line: String!, eol: CChar)

    Parameters

    line

    string to write out.

    eol

    end of line character. Defaults to carriage return (0x0D).

  • Declaration

    Objective-C

    - (unsigned long)WriteBuffer:(NSData *)buf;

    Swift

    func writeBuffer(_ buf: Data!) -> UInt

    Parameters

    buf

    buffer object to write out.

    Return Value

    - returns the number of bytes actually written to a stream. This number may less than buf_size if the stream is corrupted.

  • Attaches a filter to the this FilterWriter.

    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!)