IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter > Struct Template Reference

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

Public Member Functions

 EncodingByteBufferWriter (Encoding encoding, ref TWriter buffer)
 Initializes a new instance.
 
void Write (string text)
 Writes the text to the span, advancing the current position.
 
void Write (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
 
TWriter _buffer
 
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 IBufferWriter<byte>.

Type Constraints
TWriter :IBufferWriter<byte> 

Definition at line 11 of file EncodingByteBufferWriter.cs.

Constructor & Destructor Documentation

◆ EncodingByteBufferWriter()

IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >.EncodingByteBufferWriter ( Encoding encoding,
ref TWriter buffer )

Initializes a new instance.

Parameters
encoding
buffer

Definition at line 25 of file EncodingByteBufferWriter.cs.

26 {
27 _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding));
28 _buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
29 }

Member Function Documentation

◆ Write() [1/2]

void IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >.Write ( ReadOnlySpan< char > text)

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

Parameters
text

Definition at line 59 of file EncodingByteBufferWriter.cs.

60 {
61 var l = _encoding.GetByteCount(text);
62 var b = _buffer.GetSpan(l);
63 new EncodingSpanWriter(_encoding, b).Write(text);
64 _buffer.Advance(l);
65 _bytesWritten += l;
66 _charsWritten += text.Length;
67 }

◆ Write() [2/2]

void IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >.Write ( string text)

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

Parameters
text

Definition at line 45 of file EncodingByteBufferWriter.cs.

46 {
47 var l = _encoding.GetByteCount(text);
48 var b = _buffer.GetSpan(l);
49 new EncodingSpanWriter(_encoding, b).Write(text);
50 _buffer.Advance(l);
51 _bytesWritten += l;
52 _charsWritten += text.Length;
53 }

◆ WriteLine()

void IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >.WriteLine ( )

Writes a line feed to the span.

Definition at line 72 of file EncodingByteBufferWriter.cs.

73 {
74 Write(Environment.NewLine);
75 }
void Write(string text)
Writes the text to the span, advancing the current position.

Member Data Documentation

◆ _buffer

TWriter IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >._buffer

Definition at line 16 of file EncodingByteBufferWriter.cs.

◆ _bytesWritten

int IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >._bytesWritten

Definition at line 17 of file EncodingByteBufferWriter.cs.

◆ _charsWritten

int IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >._charsWritten

Definition at line 18 of file EncodingByteBufferWriter.cs.

◆ _encoding

readonly Encoding IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >._encoding

Definition at line 15 of file EncodingByteBufferWriter.cs.

Property Documentation

◆ BytesWritten

readonly int IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >.BytesWritten
get

Gets the number of bytes written.

Definition at line 34 of file EncodingByteBufferWriter.cs.

◆ CharsWritten

readonly int IKVM.CoreLib.Text.EncodingByteBufferWriter< TWriter >.CharsWritten
get

Gets the number of characters written.

Definition at line 39 of file EncodingByteBufferWriter.cs.


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