KeyView 23.2

# Input and Output Methods

The previous examples show KeyView taking input from a file (`keyview::io::InputFile`) and sending output to a file (`keyview::io::OutputFile`). The C++ API allows you to take input from and write output to other data sources by making use of generic types for input and output. For example, the signature of the filter method is:

    template <typename Input_Type, typename Output_Type>
    void filter(Input_Type& input, Output_Type& output);

Some input and output types are defined in `Keyview_IO.hpp`. These are InputFile, OutputFile, and InMemoryFile. You can create your own input and output types to read from and write to any data source you like.

To create a custom input type, create a class with `read`, `seek`, and `tell` methods, that reads from your data source. The methods you write must conform to the example signatures in the `keyview::InputFile` class defined in `Keyview_IO.hpp`. You can then pass instances of this into any KeyView function that takes an `InputType` (like `Session::filter` or `Session::subfiles`).

To create a custom output type, create a class with a `write` method that writes to your data source. Your `write` method must conform to the example signature in the `keyview::OutputFile` class, also defined in `Keyview_IO.hpp`. You can then pass instances of this into any KeyView function that takes an `OutputType` (like `Session::filter` or `Subfile::extract`). You can return 0 from the write method to stop the filtering process.

A class can be valid as both an `InputType` and `OutputType`.

## Partial Filtering

In some cases you might not want to filter all the text from a file, for example because the information you require is in the first half of the file. In this case you can save time by stopping the filtering process after you have what you need.

To enable partial filtering, you implement a custom `OutputType`. KeyView calls the write method you implement for each block of text that it filters. After you have the text you need, you can return 0 to stop the filtering process.

Copyright 2016-2023 Open Text
Version 23.2 | Last updated March 2023

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to swpdl.idoldocsfeedback@microfocus.com.

We appreciate your feedback!

Product: IDOL KeyView 23.2

Topic Title: Input and Output Methods