mirror of
https://github.com/hyprwm/hyprlang.git
synced 2026-05-09 01:18:10 +02:00
config: remove getAnyConfigValuePtr
This commit is contained in:
parent
240365ad3a
commit
5e38fce1b4
3 changed files with 22 additions and 19 deletions
|
|
@ -389,11 +389,6 @@ namespace Hyprlang {
|
|||
*/
|
||||
CConfigValue* getSpecialConfigValuePtr(const char* category, const char* name, const char* key = nullptr);
|
||||
|
||||
/*!
|
||||
Get a basic or special category's config value ptr by calling `getConfigValuePtr` or `getSpecialConfigValuePtr`
|
||||
*/
|
||||
CConfigValue* getAnyConfigValuePtr(const char* name);
|
||||
|
||||
/*!
|
||||
Get a config value's stored value. Empty on fail
|
||||
*/
|
||||
|
|
@ -414,12 +409,10 @@ namespace Hyprlang {
|
|||
return val->getValue();
|
||||
}
|
||||
|
||||
std::any getAnyConfigValue(const char* name) {
|
||||
CConfigValue* val = getAnyConfigValuePtr(name);
|
||||
if (!val)
|
||||
return {};
|
||||
return val->getValue();
|
||||
}
|
||||
/*!
|
||||
Get a basic or special config value's stored value. Empty on fail.
|
||||
*/
|
||||
std::any getAnyConfigValue(const char* name);
|
||||
|
||||
/*!
|
||||
Check whether a special category with the provided key value exists
|
||||
|
|
@ -472,6 +465,7 @@ namespace Hyprlang {
|
|||
void applyDefaultsToCat(SSpecialCategory& cat);
|
||||
void retrieveKeysForCat(const char* category, const char*** out, size_t* len);
|
||||
CParseResult parseRawStream(const std::string& stream);
|
||||
CConfigValue* getAnyConfigValuePtr(const char* name);
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -1124,6 +1124,15 @@ CConfigValue* CConfig::getAnyConfigValuePtr(const char* name) {
|
|||
return getConfigValuePtr(name);
|
||||
}
|
||||
|
||||
std::any CConfig::getAnyConfigValue(const char* name) {
|
||||
CConfigValue* val = getAnyConfigValuePtr(name);
|
||||
|
||||
if (!val)
|
||||
return {};
|
||||
|
||||
return val->getValue();
|
||||
}
|
||||
|
||||
void CConfig::registerHandler(PCONFIGHANDLERFUNC func, const char* name, SHandlerOptions options_) {
|
||||
SHandlerOptions options;
|
||||
std::memcpy(&options, &options_, seekABIStructSize(&options_, 0, sizeof(SHandlerOptions)));
|
||||
|
|
|
|||
|
|
@ -396,14 +396,14 @@ int main(int argc, char** argv, char** envp) {
|
|||
EXPECT(std::any_cast<int64_t>(config.getAnyConfigValue("specialAnonymousNested[c]:nested:value1")),
|
||||
std::any_cast<int64_t>(config.getSpecialConfigValue("specialAnonymousNested", "nested:value1", "c")));
|
||||
// check against malformed
|
||||
EXPECT(config.getAnyConfigValuePtr("[a]:value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("special[[a]:value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("special[[a]]:value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("special[a]]:value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("special[a]value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("special[avalue"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("special]:a[value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValuePtr("speciala]:value"), nullptr);
|
||||
EXPECT(config.getAnyConfigValue("[a]:value").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("special[[a]:value").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("special[[a]]:value").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("special[a]]:value").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("special[a]value").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("special[avalue").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("special]:a[value").has_value(), false);
|
||||
EXPECT(config.getAnyConfigValue("speciala]:value").has_value(), false);
|
||||
|
||||
// test sourcing
|
||||
std::cout << " → Testing sourcing\n";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue