UISheetFiles class

Style sheets read from files into style tables, and read again when saved.

A file is registered as one of a table's sheets (GGUI::StyleTable::SetSheet). It is read at the next pump and, while watching, again whenever it is saved. A running document picks up the new sheet at its next paint and repaints only what the sheet changed.

A missing or unparsable file is logged with its line and the table keeps what it had. It is retried on the next save.

Add from any thread. Pump on the thread that updates the documents using the tables (a table is modified nowhere else), and keep each table alive while it is registered here.

Public types

using MayChangeFn = bool(*)(void*context, const GGUI::StyleTable&table)
Asked before a sheet is applied to table: false while the table is in use.

Public functions

void Add(GGUI::StyleTable& table, std::string_view name, std::string_view path)
Register the file at path as sheet name of table. Registering the same sheet again switches it to the new path.
void Remove(const GGUI::StyleTable& table)
Drop every file registered for table. Call before the table is destroyed.
auto Pump(bool bWatch, MayChangeFn mayChange = nullptr, void* context = nullptr) -> uint32_t
Read files added since the last pump; with bWatch, also those saved since they were last read.
auto Loaded() const -> uint32_t
sheets applied, total
auto Failed() const -> uint32_t
auto LastError() const -> const std::string&
The last failure as logged: "path(line): why". Pumping thread only.

Function documentation

uint32_t UISheetFiles::Pump(bool bWatch, MayChangeFn mayChange = nullptr, void* context = nullptr)

Read files added since the last pump; with bWatch, also those saved since they were last read.

Returns how many sheets were applied. A table mayChange rejects is skipped and its file is read at the next pump that allows it.

uint32_t UISheetFiles::Failed() const

failed reads, total