Table of Contents

Struct StringView

Namespace
SampSharp.OpenMp.Core.Std
Assembly
SampSharp.OpenMp.Core.dll

Represents a view of a string which is represented in memory like an std::basic_string_view from the C++ standard library.

public readonly struct StringView : ISpanFormattable, IFormattable
Implements
Inherited Members

Constructors

StringView(byte*, Size)

Initializes a new instance of the StringView struct.

public StringView(byte* data, Size size)

Parameters

data byte*

A pointer to the underlying sequence.

size Size

The number of characters.

Methods

AsSpan()

Converts this view to a read-only span of bytes.

public ReadOnlySpan<byte> AsSpan()

Returns

ReadOnlySpan<byte>

The readonly span of bytes.

ToString()

Converts this view to a string using Encoding (UTF-8 by default, can be overridden at startup).

public override string? ToString()

Returns

string

The converted string.

ToString(string?, IFormatProvider?)

Converts this view to a string using UTF-8 encoding.

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.

formatProvider IFormatProvider

The provider to use to format the value.

Returns

string

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Tries to format the value of this string view into the provided span of characters. The string view is converted using UTF-8 encoding.

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)

Parameters

destination Span<char>

The span in which to write this instance's value formatted as a span of characters.

charsWritten int

When this method returns, contains the number of characters that were written in destination.

format ReadOnlySpan<char>

A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.

provider IFormatProvider

An optional object that supplies culture-specific formatting information for destination .

Returns

bool

true if the formatting was successful; otherwise, false.

Operators

implicit operator string?(StringView)

Converts a StringView to a string using UTF-8 encoding.

public static implicit operator string?(StringView view)

Parameters

view StringView

Returns

string