using System;
using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core;
///
/// Processes input of strings into a list of valid Filters and Instructions.
///
public sealed class StringInstructionSet
{
public readonly IReadOnlyList Filters;
public readonly IReadOnlyList Instructions;
private const string SetSeparator = ";";
public StringInstructionSet(IReadOnlyList filters, IReadOnlyList instructions)
{
Filters = filters;
Instructions = instructions;
}
public StringInstructionSet(ICollection set)
{
Filters = StringInstruction.GetFilters(set).ToList();
Instructions = StringInstruction.GetInstructions(set).ToList();
}
public static IEnumerable GetBatchSets(IList lines)
{
int start = 0;
while (start < lines.Count)
{
var list = lines.Skip(start).TakeWhile(_ => !lines[start++].StartsWith(SetSeparator, StringComparison.Ordinal)).ToList();
yield return new StringInstructionSet(list);
}
}
}