Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ui::app::Environment Class Reference

Immutable owning environment snapshot; missing and empty values remain distinct. Windows names compare without case using Unicode ordinal rules; names/values are UTF-8. POSIX names and values preserve native bytes, including non-UTF-8 values, and compare exactly. No accessor mutates or refreshes the process environment. More...

#include <ui_app.hpp>

Public Types

using Entry = std::pair<std::string, std::string>
 Opaque immutable storage; no process-owned pointers escape.

Public Member Functions

std::expected< std::optional< std::string_view >, ProcessContextError > get (std::string_view name) const noexcept
std::size_t size () const noexcept
bool operator== (const Environment &other) const noexcept

Static Public Member Functions

static std::expected< Environment, ProcessContextError > fromEntries (std::span< const Entry > entries)

Friends

std::expected< Environment, ProcessContextError > environment ()

Detailed Description

Immutable owning environment snapshot; missing and empty values remain distinct. Windows names compare without case using Unicode ordinal rules; names/values are UTF-8. POSIX names and values preserve native bytes, including non-UTF-8 values, and compare exactly. No accessor mutates or refreshes the process environment.

Member Typedef Documentation

◆ Entry

using portals::ui::app::Environment::Entry = std::pair<std::string, std::string>

Opaque immutable storage; no process-owned pointers escape.

Owning name/value pair for synthetic snapshots.

Member Function Documentation

◆ fromEntries()

std::expected< Environment, ProcessContextError > portals::ui::app::Environment::fromEntries ( std::span< const Entry > entries)
static
Parameters
entriesSynthetic native-policy entries; no process environment is modified.
Returns
Owning copy, or INVALID_ARGUMENT/NO_MEMORY. Names must be nonempty; embedded NUL is rejected.

◆ get()

std::expected< std::optional< std::string_view >, ProcessContextError > portals::ui::app::Environment::get ( std::string_view name) const
noexcept
Parameters
nameNonempty variable name without NUL, in the platform's documented encoding.
Returns
Checked borrowed value retained by this snapshot, or successful nullopt if missing. Empty values remain successful engaged views of zero length. Duplicate synthetic names resolve to the first entry. Windows Unicode conversion allocation failure is NO_MEMORY; invalid query encoding/name is INVALID_ARGUMENT.

◆ operator==()

bool portals::ui::app::Environment::operator== ( const Environment & other) const
noexcept
Parameters
otherImmutable snapshot to compare.
Returns
Exact ordered name/value byte equality, without reading the live environment.

◆ size()

std::size_t portals::ui::app::Environment::size ( ) const
noexcept
Returns
Number of captured entries, without consulting the live process.

◆ environment

std::expected< Environment, ProcessContextError > environment ( )
friend
Returns
Owning snapshot with the same initialization contract as args().

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