Offline Transaction Signing (OTS) 0.1.0
Loading...
Searching...
No Matches
ots::SeedLanguage Class Reference

Manages seed phrase languages and their properties. More...

#include <ots.hpp>

Public Member Functions

const std::string & name () const
 Retrieves the native name of the seed language.
 
const std::string & englishName () const
 Retrieves the English name of the seed language.
 
const std::string & code () const
 Retrieves the two-letter language code, which could be extended by a dash with a variation.
 
bool supported (SeedType type=SeedType::Monero) const
 Checks if the language is supported for a specific seed type.
 
bool isDefault (SeedType type=SeedType::Monero) const
 Checks if this is the default language for a given seed type.
 
int index (SeedType type=SeedType::Monero) const noexcept
 The native language index.
 
bool operator== (const SeedLanguage &other) const
 Compares two SeedLanguage objects for equality.
 
bool operator== (SeedLanguage &other) const
 Compares two SeedLanguage objects for equality.
 
bool operator== (const std::string &code) const
 Compares SeedLanguage to a language code.
 
 operator const std::string & () const
 returns the english name as string
 

Static Public Member Functions

static const SeedLanguagefromName (const std::string &name)
 Retrieves a SeedLanguage by its native name.
 
static const SeedLanguagefromEnglishName (const std::string &name)
 Retrieves a SeedLanguage by its English name.
 
static const SeedLanguagefromCode (const std::string &code)
 Retrieves a SeedLanguage by its language code.
 
static const std::vector< std::reference_wrapper< const SeedLanguage > > list ()
 Retrieves the complete list of available seed languages.
 
static const std::vector< std::reference_wrapper< const SeedLanguage > > listFor (SeedType type)
 Retrieves languages supported for a specific seed type.
 
static const SeedLanguagedefaultLanguage (SeedType type=SeedType::Monero)
 Gets the default language for a given seed type.
 
static void setDefaultLanguage (SeedType type, const SeedLanguage &language)
 Sets the default language for a given seed type.
 

Detailed Description

Manages seed phrase languages and their properties.

Provides methods to retrieve, validate, and manage seed phrase languages

Member Function Documentation

◆ code()

const std::string & ots::SeedLanguage::code ( ) const

Retrieves the two-letter language code, which could be extended by a dash with a variation.

Returns
std::string language code

◆ defaultLanguage()

const SeedLanguage & ots::SeedLanguage::defaultLanguage ( SeedType  type = SeedType::Monero)
static

Gets the default language for a given seed type.

Parameters
typeSeedType to find default language (default: Monero), alternative Polyseed
Returns
const SeedLanguage& Default language for the seed type

◆ englishName()

const std::string & ots::SeedLanguage::englishName ( ) const

Retrieves the English name of the seed language.

Returns
std::string Language name in English

◆ fromCode()

const SeedLanguage & ots::SeedLanguage::fromCode ( const std::string &  code)
static

Retrieves a SeedLanguage by its language code.

Parameters
codeLanguage code
Returns
const SeedLanguage Found language object
Exceptions
std::runtime_errorIf language not found

◆ fromEnglishName()

const SeedLanguage & ots::SeedLanguage::fromEnglishName ( const std::string &  name)
static

Retrieves a SeedLanguage by its English name.

Parameters
nameEnglish language name
Returns
const SeedLanguage Found language object
Exceptions
std::runtime_errorif language not found

◆ fromName()

const SeedLanguage & ots::SeedLanguage::fromName ( const std::string &  name)
static

Retrieves a SeedLanguage by its native name.

Parameters
nameNative language name
Returns
const SeedLanguage Found language object
Exceptions
std::runtime_errorIf language not found

◆ index()

int ots::SeedLanguage::index ( SeedType  type = SeedType::Monero) const
noexcept

The native language index.

Parameters
typeSeedType to check support for (default: Monero), alternative Polyseed
Returns
index for the SeedType or -1 on unkown

◆ isDefault()

bool ots::SeedLanguage::isDefault ( SeedType  type = SeedType::Monero) const

Checks if this is the default language for a given seed type.

Parameters
typeSeedType to check (default: Monero), alternative Polyseed
Returns
True if this is the default language, false otherwise

◆ list()

const std::vector< std::reference_wrapper< const SeedLanguage > > ots::SeedLanguage::list ( )
static

Retrieves the complete list of available seed languages.

Returns
const std::vector<SeedLanguage>& List of all supported languages

Map of language names to language codes serves also as a list of supported languages, and harmonize spelling differences

Warning
if monero or polyseed adds a language, it must be added to the map
Note
if there are more conflicting languages, there should be maybe another way to unify the name.

◆ listFor()

const std::vector< std::reference_wrapper< const SeedLanguage > > ots::SeedLanguage::listFor ( SeedType  type)
static

Retrieves languages supported for a specific seed type.

Parameters
typeSeedType to filter languages: (default: Monero), alternative Polyseed
Returns
const std::vector<SeedLanguage> Languages supporting the seed type

◆ name()

const std::string & ots::SeedLanguage::name ( ) const

Retrieves the native name of the seed language.

Returns
std::string Language native name

◆ operator const std::string &()

ots::SeedLanguage::operator const std::string & ( ) const

returns the english name as string

Returns
std::string

◆ operator==() [1/3]

bool ots::SeedLanguage::operator== ( const SeedLanguage other) const

Compares two SeedLanguage objects for equality.

Parameters
otherSeedLanguage to compare against
Returns
bool True if languages are the same, false otherwise

◆ operator==() [2/3]

bool ots::SeedLanguage::operator== ( const std::string &  code) const

Compares SeedLanguage to a language code.

Parameters
codelanguage code to compare against
Returns
bool True if language codes are the same, false otherwise

◆ operator==() [3/3]

bool ots::SeedLanguage::operator== ( SeedLanguage other) const

Compares two SeedLanguage objects for equality.

Parameters
otherSeedLanguage to compare against
Returns
bool True if languages are the same, false otherwise

◆ setDefaultLanguage()

void ots::SeedLanguage::setDefaultLanguage ( SeedType  type,
const SeedLanguage language 
)
static

Sets the default language for a given seed type.

Parameters
typeSeedType to set default language for
languageSeedLanguage to set as default
Exceptions
ots::exception::language::LanguageNotFoundIf the language is not supported

◆ supported()

bool ots::SeedLanguage::supported ( SeedType  type = SeedType::Monero) const

Checks if the language is supported for a specific seed type.

Parameters
typeSeedType to check support for (default: Monero), alternative Polyseed
Returns
bool True if the language is supported, false otherwise

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