diff --git a/include/hyprlang.hpp b/include/hyprlang.hpp index 158cea2..51ba7c4 100644 --- a/include/hyprlang.hpp +++ b/include/hyprlang.hpp @@ -181,10 +181,15 @@ namespace Hyprlang { CConfigValue(const STRING value); CConfigValue(const VEC2 value); CConfigValue(CUSTOMTYPE&& value); - CConfigValue(const CConfigValue&) = delete; CConfigValue(CConfigValue&&) = delete; CConfigValue(const CConfigValue&&) = delete; CConfigValue(CConfigValue&) = delete; + + /*! + \since 0.3.0 + */ + CConfigValue(const CConfigValue&); + ~CConfigValue(); /*! @@ -292,10 +297,17 @@ namespace Hyprlang { void removeSpecialCategory(const char* name); /*! + \since 0.3.0 + Add a config value to a special category. */ void addSpecialConfigValue(const char* cat, const char* name, const CConfigValue value); + /*! + Remove a config value from a special category. + */ + void removeSpecialConfigValue(const char* cat, const char* name); + /*! Parse the config. Refresh the values. */ @@ -323,7 +335,7 @@ namespace Hyprlang { /*! Get a special category's config value ptr. These are only static for static (key-less) - categories, unless a new variable is added via addSpecialConfigValue. + categories, unless a new variable is added via addSpecialConfigValue or removed via removeSpecialConfigValue. key can be nullptr for static categories. Cannot be nullptr for id-based categories. nullptr on fail. */ diff --git a/src/common.cpp b/src/common.cpp index 2da2543..bb5f16a 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -54,6 +54,11 @@ CConfigValue::CConfigValue(CConfigCustomValueType&& value) { m_eType = CONFIGDATATYPE_CUSTOM; } +CConfigValue::CConfigValue(const CConfigValue& other) { + m_eType = other.m_eType; + setFrom(other.getValue()); +} + CConfigValue::CConfigValue() { ; } diff --git a/src/config.cpp b/src/config.cpp index 9ef08fb..fceffb1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -93,6 +93,15 @@ void CConfig::addSpecialConfigValue(const char* cat, const char* name, const CCo reinterpret_cast(value.m_pData)->dtor}); } +void CConfig::removeSpecialConfigValue(const char* cat, const char* name) { + const auto IT = std::find_if(impl->specialCategoryDescriptors.begin(), impl->specialCategoryDescriptors.end(), [&](const auto& other) { return other->name == cat; }); + + if (IT == impl->specialCategoryDescriptors.end()) + throw "No such category"; + + std::erase_if(IT->get()->defaultValues, [name](const auto& other) { return other.first == name; }); +} + void CConfig::addSpecialCategory(const char* name, SSpecialCategoryOptions options) { const auto PDESC = impl->specialCategoryDescriptors.emplace_back(std::make_unique()).get(); PDESC->name = name;