IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.CoreLib.Text.EncodingSpanWriter Struct Reference

Provides an interface to write text to a Span<byte>. More...

Public Member Functions

 EncodingSpanWriter (Encoding encoding, Span< byte > span)
 Initializes a new instance.
 
void Write (string text)
 Writes the text to the span, advancing the current position.
 
void Write (scoped ReadOnlySpan< char > text)
 Writes the text to the span, advancing the current position.
 
void WriteLine ()
 Writes a line feed to the span.
 

Public Attributes

readonly Encoding _encoding
 
Span< byte > _span
 
int _bytesWritten
 
int _charsWritten
 

Properties

readonly int BytesWritten [get]
 Gets the number of bytes written.
 
readonly int CharsWritten [get]
 Gets the number of characters written.
 

Detailed Description

Provides an interface to write text to a Span<byte>.

Template Parameters
T

Definition at line 11 of file EncodingSpanWriter.cs.

Constructor & Destructor Documentation

◆ EncodingSpanWriter()

IKVM.CoreLib.Text.EncodingSpanWriter.EncodingSpanWriter ( Encoding encoding,
Span< byte > span )

Initializes a new instance.

Parameters
encoding
span

Definition at line 24 of file EncodingSpanWriter.cs.

25 {
26 _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding));
27 _span = span;
28 }

Member Function Documentation

◆ Write() [1/2]

void IKVM.CoreLib.Text.EncodingSpanWriter.Write ( scoped ReadOnlySpan< char > text)

Writes the text to the span, advancing the current position.

Parameters
text

Definition at line 56 of file EncodingSpanWriter.cs.

57 {
58 var l = _encoding.GetBytes(text, _span);
59 _span = _span.Slice(l);
60 _bytesWritten += l;
61 _charsWritten += text.Length;
62 }

◆ Write() [2/2]

void IKVM.CoreLib.Text.EncodingSpanWriter.Write ( string text)

Writes the text to the span, advancing the current position.

Parameters
text

Definition at line 44 of file EncodingSpanWriter.cs.

45 {
46 var l = _encoding.GetBytes(text, _span);
47 _span = _span.Slice(l);
48 _bytesWritten += l;
49 _charsWritten += text.Length;
50 }

◆ WriteLine()

void IKVM.CoreLib.Text.EncodingSpanWriter.WriteLine ( )

Writes a line feed to the span.

Definition at line 67 of file EncodingSpanWriter.cs.

68 {
69 Write(Environment.NewLine);
70 }
void Write(string text)
Writes the text to the span, advancing the current position.

Member Data Documentation

◆ _bytesWritten

int IKVM.CoreLib.Text.EncodingSpanWriter._bytesWritten

Definition at line 16 of file EncodingSpanWriter.cs.

◆ _charsWritten

int IKVM.CoreLib.Text.EncodingSpanWriter._charsWritten

Definition at line 17 of file EncodingSpanWriter.cs.

◆ _encoding

readonly Encoding IKVM.CoreLib.Text.EncodingSpanWriter._encoding

Definition at line 14 of file EncodingSpanWriter.cs.

◆ _span

Span<byte> IKVM.CoreLib.Text.EncodingSpanWriter._span

Definition at line 15 of file EncodingSpanWriter.cs.

Property Documentation

◆ BytesWritten

readonly int IKVM.CoreLib.Text.EncodingSpanWriter.BytesWritten
get

Gets the number of bytes written.

Definition at line 33 of file EncodingSpanWriter.cs.

◆ CharsWritten

readonly int IKVM.CoreLib.Text.EncodingSpanWriter.CharsWritten
get

Gets the number of characters written.

Definition at line 38 of file EncodingSpanWriter.cs.


The documentation for this struct was generated from the following file: