| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
AutoGen is a tool designed for generating program files that contain repetitive text with varied substitutions. Its goal is to simplify the maintenance of programs that contain large amounts of repetitious text. This is especially valuable if there are several blocks of such text that must be kept synchronized in parallel tables.
One common example is the problem of maintaining the code required for processing program options. Processing options requires a minimum of four different constructs be kept in proper order in different places in your program. You need at least:
You will need more things besides this if you choose to implement long option names, rc/ini/config file processing, environment variables and so on. All of this can be done mechanically; with the proper templates and this program. In fact, it has already been done and AutoGen itself uses it See section Automated Option Processing. For a simple example of Automated Option processing, See section Quick Start. For a full list of the Automated Option features, See section AutoOpts Features.
| 1.1 The Purpose of AutoGen | ||
| 1.2 A Simple Example | ||
| 1.3 csh/zsh caveat | ||
| 1.4 A User’s Perspective |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The idea of this program is to have a text file, a template if you will, that contains the general text of the desired output file. That file includes substitution expressions and sections of text that are replicated under the control of separate definition files.
AutoGen was designed with the following features:
${VAR} construct in a shell here doc.
These markers are not fixed strings. They are specified at the start of
each template. Template designers know best what fits into their
syntax and can avoid marker conflicts.
We did this because it is burdensome and difficult to avoid conflicts using either M4 tokenization or C preprocessor substitution rules. It also makes it easier to specify expressions that transform the value. Of course, our expressions are less cryptic than the shell methods.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This is just one simple example that shows a few basic features.
If you are interested, you also may run "make check" with the
VERBOSE environment variable set and see a number of other
examples in the ‘agen5/test/testdir’ directory.
Assume you have an enumeration of names and you wish to associate some string with each name. Assume also, for the sake of this example, that it is either too complex or too large to maintain easily by hand. We will start by writing an abbreviated version of what the result is supposed to be. We will use that to construct our output templates.
In a header file, ‘list.h’, you define the enumeration and the global array containing the associated strings:
typedef enum {
IDX_ALPHA,
IDX_BETA,
IDX_OMEGA } list_enum;
extern char const* az_name_list[ 3 ];
|
Then you also have ‘list.c’ that defines the actual strings:
#include "list.h"
char const* az_name_list[] = {
"some alpha stuff",
"more beta stuff",
"final omega stuff" };
|
First, we will define the information that is unique for each enumeration name/string pair. This would be placed in a file named, ‘list.def’, for example.
autogen definitions list;
list = { list_element = alpha;
list_info = "some alpha stuff"; };
list = { list_info = "more beta stuff";
list_element = beta; };
list = { list_element = omega;
list_info = "final omega stuff"; };
|
The autogen definitions list; entry defines the file as an AutoGen
definition file that uses a template named list. That is followed by
three list entries that define the associations between the
enumeration names and the strings. The order of the differently named
elements inside of list is unimportant. They are reversed inside of the
beta entry and the output is unaffected.
Now, to actually create the output, we need a template or two that can be expanded into the files you want. In this program, we use a single template that is capable of multiple output files. The definitions above refer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘list.tpl’.
It looksrefer to a ‘list’ template, so it would normally be named, ‘l