Table of Contents

Struct ValueStringBuilder

Namespace
Rinku.Querying
Assembly
Rinku.dll

Builds SQL text for a query handler. Append the text your handler wants to add to the command.

public ref struct ValueStringBuilder
Inherited Members

Constructors

ValueStringBuilder(int)

Initializes the builder by renting an initial buffer from the shared pool.

public ValueStringBuilder(int initialCapacity)

Parameters

initialCapacity int

The minimum starting capacity.

ValueStringBuilder(Span<char>)

Initializes the builder using a stack-allocated or pre-allocated buffer.

public ValueStringBuilder(Span<char> initialBuffer)

Parameters

initialBuffer Span<char>

The initial memory to use for string building.

Properties

Capacity

Gets the total number of characters the current buffer can hold without resizing.

public readonly int Capacity { get; }

Property Value

int

this[int]

Gets a reference to the character at the specified index within the current usage.

public ref char this[int index] { get; }

Parameters

index int

The zero-based index of the character.

Property Value

char

Length

The current number of characters in the builder.

public int Length { readonly get; set; }

Property Value

int

RawChars

Gets the writable buffer. Only the first Length characters contain text.

public readonly Span<char> RawChars { get; }

Property Value

Span<char>

Methods

Append(char)

Appends a single character to the builder, resizing if necessary.

public void Append(char c)

Parameters

c char

Append(char*, int)

Appends a specified number of characters from a pointer.

public void Append(char* value, int length)

Parameters

value char*
length int

Append(char, int)

Appends a character repeated a specified number of times.

public void Append(char c, int count)

Parameters

c char

The character to append.

count int

The number of times to append the character.

Append(int)

Appends the string representation of an integer.

public void Append(int i)

Parameters

i int

Append(ReadOnlySpan<char>)

Appends the contents of a read-only span of characters.

public void Append(ReadOnlySpan<char> value)

Parameters

value ReadOnlySpan<char>

The span of characters to append.

Append(string?)

Appends a string. If the string is null, the builder remains unchanged.

public void Append(string? s)

Parameters

s string

AppendSpan(int)

Advances the builder and returns a writable span of the specified length.

public Span<char> AppendSpan(int length)

Parameters

length int

Returns

Span<char>

AsSpan()

Returns a span around the contents of the builder.

public readonly ReadOnlySpan<char> AsSpan()

Returns

ReadOnlySpan<char>

AsSpan(bool)

Returns a span around the contents of the builder.

public ReadOnlySpan<char> AsSpan(bool terminate)

Parameters

terminate bool

Ensures that the builder has a null char after Length

Returns

ReadOnlySpan<char>

AsSpan(int)

Returns a span around the contents of the builder.

public readonly ReadOnlySpan<char> AsSpan(int start)

Parameters

start int

Returns

ReadOnlySpan<char>

AsSpan(int, int)

Returns a span around the contents of the builder.

public readonly ReadOnlySpan<char> AsSpan(int start, int length)

Parameters

start int
length int

Returns

ReadOnlySpan<char>

DigitCount(int)

Calculates the number of decimal digits required to represent a non-negative integer.

public static int DigitCount(int v)

Parameters

v int

The non-negative integer to measure.

Returns

int

The count of digits (1-10).

Dispose()

Returns any rented buffers to the ArrayPool<T>. The instance becomes unusable.

public void Dispose()

EnsureCapacity(int)

Ensures the buffer has enough space to accommodate the specified capacity.

public void EnsureCapacity(int capacity)

Parameters

capacity int

The total minimum capacity required.

GetPinnableReference()

Gets a pinnable reference without adding a null character after Length.

public readonly ref char GetPinnableReference()

Returns

char

GetPinnableReference(bool)

Gets a pinnable reference to the current text.

public ref char GetPinnableReference(bool terminate)

Parameters

terminate bool

Whether to add a null character after Length.

Returns

char

Insert(int, char, int)

Inserts a repeated character into the builder at the specified index.

public void Insert(int index, char value, int count)

Parameters

index int

The zero-based index at which to insert.

value char

The character to insert.

count int

The number of times to insert the character.

Insert(int, string?)

Inserts a string at the specified index, shifting existing content to the right.

public void Insert(int index, string? s)

Parameters

index int
s string

ToStringAndDispose()

Returns the content as a string and releases pooled resources.

public string ToStringAndDispose()

Returns

string

TryCopyTo(Span<char>, out int)

Copies the content to a destination and releases pooled resources.

public bool TryCopyTo(Span<char> destination, out int charsWritten)

Parameters

destination Span<char>
charsWritten int

Returns

bool

True if the destination was large enough, otherwise false.