Click or drag to resize
LineNumberTracker Class
Native content processor implementation that tracks line and offset number for content passed through the native API.
Inheritance Hierarchy
SystemObject
  Sdl.FileTypeSupport.Framework.NativeApiAbstractNativeFileTypeComponent
    Sdl.FileTypeSupport.Framework.NativeApiAbstractNativeExtractionGenerationContentProcessor
      Sdl.FileTypeSupport.Framework.Core.Utilities.NativeApiLineNumberTracker

Namespace: Sdl.FileTypeSupport.Framework.Core.Utilities.NativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core.Utilities (in Sdl.FileTypeSupport.Framework.Core.Utilities.dll) Version: 1.0.0.0 (1.0.2551.0)
Syntax
public class LineNumberTracker : AbstractNativeExtractionGenerationContentProcessor

The LineNumberTracker type exposes the following members.

Constructors
  NameDescription
Public methodLineNumberTracker
Initializes a new instance of the LineNumberTracker class
Top
Properties
  NameDescription
Public propertyLastCharacterWasCR
If true, the last processed character was a CR (0x0d). This flag is used to determine whether an LF character (0x0a) should increment the line count or not, since CR + LF is counted as a single line break character.
Public propertyLine
1-based value that expresses the number of characters that have passed through the tag and text content of this processor since the last line break.
Protected propertyLineBeforeIncrement
Accessor to the field holding the value that is set to the current line number before it is incremented in the IncrementLineAndOffsetNumbers(String) implementation. Implementations that override that method without calling the base class may need to set this property. The value is used in the implementation of GetLocationBeforeCurrentContent.
Public propertyOffset
1-based index that expresses the number of line break characters that have passed through the tag and text content of this processor.
Protected propertyOffsetBeforeIncrement
Accessor to the field holding the value that is set to the current offset number before it is incremented in the IncrementLineAndOffsetNumbers(String) implementation. Implementations that override that method without calling the base class may need to set this property. The value is used in the implementation of GetLocationBeforeCurrentContent.
Top
Methods
  NameDescription
Public methodGetCurrentLocation
Returns a text location that corresponds to the current line and offset numbers.
Public methodGetLocationAfterCurrentContent
Gets the current line and offset values, i.e. after the last increment.
Public methodGetLocationBeforeCurrentContent
Gets the line and offset values as they were before the last increment.
Protected methodIncrementLineAndOffsetNumbers
This method gets called for each text and tag content that is processed. The implementation parses text for CR and LF and updates the Line and Offset properties accordingly.
Public methodInlineEndTag
Counts line breaks and characters inside tags.
(Overrides AbstractNativeExtractionGenerationContentProcessorInlineEndTag(IEndTagProperties).)
Public methodInlinePlaceholderTag
Counts line breaks and characters inside tags.
(Overrides AbstractNativeExtractionGenerationContentProcessorInlinePlaceholderTag(IPlaceholderTagProperties).)
Public methodInlineStartTag
Counts line breaks and characters inside tags.
(Overrides AbstractNativeExtractionGenerationContentProcessorInlineStartTag(IStartTagProperties).)
Public methodParseText
Returns the number of lines and characters after the last line break in the text. Does not update any of the member variables.
Public methodStructureTag
Counts line breaks and characters inside structure tags.
(Overrides AbstractNativeExtractionGenerationContentProcessorStructureTag(IStructureTagProperties).)
Public methodText
Counts line breaks and characters inside normal text.
(Overrides AbstractNativeExtractionGenerationContentProcessorText(ITextProperties).)
Top
Remarks

This is intended to be used for components related to native text location message reporting, where line and offset numbers is the means of specifying a location for an error message.

Both line and offset numbers are 1-based, i.e. the first line in a file is line 1, and the first character on a line is character offset 1.

Line and offsets are calculated by looking at the text and tag properties passed through the content processor. Any text or tag content that contains a line break increments the current line number. The offset is reset to 1 after each line break and is incremented by 1 for each Unicode character after the line break.

Text and tags inside locked content are counted too.

The following is considered a line break character: a combination of CR+LF, a standalone LF, or a standalone CR. A CR+LF is counted as one single line break (CR = 0x0d, LF = 0x0a).

The current line and offset numbers can be read from the Line and Offset properties. These properties can also be written to, which could be useful if the values need to be adjusted.

See Also
Community
Edit

Be the first to Edit the community content of this topic.
Comments