Struct ValueStringBuilder
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
initialCapacityintThe minimum starting capacity.
ValueStringBuilder(Span<char>)
Initializes the builder using a stack-allocated or pre-allocated buffer.
public ValueStringBuilder(Span<char> initialBuffer)
Parameters
Properties
Capacity
Gets the total number of characters the current buffer can hold without resizing.
public readonly int Capacity { get; }
Property Value
this[int]
Gets a reference to the character at the specified index within the current usage.
public ref char this[int index] { get; }
Parameters
indexintThe zero-based index of the character.
Property Value
Length
The current number of characters in the builder.
public int Length { readonly get; set; }
Property Value
RawChars
Gets the writable buffer. Only the first Length characters contain text.
public readonly Span<char> RawChars { get; }
Property Value
Methods
Append(char)
Appends a single character to the builder, resizing if necessary.
public void Append(char c)
Parameters
cchar
Append(char*, int)
Appends a specified number of characters from a pointer.
public void Append(char* value, int length)
Parameters
Append(char, int)
Appends a character repeated a specified number of times.
public void Append(char c, int count)
Parameters
Append(int)
Appends the string representation of an integer.
public void Append(int i)
Parameters
iint
Append(ReadOnlySpan<char>)
Appends the contents of a read-only span of characters.
public void Append(ReadOnlySpan<char> value)
Parameters
valueReadOnlySpan<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
sstring
AppendSpan(int)
Advances the builder and returns a writable span of the specified length.
public Span<char> AppendSpan(int length)
Parameters
lengthint
Returns
AsSpan()
Returns a span around the contents of the builder.
public readonly ReadOnlySpan<char> AsSpan()
Returns
AsSpan(bool)
Returns a span around the contents of the builder.
public ReadOnlySpan<char> AsSpan(bool terminate)
Parameters
Returns
AsSpan(int)
Returns a span around the contents of the builder.
public readonly ReadOnlySpan<char> AsSpan(int start)
Parameters
startint
Returns
AsSpan(int, int)
Returns a span around the contents of the builder.
public readonly ReadOnlySpan<char> AsSpan(int start, int length)
Parameters
Returns
DigitCount(int)
Calculates the number of decimal digits required to represent a non-negative integer.
public static int DigitCount(int v)
Parameters
vintThe 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
capacityintThe total minimum capacity required.
GetPinnableReference()
Gets a pinnable reference without adding a null character after Length.
public readonly ref char GetPinnableReference()
Returns
GetPinnableReference(bool)
Gets a pinnable reference to the current text.
public ref char GetPinnableReference(bool terminate)
Parameters
Returns
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
indexintThe zero-based index at which to insert.
valuecharThe character to insert.
countintThe 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
ToStringAndDispose()
Returns the content as a string and releases pooled resources.
public string ToStringAndDispose()
Returns
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
Returns
- bool
True if the destination was large enough, otherwise false.