Okapi .NET Library

IFilter.ReadItem Method 

 [This is preliminary documentation and subject to change.]

Reads the next item of the input file or input string.

[Visual Basic]
Function ReadItem() As Integer
[C#]
int ReadItem();
[C++]
int ReadItem();
[JScript]
function ReadItem(): int;

Return Value

The type of the item processed. The value is one of the FilterItemType values.

Remarks

Use this method to read the next ietm in the current input. You must call OpenInputFile, OpenInputString, or ResetInput prior call this method a first time.

After this method has been called, you can use the GetItem method to access the different data that have been parsed from the input. The data available depend on the type of item returned (see FilterItemType for details).

Example

The following example shows how to traverse an input file using the Filter interface:

myLog.BeginProcess("Test extraction");
myFilter.OpenInputFile("myFile.xyz", "en-us", "windows-1252");
int nRes;
do
{
   nRes = myFilter.ReadItem();
   switch ( nRes )
   {
      case FiterItemType.ERROR:
         myLog.Error("An error has occurred.");
         continue;
      case FiterItemType.USERCANCEL:
         myLog.Message("Operation cancelled.");
         continue;
      case FiterItemType.ENDINPUT:
         continue; // Normal end
      case FilterItemType.TEXT:
      case FilterItemType.STARTGROUP:
      case FilterItemType.ENDGROUP:
      case FilterItemType.BINARY:
         // Do something with the item ...
         break;   
   }
} while ( nRes > FiterItemType.ENDINPUT );
myFilter.CloseInput();
myLog.EndProcess(null);

See Also

IFilter Interface | Okapi.Library.Filter Namespace | OpenInputFile | OpenInputString | ResetInput | GetItem