Go to file
Speiger d5a47ce568 Added Iteration support.
Said support allows to use the #iterate & #argument #enditerate
parameters.
Which will duplicate the text block inside of it x amount of times with
arguments being replaced.

The idea being that if code can be replicated the iterate option would
simplify the process.

Multiple arguments can be defined (they will be not part of the output)
and it will simply insert them.
Note that all argument parameters have to be equal size.
Otherwise the iterator processor will fail.

Iterators can be stacked too to create layers upon layers.

On top of that the iterator is part of the Template parser and not of
the template processor meaning its a Pre processor step.
And all mappers still apply themselves on to the output of the
iterators!
2023-06-27 13:29:31 +02:00
.settings Added Iteration support. 2023-06-27 13:29:31 +02:00
example Added Iteration support. 2023-06-27 13:29:31 +02:00
gradle/wrapper Initial Repo Data 2021-01-11 13:02:39 +01:00
src Added Iteration support. 2023-06-27 13:29:31 +02:00
.classpath Initial Repo Data 2021-01-11 13:02:39 +01:00
.gitignore Disabled the right file. 2021-06-21 17:02:18 +02:00
.project Initial Repo Data 2021-01-11 13:02:39 +01:00
LICENSE Update License 2021-01-11 17:49:54 +01:00
README.md updated readme 2022-05-21 19:45:31 +02:00
build.gradle Added Iteration support. 2023-06-27 13:29:31 +02:00
gradlew Initial Repo Data 2021-01-11 13:02:39 +01:00
gradlew.bat Initial Repo Data 2021-01-11 13:02:39 +01:00
settings.gradle Cleanup of gradle 2021-01-11 13:48:39 +01:00

README.md

Simple-Code-Generator

This Tool is a very Simple Code Generator that can read a template file and segment it based on a Set of variables that can be defined. Separate to that this tool can replace text via simple Regular Expression mapping. It has a cache that keeps track of the input (if it was changed), and only cares that the file format is Text based.

It is as bare bones as it can get but that also makes it flexible.

How to install

Using Gradle:

repositories {
    maven {
        url = "https://maven.speiger.com/repository/main"
    }
}
dependencies {
	compile 'de.speiger:Simple-Code-Generator:1.1.4'
}

How to create a Template Processor

Create a class that extends TemplateProcessor.
And run the process method
SourceFolder: Is the folder that is traversed through and Files are given back.
OutputFolder: Is the folder where the Processed files get put into. If the "relativePackages" are set to true then the source folder structure is transferred.
DataFolder: Is the folder where the input cache is stored. It uses a MD5 generator to compare inputs. Right now only FileNames without extensions are stored in there.
So no Duplicated FileName support for now.

Methods:

init: Is called when the Processes was started for the first time.
isFileValid: The Method that checks if a File can be used for a template.
relativePackages: If the Folder Structure from the SourceFolder should be transferred to the OutputFolder.
createProcesses: The Main Function that provides the FileName (without extension) and a consumer of how the file should be processed.
A TemplateProcess is a Collection of Variables that is used for File Segmentation and a List of UnaryOperators that allow to edit the build code.
A Simple sum up: Template Process is Tuple<Set, List> that also contains the new FileName.

package test.example;

public class ExampleClass
{
#if METHOD_ONE
	public void methodOne() {}
#else if METHOD_TWO && !SKIP
	public void methodTwo() {}
#else
	public void methodThree() {}
#endif
}

If the Variable "METHOD_ONE" is present only the code in the if is parsed into the template process.
If the Variable "METHOD_TWO" is present and the "SKIP" Variable is missing then the code in the else if block is parsed into the template process
Otherwise the else block is included.
Whenever a if is started, it has to end with a #endif, Even if the last condition is a else if or a else.
Recursion is supported and necessary