ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
country_service Class Reference

Service for managing countries. More...

#include <country_service.hpp>

Collaboration diagram for country_service:
Collaboration graph

Public Types

using context = ores::database::context
 

Public Member Functions

 country_service (context ctx)
 Constructs a country_service with a database context.
 
std::vector< domain::countrylist_countries (std::uint32_t offset, std::uint32_t limit)
 Lists countries with pagination support.
 
std::uint32_t count_countries ()
 Gets the total count of active countries.
 
void save_country (const domain::country &country)
 Saves a country (creates or updates).
 
void delete_country (const std::string &alpha2_code)
 Deletes a country by its alpha-2 code.
 
std::optional< domain::countryget_country (const std::string &alpha2_code)
 Retrieves a single country by its alpha-2 code.
 
std::vector< domain::countryget_country_history (const std::string &alpha2_code)
 Retrieves all historical versions of a country.
 

Detailed Description

Service for managing countries.

Provides a higher-level interface for country operations, wrapping the underlying repository.

Constructor & Destructor Documentation

◆ country_service()

country_service ( context  ctx)
explicit

Constructs a country_service with a database context.

Parameters
ctxThe database context for operations.

Member Function Documentation

◆ list_countries()

std::vector< domain::country > list_countries ( std::uint32_t  offset,
std::uint32_t  limit 
)

Lists countries with pagination support.

Parameters
offsetNumber of records to skip.
limitMaximum number of records to return.
Returns
Vector of countries for the requested page.

◆ count_countries()

std::uint32_t count_countries ( )

Gets the total count of active countries.

Returns
Total number of active countries.

◆ save_country()

void save_country ( const domain::country country)

Saves a country (creates or updates).

Parameters
countryThe country to save.
Exceptions
std::exceptionon failure.

◆ delete_country()

void delete_country ( const std::string &  alpha2_code)

Deletes a country by its alpha-2 code.

Parameters
alpha2_codeThe alpha-2 code of the country to delete.
Exceptions
std::exceptionon failure.

◆ get_country()

std::optional< domain::country > get_country ( const std::string &  alpha2_code)

Retrieves a single country by its alpha-2 code.

Parameters
alpha2_codeThe alpha-2 code of the country.
Returns
The country if found, std::nullopt otherwise.

◆ get_country_history()

std::vector< domain::country > get_country_history ( const std::string &  alpha2_code)

Retrieves all historical versions of a country.

Parameters
alpha2_codeThe alpha-2 code of the country.
Returns
Vector of all historical versions of the country.