Hyprlang
A fast and user-friendly configuration language
|
#include <hyprlang.hpp>
Public Member Functions | |
CConfig (const char *configPath, const SConfigOptions &options) | |
~CConfig () | |
void | addConfigValue (const char *name, const CConfigValue &value) |
void | registerHandler (PCONFIGHANDLERFUNC func, const char *name, SHandlerOptions options) |
void | unregisterHandler (const char *name) |
void | commence () |
void | addSpecialCategory (const char *name, SSpecialCategoryOptions options) |
void | removeSpecialCategory (const char *name) |
void | addSpecialConfigValue (const char *cat, const char *name, const CConfigValue &value) |
void | removeSpecialConfigValue (const char *cat, const char *name) |
CParseResult | parse () |
CParseResult | parseFile (const char *file) |
CParseResult | parseDynamic (const char *line) |
CParseResult | parseDynamic (const char *command, const char *value) |
CConfigValue * | getConfigValuePtr (const char *name) |
CConfigValue * | getSpecialConfigValuePtr (const char *category, const char *name, const char *key=nullptr) |
std::any | getConfigValue (const char *name) |
std::any | getSpecialConfigValue (const char *category, const char *name, const char *key=nullptr) |
bool | specialCategoryExistsForKey (const char *category, const char *key) |
std::vector< std::string > | listKeysForSpecialCategory (const char *category) |
Base class for a config file
Hyprlang::CConfig::CConfig | ( | const char * | configPath, |
const SConfigOptions & | options ) |
Hyprlang::CConfig::~CConfig | ( | ) |
void Hyprlang::CConfig::addConfigValue | ( | const char * | name, |
const CConfigValue & | value ) |
Add a config value, for example myCategory:myValue. This has to be done before commence() Value provided becomes default.
void Hyprlang::CConfig::addSpecialCategory | ( | const char * | name, |
SSpecialCategoryOptions | options ) |
Add a special category. Can be done dynamically.
void Hyprlang::CConfig::addSpecialConfigValue | ( | const char * | cat, |
const char * | name, | ||
const CConfigValue & | value ) |
Add a config value to a special category.
const CConfigValue
(non-ref) void Hyprlang::CConfig::commence | ( | ) |
Commence the config state. Config becomes immutable, as in no new values may be added or removed. Required for parsing.
|
inline |
Get a config value's stored value. Empty on fail
CConfigValue * Hyprlang::CConfig::getConfigValuePtr | ( | const char * | name | ) |
Get a config's value ptr. These are static. nullptr on fail
|
inline |
Get a special config value's stored value. Empty on fail.
CConfigValue * Hyprlang::CConfig::getSpecialConfigValuePtr | ( | const char * | category, |
const char * | name, | ||
const char * | key = nullptr ) |
Get a special category's config value ptr. These are only static for static (key-less) categories. key can be nullptr for static categories. Cannot be nullptr for id-based categories. nullptr on fail.
|
inline |
Get a vector with all registered keys for a special category
It's an error to query this for a static or non-existent category
CParseResult Hyprlang::CConfig::parse | ( | ) |
Parse the config. Refresh the values.
CParseResult Hyprlang::CConfig::parseDynamic | ( | const char * | command, |
const char * | value ) |
CParseResult Hyprlang::CConfig::parseDynamic | ( | const char * | line | ) |
Parse a single "line", dynamically. Values set by this are temporary and will be overwritten by default / config on the next parse()
CParseResult Hyprlang::CConfig::parseFile | ( | const char * | file | ) |
Same as parse(), but parse a specific file, without any refreshing. recommended to use for stuff like source = path.conf
void Hyprlang::CConfig::registerHandler | ( | PCONFIGHANDLERFUNC | func, |
const char * | name, | ||
SHandlerOptions | options ) |
Register a handler. Can be called anytime, though not recommended to do this dynamically .
void Hyprlang::CConfig::removeSpecialCategory | ( | const char * | name | ) |
Remove a special category. Can be done dynamically.
void Hyprlang::CConfig::removeSpecialConfigValue | ( | const char * | cat, |
const char * | name ) |
Remove a config value from a special category.
bool Hyprlang::CConfig::specialCategoryExistsForKey | ( | const char * | category, |
const char * | key ) |
Check whether a special category with the provided key value exists
void Hyprlang::CConfig::unregisterHandler | ( | const char * | name | ) |
Unregister a handler.