refactored SearchExpression
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
namespace ParadoxSaveParser.Lib;
|
||||
|
||||
/// <summary>"(a|b)" — matches if any alternative does.</summary>
|
||||
internal sealed class MultipleMatchExpression(List<ISearchExpression> subExprs) : ISearchExpression
|
||||
{
|
||||
public bool DoesMatch(MatchCandidate candidate, out ISearchExpression? nextSearchExpression)
|
||||
{
|
||||
// the first matching alternative wins
|
||||
foreach (var e in subExprs)
|
||||
if (e.DoesMatch(candidate, out nextSearchExpression))
|
||||
return true;
|
||||
|
||||
nextSearchExpression = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void ReEncode(Encoding encoding)
|
||||
{
|
||||
foreach (var e in subExprs)
|
||||
e.ReEncode(encoding);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user