// Copyright Epic Games, Inc. All Rights Reserved.
using System.Collections.Generic;
namespace EpicGames.Perforce
{
///
/// Wrapper for a list of filespecs. Allows implicit conversion from string (a single entry) or list.
///
public struct FileSpecList
{
///
/// Empty filespec list
///
public static FileSpecList Empty { get; } = new FileSpecList(new List());
///
/// Matches any files in the depot
///
public static FileSpecList Any { get; } = new FileSpecList(new List { "//..." });
///
/// The list of filespecs
///
public IReadOnlyList List { get; }
///
/// Private constructor. Use implicit conversion operators below instead.
///
/// List of filespecs
private FileSpecList(IReadOnlyList fileSpecList)
{
List = fileSpecList;
}
///
/// Implicit conversion operator from a list of filespecs
///
/// The list to construct from
public static implicit operator FileSpecList(List list)
{
return new FileSpecList(list);
}
///
/// Implicit conversion operator from an array of filespecs
///
/// The array to construct from
public static implicit operator FileSpecList(string[] array)
{
return new FileSpecList(array);
}
///
/// Implicit conversion operator from a single filespec
///
/// The single filespec to construct from
public static implicit operator FileSpecList(string fileSpec)
{
return new FileSpecList(new string[] { fileSpec });
}
}
}