|
Writing a File Parser
File parsers should be contained in a set of source and include files as
follows, where XXX represents a mnemonic for the data format. For specific examples, see the
sample ASCII filter files identified in the following table.
Generic file name
| Contents
| Sample ASCII filter file
| VS_XXX.C
| Code
| VS_ASC.C
| VSD_XXX.C
| Data
| VSD_ASC.C
| VS_XXX.H
| Type definitions
| VS_ASC.H
| VSP_XXX.H
| Portability information
| VSP_ASC.H
|
The portability information file makes porting of filters platforms easier. To
allow file parsers to be used for content indexing, a set of include files is
provided that will allow conditional compilations to yield executable DLLs for
all of these needs from the same set of source files.
Your VSP_XXX.H file should look something like the following. (For further information,
see the corresponding ASCII filter file.)
- The structure type and name of the static data.
#define VwStreamStaticType ???
#define VwStreamStaticName ???
The parser must not change the contents of the structure, because it is shared
among all instances of the parser.
- The structure type and name of the dynamic data.
#define VwStreamDynamicType ???
#define VwStreamDynamicName ???
VwStreamDynamicName is for consistency and has no real use, because all dynamic data is accessed
through the pseudonym Proc. Each instance of the parser has a separate copy of dynamic data.
- The structure type and name of the save data.
#define VwStreamSaveType ???
#define VwStreamSaveName ???
VwStreamSaveName should reference an element in the VwStreamDynamicType structure. The data in this structure is saved after every call to VwStreamSectionFunc and VwStreamReadFunc and restored before every call to VwStreamReadFunc.
- The structure type and name of the section data.
#define VwStreamSectionType ???
#define VwStreamSectionName ???
If neither of these is defined, the file parser is assumed to be single section only. VwStreamSectionName should reference an element in the VwStreamDynamicType structure. The data in this structure is saved after each call to VwStreamSectionFunc and is guaranteed to contain the current section's data on entry to VwStreamReadFunc.
This example shows the relationship of the various save areas to the dynamic
data structure.
typedef struct {
...
} VwStreamSaveType;
typedef struct {
...
} VwStreamSectionType;
typedef struct {
...
VwStreamSectionType VwStreamSectionName; // multisection only
VwStreamSaveType VwStreamSaveName;
} VwStreamDynamicType;
- The stream identifier name and count.
#define VwStreamIdName ???
#define VwStreamIdCount ???
VwStreamIdName is the name of the FILTER_DESC array in VSD_XXX.C, and VwStreamIdCount is the number of elements in this array. Like the static data, this data
should never be changed by a parser.
- The name of the include file. All the structure types used by the parser
should be defined in this file.
#define VwInclude "vs_xxx.h"
#define VwStreamUserSaveType ???
#define VwStreamGenSeekName ???
#define VwStreamOpenFunc xxx_stream_open
#define VwStreamSeekFunc xxx_stream_seek
#define VwStreamTellFunc xxx_stream_tell
#define VwStreamReadFunc xxx_stream_read
#define VwStreamReadRecordFunc xxx_stream_readrecord
#define VwStreamSectionFunc xxx_stream_section
#define VwStreamCloseFunc xxx_stream_close
#define VwGetInfoFunc xxx_getinfo
#define VwGetRtnsFunc xxx_getrtns
#define VwGetDataFunc xxx_getdata
#define VwSetDataFunc xxx_setdata
#define VwAllocProcFunc xxx_alloc_proc
#define VwFreeProcFunc xxx_free_proc
#define VwLocalUpFunc xxx_local_up
#define VwLocalDownFunc xxx_local_down
#define VwGetSectionDataFunc xxx_getsectiondata
#define VwSetSectionDataFunc xxx_setsectiondata
- The top of the VS_XXX.C file should look like this.
#include "VSP_XXX.H"
#include "VSCTOP.H"
#include "VS_XXX.PRO"
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|