HoverRace  2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
HoverRace::Util::Locale Class Reference

A library of available locales. More...

#include <Locale.h>

Public Types

using const_iterator = locales_t::const_iterator
 
using iterator = locales_t::iterator
 
using value_type = locales_t::value_type
 

Public Member Functions

 Locale (const OS::path_t &path, const std::string &domain)
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_iterator end () const
 
const boost::optional< std::string > & GetSelectedLocaleId () const
 Return the ID of the locale that was selected by RequestLocale(). More...
 
const std::string & IdToName (const std::string &id) const
 Find the locale name for the given locale ID. More...
 
void RequestLocale (const std::string &id)
 Attempt to change the global locale. More...
 
void RequestPreferredLocale ()
 Attempt to change the global locale to the preferred locale. More...
 

Static Public Member Functions

static std::string NormalizeId (const std::string &s)
 Normalize the locale ID. More...
 

Private Types

using locales_t = std::map< std::string, std::string >
 

Private Member Functions

void ScanLocales ()
 Scan the locale directory for available locales. More...
 

Private Attributes

locales_t availableLocales
 Cached list of available locales. More...
 
std::string domain
 
OS::path_t path
 
boost::optional< std::string > selectedLocaleId
 

Detailed Description

A library of available locales.

Author
Michael Imamura

Member Typedef Documentation

using HoverRace::Util::Locale::const_iterator = locales_t::const_iterator
using HoverRace::Util::Locale::iterator = locales_t::iterator
using HoverRace::Util::Locale::locales_t = std::map<std::string, std::string>
private
using HoverRace::Util::Locale::value_type = locales_t::value_type

Constructor & Destructor Documentation

HoverRace::Util::Locale::Locale ( const OS::path_t path,
const std::string &  domain 
)

Member Function Documentation

const_iterator HoverRace::Util::Locale::begin ( ) const
inline
Locale::const_iterator HoverRace::Util::Locale::cbegin ( ) const
Locale::const_iterator HoverRace::Util::Locale::cend ( ) const
const_iterator HoverRace::Util::Locale::end ( ) const
inline
const boost::optional<std::string>& HoverRace::Util::Locale::GetSelectedLocaleId ( ) const
inline

Return the ID of the locale that was selected by RequestLocale().

Returns
The locale ID, if set. If not set, then the requested locale was unavailable, so the default is being used instead.
const std::string & HoverRace::Util::Locale::IdToName ( const std::string &  id) const

Find the locale name for the given locale ID.

Parameters
idThe locale ID.
Returns
The locale name (never empty).
std::string HoverRace::Util::Locale::NormalizeId ( const std::string &  s)
static

Normalize the locale ID.

This removes extraneous whitespace and invalid characters.

Parameters
sThe original locale ID.
Returns
The normalized ID.
void HoverRace::Util::Locale::RequestLocale ( const std::string &  id)

Attempt to change the global locale.

Parameters
idThe locale ID.
void HoverRace::Util::Locale::RequestPreferredLocale ( )

Attempt to change the global locale to the preferred locale.

void HoverRace::Util::Locale::ScanLocales ( )
private

Scan the locale directory for available locales.

This will invalidate all iterators.

Member Data Documentation

locales_t HoverRace::Util::Locale::availableLocales
private

Cached list of available locales.

std::string HoverRace::Util::Locale::domain
private
OS::path_t HoverRace::Util::Locale::path
private
boost::optional<std::string> HoverRace::Util::Locale::selectedLocaleId
private

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