02 Config Value File - oldgreydog/CodeGenerator GitHub Wiki

The config values file holds the values that are substituted into the template when the template is evaluated. It is an XML file with a very simple tree structure that lets you create as complex a definition of your functional domain as you need. Here is an example taken from the ConfigVariable documentation:

<?xml version="1.0" encoding="UTF-8"?>
<Node name="root">
    <Node name="global">
        <Value name="databaseName">Operations</Value>
        <Value name="packageName">codegenerator.examples.operations</Value>
        <Value name="outputPath">/home/dev/temp/code_generator/operations_db</Value>
    </Node>
    <Node name="table">
        <Value name="className">User</Value>
        <Value name="sqlName">USER</Value>
        <Node name="column">
            <Value name="name">UserId</Value>
            <Value name="sqlName">USER_ID</Value>
            <Value name="memberName">userId</Value>
            <Value name="type">int</Value>
            <Value name="isNullable">false</Value>
            <Value name="isPrimaryKey">true</Value>
        </Node>
        <Node name="column">
            <Value name="name">LoginName</Value>
            <Value name="sqlName">LOGIN_NAME</Value>
            <Value name="memberName">loginName</Value>
            <Value name="type">varchar</Value>
            <Value name="valueMaxSize">50</Value>
            <Value name="isNullable">false</Value>
            <Value name="isPrimaryKey">false</Value>
        </Node>

        ...

    </Node>

    ...

</Node>

This XML format comes from the ConfigManager in CoreUtils. The <Node>s can hold <Node>s and <Value>s. The <Value>s only contain a string value. Both tags have a required "name" attribute and an optional "description" attribute. You can make your config file as simple or complex as your templates require with this structure.

If you can agree on a config values file structure with other people, then you can each create template sets that can generate solutions in different languages and/or tool sets. For example, if you used the database-oriented example above, then you could combine templates from multiple sources to generate database access code for every language used in your project. Any database definition changes that you make in the config file or changes to the templates can be almost instantly updated across the whole code base. Even if that is thousands of files.

And since this generator isn't limited to code, you can generate any other text files that you need, too. For example, the example templates have a template that will generate a DDL file at the same time as the database access code.

And you aren't limited to database code. You could set up config value files and templates to generate web pages, GUI apps or project files. Or whatever.

⚠️ **GitHub.com Fallback** ⚠️