2018-05-18 05:43:07 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2019-07-14 22:06:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Processes input of strings into a list of valid Filters and Instructions.
|
|
|
|
|
/// </summary>
|
2018-05-18 05:43:07 +00:00
|
|
|
|
public class StringInstructionSet
|
|
|
|
|
{
|
|
|
|
|
public IList<StringInstruction> Filters { get; private set; }
|
|
|
|
|
public IList<StringInstruction> Instructions { get; private set; }
|
|
|
|
|
|
|
|
|
|
private const string SetSeparator = ";";
|
2018-07-29 20:27:48 +00:00
|
|
|
|
|
2018-05-22 00:04:02 +00:00
|
|
|
|
public static IEnumerable<StringInstructionSet> GetBatchSets(IList<string> lines)
|
2018-05-18 05:43:07 +00:00
|
|
|
|
{
|
|
|
|
|
int start = 0;
|
2018-05-22 00:04:02 +00:00
|
|
|
|
while (start < lines.Count)
|
2018-05-18 05:43:07 +00:00
|
|
|
|
{
|
|
|
|
|
var list = lines.Skip(start).TakeWhile(_ => !lines[start++].StartsWith(SetSeparator)).ToList();
|
|
|
|
|
yield return GetBatchSet(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 00:04:02 +00:00
|
|
|
|
private static StringInstructionSet GetBatchSet(ICollection<string> set)
|
2018-05-18 05:43:07 +00:00
|
|
|
|
{
|
|
|
|
|
return new StringInstructionSet
|
|
|
|
|
{
|
|
|
|
|
Filters = StringInstruction.GetFilters(set).ToList(),
|
|
|
|
|
Instructions = StringInstruction.GetInstructions(set).ToList(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|