|
ArticyXImporter
ArticyXImporter for Unreal Engine
|
A class to generate and manage code files with convenience methods for generating code lines, comments, and more. More...
#include <CodeFileGenerator.h>
Public Member Functions | |
| template<typename Lambda> | |
| void | SafeExecute (Lambda Lamb) |
| Executes a lambda function safely. | |
| template<typename Lambda> | |
| CodeFileGenerator (const FString &Path, const bool bHeader, Lambda ContentGenerator) | |
| Creates a new code file generator with default lines and executes a content generator. | |
| void | Line (const FString &Line="", const bool bSemicolon=false, const bool bIndent=true, const int IndentOffset=0) |
| Adds a line to the file content. | |
| void | Comment (const FString &Text) |
| Adds a comment to the file content. | |
| void | AccessModifier (const FString &Text) |
| Adds an access modifier with optional colon. | |
| void | UPropertyMacro (const FString &Specifiers) |
| Adds a UPROPERTY macro to the file content. | |
| void | UFunctionMacro (const FString &Specifiers) |
| Adds a UFUNCTION macro to the file content. | |
| template<typename Lambda> | |
| void | Block (const bool bIndent, Lambda Content, const bool bSemicolonAtEnd=false) |
| Adds a block of code with optional indentation and semicolon. | |
| template<typename Lambda> | |
| void | Class (const FString &Classname, const FString &Comment, const bool bUClass, Lambda Content, const FString &UClassSpecifiers="BlueprintType") |
| Adds a class definition with optional UCLASS macro. | |
| template<typename Lambda> | |
| void | Struct (const FString &Structname, const FString &Comment, const bool bUStruct, Lambda Content, const FString &InlineDeclaration="") |
| Adds a struct definition with optional USTRUCT macro. | |
| template<typename Lambda> | |
| void | UInterface (const FString &Classname, const FString &UInterfaceSpecifiers, const FString &Comment, Lambda Content) |
| Adds a UINTERFACE definition with corresponding interface class. | |
| template<typename Type> | |
| void | Enum (const FString &Enumname, const FString &Comment, const bool bUEnum, TArray< Type > Values) |
| Adds an enum definition with optional UENUM macro. | |
| void | Variable (const FString &Type, const FString &Name, const FString &Value="", const FString &Comment="", const bool bUProperty=false, const FString &UPropertySpecifiers="VisibleAnywhere, BlueprintReadOnly") |
| Adds a variable definition, optionally as UPROPERTY. | |
| template<typename Lambda> | |
| void | Method (const FString &ReturnType, const FString &Name, const FString &Parameters="", Lambda Definition=nullptr, const FString &Comment="", const bool bUFunction=false, const FString &UFunctionSpecifiers="", const FString &MethodSpecifiers="") |
| Adds a method definition, optionally as UFUNCTION. | |
| template<> | |
| void | SafeExecute (nullptr_t Lamb) |
A class to generate and manage code files with convenience methods for generating code lines, comments, and more.
Holds a content string that can be written to a file and includes methods for generating code structures like classes and structs.
| CodeFileGenerator::CodeFileGenerator | ( | const FString & | Path, |
| const bool | bHeader, | ||
| Lambda | ContentGenerator ) |
Creates a new code file generator with default lines and executes a content generator.
Template constructor for CodeFileGenerator.
Adds default content such as copyright information and then calls WriteToFile.
| Lambda | The type of the content generator function. |
| Path | The path to the file to be generated. |
| bHeader | Whether the file is a header file. |
| ContentGenerator | The function generating the file content. |
Adds default content, executes the content generator, and writes to file.
| Lambda | The type of the content generator function. |
| Path | The path to the file to be generated. |
| bHeader | Whether the file is a header file. |
| ContentGenerator | The function generating the file content. |
| void CodeFileGenerator::AccessModifier | ( | const FString & | Text | ) |
Adds an access modifier with optional colon.
| Text | The access modifier text. |
| void CodeFileGenerator::Block | ( | const bool | bIndent, |
| Lambda | Content, | ||
| const bool | bSemicolonAtEnd = false ) |
Adds a block of code with optional indentation and semicolon.
| Lambda | The type of the content function. |
| bIndent | Whether to indent the block. |
| Content | The function generating the block content. |
| bSemicolonAtEnd | Whether to append a semicolon after the block. |
| void CodeFileGenerator::Class | ( | const FString & | Classname, |
| const FString & | Comment, | ||
| const bool | bUClass, | ||
| Lambda | Content, | ||
| const FString & | UClassSpecifiers = "BlueprintType" ) |
Adds a class definition with optional UCLASS macro.
| Lambda | The type of the content function. |
| Classname | The name of the class. |
| Comment | A comment describing the class. |
| bUClass | Whether the class is a UCLASS. |
| Content | The function generating the class content. |
| UClassSpecifiers | The specifiers for the UCLASS macro. |
| void CodeFileGenerator::Comment | ( | const FString & | Text | ) |
Adds a comment to the file content.
| Text | The comment text to add. |
| void CodeFileGenerator::Enum | ( | const FString & | Enumname, |
| const FString & | Comment, | ||
| const bool | bUEnum, | ||
| TArray< Type > | Values ) |
Adds an enum definition with optional UENUM macro.
| Type | The type of the enum values. |
| Enumname | The name of the enum. |
| Comment | A comment describing the enum. |
| bUEnum | Whether the enum is a UENUM. |
| Values | The values of the enum. |
| void CodeFileGenerator::Line | ( | const FString & | Line = "", |
| const bool | bSemicolon = false, | ||
| const bool | bIndent = true, | ||
| const int | IndentOffset = 0 ) |
Adds a line to the file content.
| Line | The line of code to add. |
| bSemicolon | Whether to append a semicolon at the end of the line. |
| bIndent | Whether to indent the line. |
| IndentOffset | The number of additional indentations to apply. |
| void CodeFileGenerator::Method | ( | const FString & | ReturnType, |
| const FString & | Name, | ||
| const FString & | Parameters = "", | ||
| Lambda | Definition = nullptr, | ||
| const FString & | Comment = "", | ||
| const bool | bUFunction = false, | ||
| const FString & | UFunctionSpecifiers = "", | ||
| const FString & | MethodSpecifiers = "" ) |
Adds a method definition, optionally as UFUNCTION.
| Lambda | The type of the method definition function. |
| ReturnType | The return type of the method. |
| Name | The name of the method. |
| Parameters | The parameters of the method. |
| Definition | The function defining the method. |
| Comment | A comment describing the method. |
| bUFunction | Whether to add a UFUNCTION macro. |
| UFunctionSpecifiers | The specifiers for the UFUNCTION macro. |
| MethodSpecifiers | Additional specifiers for the method. |
| void CodeFileGenerator::SafeExecute | ( | Lambda | Lamb | ) |
Executes a lambda function safely.
If the Lambda is nullptr (type nullptr_t), nothing happens.
| Lambda | The type of the lambda function to execute. |
| Lamb | The lambda function to execute. |
| void CodeFileGenerator::Struct | ( | const FString & | Structname, |
| const FString & | Comment, | ||
| const bool | bUStruct, | ||
| Lambda | Content, | ||
| const FString & | InlineDeclaration = "" ) |
Adds a struct definition with optional USTRUCT macro.
| Lambda | The type of the content function. |
| Structname | The name of the struct. |
| Comment | A comment describing the struct. |
| bUStruct | Whether the struct is a USTRUCT. |
| Content | The function generating the struct content. |
| InlineDeclaration | An optional inline declaration for the struct. |
| void CodeFileGenerator::UFunctionMacro | ( | const FString & | Specifiers | ) |
Adds a UFUNCTION macro to the file content.
| Specifiers | The specifiers for the UFUNCTION macro. |
| void CodeFileGenerator::UInterface | ( | const FString & | Classname, |
| const FString & | UInterfaceSpecifiers, | ||
| const FString & | Comment, | ||
| Lambda | Content ) |
Adds a UINTERFACE definition with corresponding interface class.
| Lambda | The type of the content function. |
| Classname | The name of the interface class. |
| UInterfaceSpecifiers | The specifiers for the UINTERFACE macro. |
| Comment | A comment describing the interface. |
| Content | The function generating the interface content. |
| void CodeFileGenerator::UPropertyMacro | ( | const FString & | Specifiers | ) |
Adds a UPROPERTY macro to the file content.
| Specifiers | The specifiers for the UPROPERTY macro. |
| void CodeFileGenerator::Variable | ( | const FString & | Type, |
| const FString & | Name, | ||
| const FString & | Value = "", | ||
| const FString & | Comment = "", | ||
| const bool | bUProperty = false, | ||
| const FString & | UPropertySpecifiers = "VisibleAnywhere, BlueprintReadOnly" ) |
Adds a variable definition, optionally as UPROPERTY.
| Type | The type of the variable. |
| Name | The name of the variable. |
| Value | The initial value of the variable. |
| Comment | A comment describing the variable. |
| bUProperty | Whether to add a UPROPERTY macro. |
| UPropertySpecifiers | The specifiers for the UPROPERTY macro. |