-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.cs
More file actions
133 lines (121 loc) · 2.3 KB
/
Copy pathOptions.cs
File metadata and controls
133 lines (121 loc) · 2.3 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections.Generic;
using System.Text;
using Sid.Log;
namespace Sid.Parse.TextPatternParser
{
public class Options : HasLogImp
{
List<Options> m_SubOptions = null;
IComparisonWithAdvance m_LineWrap;
IOperation m_SkipLineWrap;
// The options. Don't forget to update 'CopyToSubOptions' when adding new options here
bool? m_CaseSensitive;
//~The options
//~V
public Options(
ILog log)
{
Log = log;
}
public void AddSubOption(
Options subOptions)
{
if (m_SubOptions == null)
{
m_SubOptions = new List<Options>();
}
m_SubOptions.Add(subOptions);
}
public bool CaseSensitive
{
get
{
if (!m_CaseSensitive.HasValue)
{
// Default to case sensitive
m_CaseSensitive = true;
}
return m_CaseSensitive.Value;
}
set
{
m_CaseSensitive = value;
}
}
public IComparisonWithAdvance LineWrap
{
get
{
return m_LineWrap;
}
set
{
bool changed = (m_LineWrap != value);
m_LineWrap = value;
if(changed)
{
// Create the skip operation
AdvanceIfOperation op= new AdvanceIfOperation(Log, m_LineWrap); ;
op.Name = "Skip linewrap";
m_SkipLineWrap = op;
}
}
}
public IOperation SkipLineWrapOperation
{
get
{
return m_SkipLineWrap;
}
}
public void CopyToSubOptions()
{
if (m_SubOptions != null)
{
foreach (Options options in m_SubOptions)
{
CopyToSubOptionsValue(m_CaseSensitive, options, ref options.m_CaseSensitive);
}
}
}
private void CopyToSubOptions<TYPE>(
TYPE thisComp,
Options options,
ref TYPE optionsComp) where TYPE : class
{
// Only update if this isn't NULL and the options version IS
if(thisComp != null && optionsComp == null)
{
optionsComp = thisComp;
}
}
private void CopyToSubOptionsValue<TYPE>(
TYPE? thisValue,
Options options,
ref TYPE? optionsValue) where TYPE : struct
{
if(thisValue.HasValue && !optionsValue.HasValue)
{
optionsValue = thisValue;
}
}
public void SkipLineWrap(
string input,
int pos,
int depth,
RunState runState,
out int index)
{
if (m_SkipLineWrap != null)
{
m_SkipLineWrap.Perform(input, pos, depth, runState, out index);
}
else
{
// Do nothing
index = pos;
}
}
}
}