Open topic with navigation
Avoid unnecessary initialization.
The context variable is allocated in
fpAllocateContext(). This structure must be immediately
memset() to zero. This sets all
BOOL values to
FALSE, all pointers to
NULL, and all integers to
0. Only non-zero, non-
BOOLs that must be
TRUE need to be initialized. This is best done in
Know where you are in the input source file.
If you are processing headers, footers, notes, or (in the case of
rtfsr) tables, you must be able to reposition the file pointer as required.
Check buffer boundaries continuously.
Whenever you advance through the buffer, you need to know whether there is enough of the input stream to completely process the current command. If not, you need to append the next section of the input file before continuing.
Strive for a "clean" token stream.
filtertest with the
-d command-line option to generate a token version of the document. If there are redundant tokens, the reader is producing an inefficient token stream. You can keep the token stream free from redundancies by storing the state of the document and then applying the changes only when content is encountered. Content can be text, tabs, or picture objects. The
filtertest.exe is in the directory
install is the path name of the Filter installation directory.
switch() statements whenever possible. They make both development and debugging more complicated than necessary. If there is a fixed set of commands, consider using a hash table that enables you to quickly identify a pointer to the function that handles that command.
Filtering document metadata is a separate process.
fpGetSummaryInfo() is a completely separate process from the rest of your code. It creates its own context variable structure. It does not have to call
Use caution when processing headers, footers, and notes.
If you need to process these items, the structured access layer calls
fpCloseStream(). It is critical that you save the state of your document and the file pointer position prior to returning from
fpOpenStream(). Prior to returning from
fpCloseStream(), you must restore the file pointer and the previous state of your document.
Test your code.
The structured access layer for each SDK is unique. Test your code in Filter SDK, Export SDK, and Viewing SDK.