Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::Language Class Reference

The Language class manges the language files and entries and stores the LanguageEntry objects in a map. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/Language.h>

Inheritance diagram for orxonox::Language:
orxonox::Singleton< Language >

Public Member Functions

 Language ()
 Constructor: Reads the default language file and sets some values. More...
 
 ~Language ()
 Destructor: Deletes all language entries. More...
 
void addEntry (const LanguageEntryLabel &label, const std::string &entry)
 Adds a new LanguageEntry, if it's not already existing. More...
 
const std::string & getLocalisation (const LanguageEntryLabel &label, bool bError=true) const
 Returns the localisation of a given entry. More...
 

Private Member Functions

 Language (const Language &)=delete
 
LanguageEntrycreateEntry (const LanguageEntryLabel &label, const std::string &entry)
 Creates a new LanguageEntry with a given label and a given default entry. More...
 
Languageoperator= (const Language &)=delete
 
void readDefaultLanguageFile ()
 Reads the default language file and creates a LanguageEntry objects for every entry. More...
 
bool readTranslatedLanguageFile (const std::string &language)
 Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object. More...
 
void writeDefaultLanguageFile () const
 Writes all default entries to the default language file. More...
 

Static Private Member Functions

static std::string getFilename (const std::string &language)
 Creates the name of the language file out of the languages name. More...
 

Private Attributes

std::string defaultLanguage_
 The default language. More...
 
std::string defaultLocalisation_
 The returned string, if an entry unavailable entry is requested. More...
 
std::map< std::string, LanguageEntry * > languageEntries_
 A map to store all LanguageEntry objects and their labels. More...
 

Static Private Attributes

static LanguagesingletonPtr_s = nullptr
 

Friends

class CoreConfig
 
class Singleton< Language >
 

Additional Inherited Members

- Static Public Member Functions inherited from orxonox::Singleton< Language >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static LanguagegetInstance ()
 Returns a reference to the singleton instance. More...
 
- Protected Member Functions inherited from orxonox::Singleton< Language >
 Singleton ()
 Constructor sets the singleton instance pointer. More...
 
virtual ~Singleton ()
 Destructor resets the singleton instance pointer. More...
 

Detailed Description

The Language class manges the language files and entries and stores the LanguageEntry objects in a map.

See also
See Language.h for some examples.

Constructor & Destructor Documentation

orxonox::Language::Language ( )

Constructor: Reads the default language file and sets some values.

orxonox::Language::~Language ( )

Destructor: Deletes all language entries.

orxonox::Language::Language ( const Language )
privatedelete

Member Function Documentation

void orxonox::Language::addEntry ( const LanguageEntryLabel label,
const std::string &  entry 
)

Adds a new LanguageEntry, if it's not already existing.

Parameters
labelThe label of the entry
entryThe default entry
LanguageEntry * orxonox::Language::createEntry ( const LanguageEntryLabel label,
const std::string &  entry 
)
private

Creates a new LanguageEntry with a given label and a given default entry.

Parameters
labelThe label of the entry
entryThe default entry
Returns
The created LanguageEntry object
std::string orxonox::Language::getFilename ( const std::string &  language)
staticprivate

Creates the name of the language file out of the languages name.

Parameters
languageThe name of the language
Returns
The filename
const std::string & orxonox::Language::getLocalisation ( const LanguageEntryLabel label,
bool  bError = true 
) const

Returns the localisation of a given entry.

Parameters
labelThe label of the entry
bErrorIf true, an error is printed if the label doesn't exist and the default localisation is returned. If false, no error is printed and an empty string is returned.
Returns
The localisation
Language& orxonox::Language::operator= ( const Language )
privatedelete
void orxonox::Language::readDefaultLanguageFile ( )
private

Reads the default language file and creates a LanguageEntry objects for every entry.

bool orxonox::Language::readTranslatedLanguageFile ( const std::string &  language)
private

Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.

Returns
Returns false if the language file couldn't be found.
void orxonox::Language::writeDefaultLanguageFile ( ) const
private

Writes all default entries to the default language file.

Friends And Related Function Documentation

friend class CoreConfig
friend
friend class Singleton< Language >
friend

Member Data Documentation

std::string orxonox::Language::defaultLanguage_
private

The default language.

std::string orxonox::Language::defaultLocalisation_
private

The returned string, if an entry unavailable entry is requested.

std::map<std::string, LanguageEntry*> orxonox::Language::languageEntries_
private

A map to store all LanguageEntry objects and their labels.

Language * orxonox::Language::singletonPtr_s = nullptr
staticprivate

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