Smolgui
Immediate gui library based on SFML
Loading...
Searching...
No Matches
TextContainer.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <unordered_map>
6
7namespace sgui
8{
9template <typename Type>
10using LookupTable = std::unordered_map <std::string, Type>;
16public:
20 const std::string& tongue () const;
24 void setTongue (const std::string& tongue);
28 bool reload (const std::string& tongue = "");
32 bool loadFromFile (
33 const std::string& filename,
34 const std::string& tongue = "");
38 void saveInFile (const std::string& filename);
42 void add (
43 const std::string& key,
44 const std::string& text);
48 void remove (const std::string& key);
52 std::string& get (const std::string& entry);
56 const std::string& get (const std::string& entry) const;
60 bool has (const std::string& entry) const;
61private:
62 std::string m_activeTongue = "english";
65};
66
67} // namespace sgui
store text accessible with a string key, with option to load and store text for a given tongue,...
Definition TextContainer.h:15
void setTongue(const std::string &tongue)
set tongue used
Definition TextContainer.cpp:14
bool loadFromFile(const std::string &filename, const std::string &tongue="")
load texts from a filename for this given tongue. By default it uses active tongue.
Definition TextContainer.cpp:37
void remove(const std::string &key)
remove text from the container for the current tongue
Definition TextContainer.cpp:75
void add(const std::string &key, const std::string &text)
add a text with a given key to the container for the current tongue
Definition TextContainer.cpp:67
bool reload(const std::string &tongue="")
reload all texts for the active tongue
Definition TextContainer.cpp:20
bool has(const std::string &entry) const
check that entry is stored
Definition TextContainer.cpp:97
std::string & get(const std::string &entry)
get mutable text entry for the current tongue
Definition TextContainer.cpp:81
void saveInFile(const std::string &filename)
save texts of the current tongue
Definition TextContainer.cpp:61
const std::string & tongue() const
get current tongue used
Definition TextContainer.cpp:8
Definition Interpolation.h:16
std::unordered_map< std::string, Type > LookupTable
Definition TextContainer.h:10