RuleParserInterface Class Reference

#include <ruleparser.h>

Detailed Description

Class to evaluate in-/exclusion rules from an ASCII file. The rule parser allows e.g. for simple distillation scripts.

Scripts are always executed from top to bottom.

lines that start with + "PATTERN" mean that if the pattern matches the file(s)/directory(s) will be included lines that start with - "PATTERN" mean that if the pattern matches the file(s)/directory(s) will be included lines that contain "A" -> "B" mean that if the pattern matches the file(s)/directory(s) will be renamed "->" can be combined with "+" at the same time

any path must be surrounded by quotation marks

patterns that only contain endings do not just check the pattern, but the ending itself (so .pbxproj.user will not match ".pbxproj")

conditions can be started with if "PATTERN" or ifnot "PATTERN"

lines that are enclosed with {..} will only be executed if the condition matches

Here an example script:

+ "/_bin/kernel_app.exe" -> "/kernel_app_32bit.exe" // add any files matching "/_bin/kernel_app.exe" and rename the matching part to "/kernel_app_32bit.exe"
if "/modules/" // if "/modules/" matches
{
+ ".xdl32" // add if ".xdl32" matches
}

Public Member Functions

MAXON_METHOD Result< void > Init (const Url &ruleFile, const StringDecodingRef &strDecoding)
 
MAXON_METHOD Bool Check (const String &relativeName, String *outputName)
 

Static Public Member Functions

static MAXON_METHOD RuleParserInterfaceAlloc (MAXON_SOURCE_LOCATION_DECLARATION)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (RuleParserInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.ruleparser")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( RuleParserInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.ruleparser"   
)
private

◆ Alloc()

allocator for common use.

◆ Init()

MAXON_METHOD Result<void> Init ( const Url ruleFile,
const StringDecodingRef &  strDecoding 
)

Initializes the rule set from a file.

Parameters
[in]ruleFileName of the file to read the rules from.
[in]strDecodingString Decoding that should be used for the char -> unichar conversion.
Returns
OK on success.

◆ Check()

MAXON_METHOD Bool Check ( const String relativeName,
String outputName 
)

Checks if a file matches the rule set.

Parameters
[in]relativeNameRelative name of the file, must start with "/", e.g. "/main_dev/test.cpp".
[out]outputNameCan be set to nullptr. If present the content is identical to relativeName or, if the rule set contained a rename operation, the modified name.
Returns
True if the file matched the rule set and the rule set contained no errors.