Class NativeTextLocation
Reference to a location inside a plain text file, specified through line and offset numbers.
Inheritance
Inherited Members
Namespace: Sdl.FileTypeSupport.Framework.NativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core.dll
Syntax
public class NativeTextLocation : ICloneable, IComparable<NativeTextLocation>
Remarks
Line and offset numbers are 1-based, i.e. line number 1 is the first line in a file, and offset number 1 is the first character on the line.
Constructors
NativeTextLocation()
Creates an uninitialized instance, where line and offset are both 0.
Declaration
public NativeTextLocation()
NativeTextLocation(NativeTextLocation)
Protected constructor used in cloning
Declaration
protected NativeTextLocation(NativeTextLocation other)
Parameters
Type | Name | Description |
---|---|---|
NativeTextLocation | other |
NativeTextLocation(Int32, Int32)
Initializes with the specified line and offset numbers.
Declaration
public NativeTextLocation(int line, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | line | |
System.Int32 | offset |
Properties
Line
Line number in the text. The first line in a file is line number 1. A value of 0 indicates that the line number has not been set. Negative values are not allowed.
Declaration
public virtual int Line { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
A new line starts when one of the following character combinations are encountered:
- CR + LF (0x0c 0x0a) (treated as a single line break)
- Standalone CR (without a following LF)
- Standalone LF
Offset
Character offset on the current line. The first character on the line is offset 1. A value of 0 indicates that the offset has not be specified. Negative values are not allowed.
Declaration
public virtual int Offset { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Clone()
Returns a deep clone of this object.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object |
CompareTo(NativeTextLocation)
Returns 1 if this is after the other, -1 if this is before the other, and 0 if equal to the other.
Declaration
public int CompareTo(NativeTextLocation other)
Parameters
Type | Name | Description |
---|---|---|
NativeTextLocation | other | Must not be null |
Returns
Type | Description |
---|---|
System.Int32 |
Equals(Object)
True if both line and offset numbers are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
GetHashCode()
The hash code is computed by shifting and combining the line and offset numbers.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
IsAfter(NativeTextLocation)
True
if this instance has line and offset numbers
that indicate that it appears later in the content than the
other instance.
Declaration
public bool IsAfter(NativeTextLocation other)
Parameters
Type | Name | Description |
---|---|---|
NativeTextLocation | other | Must not be null |
Returns
Type | Description |
---|---|
System.Boolean |
IsBefore(NativeTextLocation)
True
if this instance has line and offset numbers
that indicate that it appears earlier in the content than the
other instance.
Declaration
public bool IsBefore(NativeTextLocation other)
Parameters
Type | Name | Description |
---|---|---|
NativeTextLocation | other | must not be null |
Returns
Type | Description |
---|---|
System.Boolean |
ToString()
Returns a string in the format "(line, offset)" that is intended for ease of use in debugging
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |