TGUI  0.9.5
Loading...
Searching...
No Matches

Default implementation for theme loading. More...

#include <TGUI/Loading/ThemeLoader.hpp>

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

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

virtual std::unique_ptr< DataIO::Node > readFile (const String &filename) const
 Reads and return the contents of the entire file.
 
- Protected Member Functions inherited from tgui::BaseThemeLoader
void injectThemePath (const std::unique_ptr< DataIO::Node > &node, const String &path) const
 
void resolveReferences (std::map< String, std::reference_wrapper< const std::unique_ptr< DataIO::Node > > > &sections, const std::unique_ptr< DataIO::Node > &node) const
 

Static Protected Attributes

static std::map< String, std::map< String, std::map< String, String > > > m_propertiesCache
 

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

◆ canLoad()

bool tgui::DefaultThemeLoader::canLoad ( const String filename,
const String section 
)
overridevirtual

Check if the requested property-value pairs are available.

Parameters
filenameFilename of the theme file
sectionName of the section inside the theme file
Returns
Whether a map op property-value pairs is available

Implements tgui::BaseThemeLoader.

◆ flushCache()

static void tgui::DefaultThemeLoader::flushCache ( const 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()

const std::map< String, String > & tgui::DefaultThemeLoader::load ( const String filename,
const 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()

void tgui::DefaultThemeLoader::preload ( const 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 std::unique_ptr< DataIO::Node > tgui::DefaultThemeLoader::readFile ( const String filename) const
protectedvirtual

Reads and return the contents of the entire file.

Parameters
filenameFilename of the file to read
Returns
Root node of the parsed file, obtained by calling DataIO::parse(fileContents)

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