Class NcDstPieceFactory
- Namespace
- Hi.NcParsers.NcWriteback
- Assembly
- HiMech.dll
Builds the destination SyntaxPieces of an Convert(IEnumerable<SyntaxPiece>, NcDstPieceFactory, NcDiagnosticProgress) run, stamping their identity: DstFilePath on the Sentence, a DstFileIndex/line-index char segment (line index advances per produced line), and a fresh SentenceIndex drawn from AllocateSentenceIndex.
In-session callers pass the session's Allocate() (and a FileIndexCounterDependency value) so destination identities stay unique against every played piece; out-of-session callers use CreateFallback(IReadOnlyCollection<SyntaxPiece>, string), which continues numbering after the source stream's maxima.
public class NcDstPieceFactory
- Inheritance
-
NcDstPieceFactory
- Inherited Members
- Extension Methods
Properties
AllocateSentenceIndex
Allocator for fresh destination SentenceIndex values; must never return an index already used by a source piece.
public required Func<int> AllocateSentenceIndex { get; init; }
Property Value
DstFileIndex
File index used in the destination char segments.
public int DstFileIndex { get; init; }
Property Value
DstFilePath
File path stamped on each destination sentence (the output NC file); may be null.
public string DstFilePath { get; init; }
Property Value
Methods
Create(string)
Creates the next destination piece: a Sentence holding
blockText at the running line position of the
destination file, an empty JSON object (the src↔dst
Register(SyntaxPiece, SyntaxPiece) stamps the
SourceRef section), and a fresh sentence index. A multi-line
block advances the line position by its line count.
public SyntaxPiece Create(string blockText)
Parameters
blockTextstring
Returns
CreateFallback(IReadOnlyCollection<SyntaxPiece>, string)
Builds a factory for callers without a session counter: destination
sentence indices continue after the maximum source
SentenceIndex, and
DstFileIndex follows the maximum source file index.
Only safe for a single conversion over srcPieces
— a second stream with higher indices would collide; in-session
callers use the session counters instead.
public static NcDstPieceFactory CreateFallback(IReadOnlyCollection<SyntaxPiece> srcPieces, string dstFilePath = null)
Parameters
srcPiecesIReadOnlyCollection<SyntaxPiece>dstFilePathstring