Skip to navigation

hololink::module::env_hololink_ip

View as Markdown
inline std::string hololink::module::env_hololink_ip(
std::size_t index,
const std::string &fallback
)

Get the IP address of a device from the HOLOLINK_IPS environment variable.

HOLOLINK_IPS holds a comma-separated list of device addresses, for example 192.168.0.2,192.168.0.3. This returns the entry at position index, counting from zero. It lets a test harness (for example ctest, or pytest through its --channel-ips option) choose the devices a program uses, without each program needing its own command-line option; programs normally pass the result as the default for such an option.

The entry is returned exactly as written: whitespace is not removed and the text is not checked to be a valid address.

Returns: The selected address, or fallback.

Parameters

index
std::size_t

Zero-based position in the list.

fallback
const std::string &

Value to return when no address is available for index: the variable is unset or empty, the list has index or fewer entries, or the entry at index is empty (as in a,,b).