Samples

The distribution include a number of samples as examples of how to write Flavor source files, and how to interface your C++ code to the code generated by the translator.

Description

The following sample programs are provided.

Basic
This is a very simple example of an object containing just one character. Its purpose is to demonstrate the process of creating a Flavor object in C++, and calling its put() and get() methods. The sample also includes examples of verbatim code.
 
The program accepts the bitstream file name as its single argument. It will first output the Flavor object, and then read it back in. It will also print informative messages during execution, based on the verbatim code inserted in the Flavor code.
 
Gifprint
This example includes a Flavor description of the GIF87a file structure. Note that only the headers are include. It also includes verbatim statements that will output the information contained in the GIF headers.
 
The program accepts the GIF file name as its single argument. Printing of header information is triggered by verbatim statements inserted in the Flavor source code.
 
Giftrace
This is similar to 'Gifprint', but instead of relying on user code to produce the output of header information, the automatic tracing facility of the translator is used.
 
The program accepts the GIF file name as its single argument. Note that the trace output will be directed to stdout, and it may be large (depending on the GIF file size).
 
Polymorphic
This is an example that demonstrates polymorphic parsable classes. It is identical to the example used in the Tracing section of the User's Manual.
 
The program accepts the bitstream file name as its single argument. It will first output the Flavor object, and then read it back in. The Flavor code activates automatic tracing so that the contents of the objects are printed out. The trace output will be directed to stdout.

Building the Samples

The process for building the samples depends on if you are using a UNIX or Win32 platform.

UNIX Platforms

Before building the samples, make sure that you run the configure script located in the root directory of the distribution. This only needs to be done once. This script will create appropriate Makefiles for all source code directories, taking into account the details of your particular environment.

You can then build individual samples by going to their directory and entering make.

For example, to build the basic sample enter the commands:

$ cd flavor_root
$ ./configure
$ cd samples/basic
$ make

Win32 Platforms

There are two ways to build the library in Win32 platforms, depending on if you use command-line or visual tools. If you use command-line tools, go to the directory where the sample is located and type:

    nmake -f name.mak

where name is the name of the sample. For example, to build the Basic sample enter:

    nmake -f basic.mak

You can also use different configurations, depending on if you want a debug or release version. The configurations are "name - Win32 Debug" and "name - Win32 Release". You can specify which one you want by defining the variable CFG in the nmake command line. For example:

    nmake -f basic.mak CFG="basic - Win32 Release"

By default, the debug versions are built.

The executable for each sample will be placed in the Debug or Release subdirectory of the sample's directory. These subdirectories are created as part of the build process.

If you use the Microsoft Developer Studio environment, load either the flavor.dsw workshop file (located in the root directory) and select the project corresponding to the sample you are interested in, or load directly the project file (*.dsp) from the sample's directory. Select "Win 32 - Release" or "Win32 - Debug" as the active project configuration (the debug is the default) and then build the project. As with the command line build, The executable for each sample will be placed in the Debug or Release subdirectory of the sample's directory. The project files are set up so that you can run the examples directly from the IDE.