-
Notifications
You must be signed in to change notification settings - Fork 10
/
Config.cs
79 lines (65 loc) · 2.42 KB
/
Config.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Retina.Configuration
{
public class Config
{
public RegexOptions RegexOptions { get; set; }
// General configuration
public List<Limit> Limits { get; set; }
// This is only relevant for stages with multiple patterns.
// If this is true, the patterns will be chosen from greedily.
// If this is false, the patterns will be cycled through instead.
public bool Greedy { get; set; }
// If this is true, the stage's input will be used as the regex, and the first
// line of the stage will be used as the input.
public bool InputAsRegex { get; set; }
// If this is true, the matches and the separators between them
// will swap their roles.
public bool InvertMatches { get; set; }
// Custom regex modifiers
// How to treat overlapping matches.
public Overlaps Overlaps { get; set; }
// How to treat repeated matches.
public UniqueMatches UniqueMatches { get; set; }
// Require the regex to cover the entire input.
public bool Anchored { get; set; }
// General options which are interpreted differently by various stage types.
public bool Reverse { get; set; }
public bool Random { get; set; }
public string ListStart { get; set; }
public string ListSeparator { get; set; }
public string ListEnd { get; set; }
// Configuration for Output stages
public bool TrailingLinefeed { get; set; }
public bool PrintOnlyIfChanged { get; set; }
// Configuration for Split mode
public bool OmitEmpty { get; set; }
public bool OmitGroups { get; set; }
public Config()
{
Limits = new List<Limit>();
ListStart = "";
ListEnd = "";
ListSeparator = "\n";
}
public void Inherit(Config other)
{
RegexOptions ^= other.RegexOptions;
}
public void Merge(Config other)
{
RegexOptions ^= other.RegexOptions;
Limits.AddRange(other.Limits);
}
public Limit GetLimit(int i)
{
return i < Limits.Count ? Limits[i] : new Limit();
}
}
}