Implemented the DoesNotExist condition.

This commit is contained in:
ruri
2019-04-20 12:04:10 +02:00
parent 78483a1a84
commit f3552a58a1
3 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -76,7 +76,7 @@ namespace RuriLib
{
k.LeftTerm = first;
k.Condition = (Condition)LineParser.ParseEnum(ref input, "Condition", typeof(Condition));
if (k.Condition != Condition.Exists)
if (k.Condition != Condition.Exists && k.Condition != Condition.DoesNotExist)
k.RightTerm = LineParser.ParseLiteral(ref input, "Right Term");
}
@@ -128,7 +128,7 @@ namespace RuriLib
.Literal(k.LeftTerm)
.Token(k.Condition);
if (k.Condition != Condition.Exists)
if (k.Condition != Condition.Exists && k.Condition != Condition.DoesNotExist)
writer.Literal(k.RightTerm);
}
}
+7 -1
View File
@@ -28,7 +28,10 @@ namespace RuriLib
DoesNotContain,
/// <summary>Whether any variable can be replaced inside the string.</summary>
Exists
Exists,
/// <summary>Whether no variable can be replaced inside the string.</summary>
DoesNotExist
}
/// <summary>
@@ -74,6 +77,9 @@ namespace RuriLib
case Condition.Exists:
return L.Any(l => l != left); // Returns true if any replacement took place
case Condition.DoesNotExist:
return L.All(l => l == left); // Returns true if no replacement took place
default:
return false;
}
+1 -1
View File
@@ -426,7 +426,7 @@ namespace RuriLib.LS
var first = LineParser.ParseLiteral(ref cfLine, "STRING");
var condition = (Condition)LineParser.ParseEnum(ref cfLine, "CONDITION", typeof(Condition));
var second = "";
if (condition != Condition.Exists)
if (condition != Condition.Exists && condition != Condition.DoesNotExist)
second = LineParser.ParseLiteral(ref cfLine, "STRING");
return (ConditionChecker.Verify(first, condition, second, data));
}