forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryToken.cs
More file actions
68 lines (59 loc) · 2.24 KB
/
Copy pathQueryToken.cs
File metadata and controls
68 lines (59 loc) · 2.24 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
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
namespace UnityEditor.Search
{
/// <summary>
/// Represents a token of a query string.
/// </summary>
public readonly struct QueryToken
{
/// <summary>
/// The text representing the token.
/// </summary>
public string text { get; }
/// <summary>
/// The position of the token in the entire query string.
/// </summary>
public int position { get; }
/// <summary>
/// The length of the token. Can be different than the length of the text.
/// </summary>
public int length { get; }
internal readonly StringView stringView;
/// <summary>
/// Creates a token from a string and a position.
/// </summary>
/// <param name="text">The value of the token.</param>
/// <param name="position">The position of the token in the entire query string.</param>
public QueryToken(string text, int position)
: this(text, position, text?.Length ?? 0)
{}
/// <summary>
/// Creates a token from a string, a position and a length.
/// </summary>
/// <param name="text">The value of the token.</param>
/// <param name="position">The position of the token in the entire query string.</param>
/// <param name="length">The length of the token.</param>
public QueryToken(string text, int position, int length)
{
this.position = position;
this.length = length;
this.stringView = new StringView(text);
this.text = text;
}
internal QueryToken(in StringView stringView, int position)
: this(stringView, position, stringView.length)
{}
internal QueryToken(in StringView stringView, int position, int length)
{
this.stringView = stringView;
this.text = stringView.ToString();
this.position = position;
this.length = length;
}
internal QueryToken(int position, int length)
: this(StringView.empty, position, length)
{}
}
}