Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
host_records.h File Reference

Declares host record models and utilities. More...

#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for host_records.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  app::HostAppRecord
 App metadata shown on the per-host apps page. More...
 
struct  app::HostRecord
 Manual host record shown in the shell. More...
 
struct  app::ParseHostRecordsResult
 Result of parsing a serialized host record list. More...
 

Enumerations

enum class  app::HostAppListState { idle , loading , ready , failed }
 Fetch state for the per-host app library. More...
 
enum class  app::HostReachability { unknown , online , offline }
 Reachability state tracked for a discovered or saved host. More...
 
enum class  app::PairingState { not_paired , paired }
 Pairing state tracked for a saved host record. More...
 

Functions

std::string app::build_default_host_display_name (std::string_view normalizedAddress)
 Build a controller-friendly default display name for a host.
 
bool app::contains_host_address (const std::vector< HostRecord > &records, std::string_view normalizedAddress, uint16_t port=0)
 Return whether a host list already contains an endpoint.
 
uint16_t app::effective_host_port (uint16_t port)
 Return the effective TCP port for a host record.
 
bool app::host_matches_endpoint (const HostRecord &host, std::string_view normalizedAddress, uint16_t port)
 Return whether a host record matches a specific endpoint.
 
bool app::is_valid_ipv4_address (std::string_view address)
 Return whether a string is a valid IPv4 address.
 
std::string app::normalize_ipv4_address (std::string_view address)
 Normalize a user-provided IPv4 address.
 
ParseHostRecordsResult app::parse_host_records (std::string_view serializedRecords)
 Parse host records from the stable serialized text format.
 
std::string app::serialize_host_records (const std::vector< HostRecord > &records)
 Serialize host records into a stable tab-separated text format.
 
const char * app::to_string (HostReachability reachability)
 Return a stable lowercase label for a host reachability state.
 
const char * app::to_string (PairingState pairingState)
 Return a stable lowercase label for a pairing state.
 
bool app::try_parse_host_port (std::string_view portText, uint16_t *parsedPort)
 Parse a user-supplied TCP port string.
 
bool app::validate_host_record (const HostRecord &record, std::string *errorMessage=nullptr)
 Validate a host record before saving or serializing it.
 

Variables

constexpr uint16_t app::DEFAULT_HOST_PORT = 47989
 Default HTTP port used by Moonlight-compatible hosts.
 

Detailed Description

Declares host record models and utilities.

Enumeration Type Documentation

◆ HostAppListState

enum class app::HostAppListState
strong

Fetch state for the per-host app library.

Enumerator
idle 

No app-list request is active and no fresh result is pending.

loading 

An app-list request is currently in progress.

ready 

A recent app list is available for display.

failed 

The latest app-list request failed.

◆ HostReachability

enum class app::HostReachability
strong

Reachability state tracked for a discovered or saved host.

Enumerator
unknown 

Reachability has not been probed yet.

online 

The host responded to the latest reachability check.

offline 

The host did not respond to the latest reachability check.

◆ PairingState

enum class app::PairingState
strong

Pairing state tracked for a saved host record.

Enumerator
not_paired 

The client has not completed pairing with the host.

paired 

The client is paired and can issue authenticated requests.

Function Documentation

◆ build_default_host_display_name()

std::string app::build_default_host_display_name ( std::string_view normalizedAddress)

Build a controller-friendly default display name for a host.

Parameters
normalizedAddressCanonical IPv4 address.
Returns
Generated display label.

◆ contains_host_address()

bool app::contains_host_address ( const std::vector< HostRecord > & records,
std::string_view normalizedAddress,
uint16_t port = 0 )

Return whether a host list already contains an endpoint.

Parameters
recordsSaved hosts to search.
normalizedAddressCanonical IPv4 address to match.
portStored port override to match.
Returns
true when a saved host uses the same address and effective port.

◆ effective_host_port()

uint16_t app::effective_host_port ( uint16_t port)

Return the effective TCP port for a host record.

Parameters
portStored port override where zero means default.
Returns
Effective host port.

◆ host_matches_endpoint()

bool app::host_matches_endpoint ( const HostRecord & host,
std::string_view normalizedAddress,
uint16_t port )

Return whether a host record matches a specific endpoint.

A host matches when the canonical host address equals normalizedAddress and port matches any known effective host endpoint (stored HTTP port, resolved HTTP port, or HTTPS port).

Parameters
hostHost record to test.
normalizedAddressCanonical IPv4 address to compare.
portEndpoint port where zero means DEFAULT_HOST_PORT.
Returns
true when the host record can be reached by the given endpoint.

◆ is_valid_ipv4_address()

bool app::is_valid_ipv4_address ( std::string_view address)

Return whether a string is a valid IPv4 address.

Parameters
addressCandidate IPv4 address.
Returns
true when the address can be normalized.

◆ normalize_ipv4_address()

std::string app::normalize_ipv4_address ( std::string_view address)

Normalize a user-provided IPv4 address.

Parameters
addressCandidate IPv4 address.
Returns
Canonical dotted-quad form, or an empty string when invalid.

◆ parse_host_records()

ParseHostRecordsResult app::parse_host_records ( std::string_view serializedRecords)

Parse host records from the stable serialized text format.

Parameters
serializedRecordsSerialized host record text.
Returns
Parsed records plus any non-fatal line errors.

◆ serialize_host_records()

std::string app::serialize_host_records ( const std::vector< HostRecord > & records)

Serialize host records into a stable tab-separated text format.

The serialized form preserves the saved host identity plus any cached app-list entries and their local visibility or artwork metadata.

Parameters
recordsHost records to serialize.
Returns
Serialized text suitable for disk persistence.

◆ to_string() [1/2]

const char * app::to_string ( HostReachability reachability)

Return a stable lowercase label for a host reachability state.

Parameters
reachabilityReachability state to stringify.
Returns
Stable lowercase label.

◆ to_string() [2/2]

const char * app::to_string ( PairingState pairingState)

Return a stable lowercase label for a pairing state.

Parameters
pairingStatePairing state to stringify.
Returns
Stable lowercase label.

◆ try_parse_host_port()

bool app::try_parse_host_port ( std::string_view portText,
uint16_t * parsedPort )

Parse a user-supplied TCP port string.

Parameters
portTextText entered by the user.
parsedPortOutput port override where zero means default.
Returns
true when the port string is valid.

◆ validate_host_record()

bool app::validate_host_record ( const HostRecord & record,
std::string * errorMessage = nullptr )

Validate a host record before saving or serializing it.

Parameters
recordHost record to validate.
errorMessageOptional output for a validation error.
Returns
true when the record is valid.