made parseConfigName static

This commit is contained in:
Undeadamien 2026-03-23 16:33:02 +01:00
parent cc60c9b2b4
commit 240365ad3a
2 changed files with 14 additions and 21 deletions

View file

@ -14,7 +14,6 @@
class CConfigImpl;
struct SConfigDefaultValue;
struct SSpecialCategory;
struct SParsedConfigName;
#define HYPRLANG_END_MAGIC 0x1337BEEF
@ -376,12 +375,6 @@ namespace Hyprlang {
CParseResult parseDynamic(const char* line);
CParseResult parseDynamic(const char* command, const char* value);
/*!
Parse a config name string into category, key, name.
category and key default to ""
*/
SParsedConfigName parseConfigName(const char* name);
/*!
Get a config's value ptr. These are static.
nullptr on fail

View file

@ -41,6 +41,20 @@ static size_t seekABIStructSize(const void* begin, size_t startOffset, size_t ma
return 0;
}
static SParsedConfigName parseConfigName(const char* name) {
const std::string NAME = name;
const auto L = NAME.find('[');
const auto R = NAME.find("]:", L);
if (L != std::string::npos && R != std::string::npos)
return SParsedConfigName{
.category = NAME.substr(0, L),
.key = NAME.substr(L + 1, R - L - 1),
.name = NAME.substr(R + 2),
};
return SParsedConfigName{.name = name};
}
static std::expected<std::string, eGetNextLineFailure> getNextLine(std::istream& str, int& rawLineNum, int& lineNum) {
std::string line = "";
std::string nextLine = "";
@ -1071,20 +1085,6 @@ CParseResult CConfig::parseDynamic(const char* command, const char* value) {
return ret;
}
SParsedConfigName CConfig::parseConfigName(const char* name) {
const std::string NAME = name;
const auto L = NAME.find('[');
const auto R = NAME.find("]:", L);
if (L != std::string::npos && R != std::string::npos)
return SParsedConfigName{
.category = NAME.substr(0, L),
.key = NAME.substr(L + 1, R - L - 1),
.name = NAME.substr(R + 2),
};
return SParsedConfigName{.name = name};
}
void CConfig::clearState() {
impl->categories.clear();
impl->parseError = "";