FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SharpUtils/Text/StringReference.cs at master · IS4Code/SharpUtils · GitHub
IS4Code
/
SharpUtils
Public
Notifications
You must be signed in to change notification settings
Fork
13
Star
83
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
SharpUtils
/
Text
/
StringReference.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
261 lines (211 loc) · 5.28 KB
Breadcrumbs
SharpUtils
/
Text
/
StringReference.cs
Copy path
File metadata and controls
261 lines (211 loc) · 5.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/* Date: 15.7.2015, Time: 21:45 */
using
System
;
using
System
.
Linq
;
using
System
.
Text
;
using
IllidanS4
.
SharpUtils
.
Accessing
;
namespace
IllidanS4
.
SharpUtils
.
Text
{
/// <summary>
/// Represents a mutable string.
/// </summary>
public
abstract
class
StringReference
{
public
StringReference
(
)
{
}
public
abstract
void
Clear
(
)
;
public
abstract
override
string
ToString
(
)
;
public
abstract
void
Append
(
string
value
)
;
public
abstract
int
Length
{
get
;
}
public
abstract
void
Insert
(
int
index
,
string
value
)
;
public
abstract
void
Remove
(
int
startIndex
,
int
count
)
;
public
abstract
void
Replace
(
string
oldValue
,
string
newValue
)
;
public
virtual
void
Insert
(
int
index
,
string
value
,
int
count
)
{
Insert
(
index
,
String
.
Concat
(
Enumerable
.
Repeat
(
value
,
count
)
)
)
;
}
public
virtual
void
AppendLine
(
)
{
Append
(
Environment
.
NewLine
)
;
}
public
virtual
void
AppendLine
(
string
value
)
{
Append
(
value
+
Environment
.
NewLine
)
;
}
public
static
implicit
operator
StringReference
(
StringBuilder
builder
)
{
return
Create
(
builder
)
;
}
public
static
implicit
operator
StringReference
(
string
r
)
{
return
new
StringRef
(
AtomicContainer
.
Create
(
r
)
)
;
}
public
static
StringReference
Create
(
StringBuilder
builder
)
{
return
new
StringBuilderRef
(
builder
)
;
}
public
static
StringReference
Create
(
IReadWriteAccessor
<
string
>
acc
)
{
return
new
StringRef
(
acc
)
;
}
public
static
StringReference
Create
(
IReadWriteAccessor
<
StringChunk
>
acc
)
{
return
new
StringChunkRef
(
acc
)
;
}
public
static
void
Create
(
ref
string
reference
,
Action
<
StringReference
>
outputAct
)
{
ReferenceAccessor
.
Create
(
ref
reference
,
r
=>
outputAct
(
Create
(
r
)
)
)
;
}
public
static
TRet
Create
<
TRet
>
(
ref
string
reference
,
Func
<
StringReference
,
TRet
>
outputFunc
)
{
return
ReferenceAccessor
.
Create
(
ref
reference
,
r
=>
outputFunc
(
Create
(
r
)
)
)
;
}
public
static
void
Create
(
ref
StringChunk
reference
,
Action
<
StringReference
>
outputAct
)
{
ReferenceAccessor
.
Create
(
ref
reference
,
r
=>
outputAct
(
Create
(
r
)
)
)
;
}
public
static
TRet
Create
<
TRet
>
(
ref
StringChunk
reference
,
Func
<
StringReference
,
TRet
>
outputFunc
)
{
return
ReferenceAccessor
.
Create
(
ref
reference
,
r
=>
outputFunc
(
Create
(
r
)
)
)
;
}
private
sealed
class
StringBuilderRef
:
StringReference
{
readonly
StringBuilder
builder
;
public
StringBuilderRef
(
StringBuilder
builder
)
{
this
.
builder
=
builder
;
}
public
override
void
Clear
(
)
{
builder
.
Clear
(
)
;
}
public
override
string
ToString
(
)
{
return
builder
.
ToString
(
)
;
}
public
override
void
Append
(
string
value
)
{
builder
.
Append
(
value
)
;
}
public
override
void
AppendLine
(
)
{
builder
.
AppendLine
(
)
;
}
public
override
void
AppendLine
(
string
value
)
{
builder
.
AppendLine
(
value
)
;
}
public
override
int
Length
{
get
{
return
builder
.
Length
;
}
}
public
override
void
Insert
(
int
index
,
string
value
)
{
builder
.
Insert
(
index
,
value
)
;
}
public
override
void
Insert
(
int
index
,
string
value
,
int
count
)
{
builder
.
Insert
(
index
,
value
,
count
)
;
}
public
override
void
Remove
(
int
startIndex
,
int
count
)
{
builder
.
Remove
(
startIndex
,
count
)
;
}
public
override
void
Replace
(
string
oldValue
,
string
newValue
)
{
builder
.
Replace
(
oldValue
,
newValue
)
;
}
}
private
sealed
class
StringRef
:
StringReference
{
readonly
IReadWriteAccessor
<
string
>
acc
;
private
string
Item
{
get
{
return
acc
.
Item
;
}
set
{
acc
.
Item
=
value
;
}
}
public
StringRef
(
IReadWriteAccessor
<
string
>
acc
)
{
this
.
acc
=
acc
;
}
public
override
string
ToString
(
)
{
return
Item
;
}
public
override
void
Replace
(
string
oldValue
,
string
newValue
)
{
Item
=
Item
.
Replace
(
oldValue
,
newValue
)
;
}
public
override
void
Remove
(
int
startIndex
,
int
count
)
{
Item
=
Item
.
Remove
(
startIndex
,
count
)
;
}
public
override
int
Length
{
get
{
return
Item
.
Length
;
}
}
public
override
void
Insert
(
int
index
,
string
value
)
{
Item
=
Item
.
Insert
(
index
,
value
)
;
}
public
override
void
Clear
(
)
{
Item
=
String
.
Empty
;
}
public
override
void
Append
(
string
value
)
{
Item
+=
value
;
}
}
private
sealed
class
StringChunkRef
:
StringReference
{
readonly
IReadWriteAccessor
<
StringChunk
>
acc
;
private
StringChunk
Item
{
get
{
return
acc
.
Item
;
}
set
{
acc
.
Item
=
value
;
}
}
public
StringChunkRef
(
IReadWriteAccessor
<
StringChunk
>
acc
)
{
this
.
acc
=
acc
;
}
public
override
string
ToString
(
)
{
return
Item
.
ToString
(
)
;
}
public
override
void
Replace
(
string
oldValue
,
string
newValue
)
{
Item
=
Item
.
ToString
(
)
.
Replace
(
oldValue
,
newValue
)
;
}
public
override
void
Remove
(
int
startIndex
,
int
count
)
{
Item
=
Item
.
ToString
(
)
.
Remove
(
startIndex
,
count
)
;
}
public
override
int
Length
{
get
{
return
Item
.
Length
;
}
}
public
override
void
Insert
(
int
index
,
string
value
)
{
Item
=
Item
.
ToString
(
)
.
Insert
(
index
,
value
)
;
}
public
override
void
Clear
(
)
{
Item
=
default
(
StringChunk
)
;
}
public
override
void
Append
(
string
value
)
{
Item
=
Item
.
ToString
(
)
+
value
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL