Skip to content

PgPath

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns an immutable ordered sequence of points and an open/closed flag for PostgreSQL path. Empty paths can be constructed and exchanged even though PostgreSQL’s text parser requires points.

public sealed class PgPath : IReadOnlyList<PgPoint>, IReadOnlyCollection<PgPoint>, IEnumerable<PgPoint>, IEnumerable, ISpanFormattable, IFormattable, IParsable<PgPath>

Inheritance: object

Implements: IReadOnlyList<PgPoint>, IReadOnlyCollection<PgPoint>, IEnumerable<PgPoint>, IEnumerable, ISpanFormattable, IFormattable, IParsable<PgPath>

Copies the supplied points and records whether the last point connects back to the first.

public PgPath(IEnumerable<PgPoint> points, bool isClosed = false)

Parameters:

points — IEnumerable<PgPoint>

The ordered vertices.

isClosed — bool

Whether the path is closed.

Gets the number of vertices.

public int Count { get; }

Value: int

Gets whether the path is closed.

public bool IsClosed { get; }

Value: bool

Gets a vertex by its zero-based index.

public PgPoint this[int index] { get; }

Parameters:

index — int

The vertex index.

Value: PgPoint

The point.

Gets the vertices without exposing mutable storage.

public ReadOnlySpan<PgPoint> Points { get; }

Value: ReadOnlySpan<PgPoint>

Enumerates vertices in order.

public IEnumerator<PgPoint> GetEnumerator()

Returns: IEnumerator<PgPoint>

The vertex enumerator.

Parses a path using PostgreSQL on the active backend.

public static PgPath Parse(string text)

Parameters:

text — string

The path text.

Returns: PgPath

The owned path.

Formats vertices with the path’s opening and closing delimiters without backend access.

public override string ToString()

Returns: string

The path text.

Formats the value as PostgreSQL’s canonical text, the same text as ToString().

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

Parameters:

format — string

Null or empty; PostgreSQL text has one canonical form.

formatProvider — IFormatProvider

Ignored: the text does not depend on culture.

Returns: string

The canonical text.

Exceptions:

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

Section titled “TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)”

Copies the value’s canonical PostgreSQL text into a span, as interpolated strings and other span-based formatters request it.

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

Parameters:

destination — Span<char>

The span that receives the text.

charsWritten — int

The number of characters written.

format — ReadOnlySpan<char>

Empty; PostgreSQL text has one canonical form.

provider — IFormatProvider

Ignored: the text does not depend on culture.

Returns: bool

Whether the text fit in the destination.

Exceptions:

Tries PostgreSQL parsing without swallowing backend-access or operational errors.

public static bool TryParse(string? text, out PgPath? value)

Parameters:

text — string

The path text.

value — PgPath

The result, or null.

Returns: bool

Whether parsing succeeded.

Invalid input leaves no error pending: PostgreSQL 16 and later report it as a soft input error, and earlier majors roll back an internal subtransaction. Before PostgreSQL 16, transaction callbacks and parallel operations forbid that rollback; native errors there remain pending and throw PgException.

Copies this path with a new open/closed flag.

public PgPath WithClosed(bool isClosed)

Parameters:

isClosed — bool

The new flag.

Returns: PgPath

The independent path.