TGUI  0.8-dev

Default implementation for theme loading. More...

#include <ThemeLoader.hpp>

Inheritance diagram for tgui::DefaultThemeLoader:
tgui::BaseThemeLoader

Public Member Functions

virtual void preload (const std::string &filename) override
 Loads the theme file in cache. More...
 
virtual const std::map< sf::String, sf::String > & load (const std::string &filename, const std::string &section) override
 Loads the property-value pairs from the theme file. More...
 
- Public Member Functions inherited from tgui::BaseThemeLoader
virtual ~BaseThemeLoader ()=default
 Virtual destructor.
 

Static Public Member Functions

static void flushCache (const std::string &filename="")
 Empties the caches and force files to be reloaded. More...
 

Protected Member Functions

virtual void readFile (const std::string &filename, std::stringstream &contents) const
 Reads and return the contents of the entire file. More...
 

Detailed Description

Default implementation for theme loading.

Themes are stored on disk in files which contain sections with a syntax similar to CSS. This loader will be able to extract the data from these files.

On first access, the entire file will be cached, the next times the cached map is simply returned.

Member Function Documentation

◆ flushCache()

static void tgui::DefaultThemeLoader::flushCache ( const std::string &  filename = "")
static

Empties the caches and force files to be reloaded.

Parameters
filenameFile to remove from cache. If no filename is given, the entire cache is cleared.

◆ load()

virtual const std::map<sf::String, sf::String>& tgui::DefaultThemeLoader::load ( const std::string &  filename,
const std::string &  section 
)
overridevirtual

Loads the property-value pairs from the theme file.

Parameters
filenameFilename of the theme file
sectionName of the section inside the theme file
Returns
Map of property-value pairs
Exceptions
Exceptionwhen finding syntax errors in the file
Exceptionwhen file did not contain requested class name

Implements tgui::BaseThemeLoader.

◆ preload()

virtual void tgui::DefaultThemeLoader::preload ( const std::string &  filename)
overridevirtual

Loads the theme file in cache.

Parameters
filenameFilename of the theme file to load
Exceptions
Exceptionwhen finding syntax errors in the file

Reimplemented from tgui::BaseThemeLoader.

◆ readFile()

virtual void tgui::DefaultThemeLoader::readFile ( const std::string &  filename,
std::stringstream &  contents 
) const
protectedvirtual

Reads and return the contents of the entire file.

Parameters
filenameFilename of the file to read
contentsReference to a stringstream that should be filled with the contents of the file by this function

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