docs: add some comments

Signed-off-by: black-desk <me@black-desk.cn>
This commit is contained in:
black-desk 2023-05-12 13:20:11 +08:00 committed by 爱折腾的小竹同学
parent 0ce69c609a
commit a041aa7cf3

View File

@ -235,7 +235,9 @@ bool KeyFile::loadFile(const std::string &filePath)
if (line.front() == '[') { if (line.front() == '[') {
auto rPos = line.find_first_of(']'); auto rPos = line.find_first_of(']');
if ( rPos != std::string::npos && 0 < rPos ) { if ( rPos != std::string::npos && 0 < rPos ) {
// TODO(black_desk): lastSection might be empty string here.
// I cannot found a spec for the space before groupname in
// freedesktop.org
lastSection = line.substr(1, rPos-1); lastSection = line.substr(1, rPos-1);
m_mainKeyMap.insert({ m_mainKeyMap.insert({
@ -261,10 +263,16 @@ bool KeyFile::loadFile(const std::string &filePath)
} }
// 子键 // 子键
// TODO(black_desk): we should check chars in key here, as spec says
// that it can only contain a-z0-9A-Z
std::string key = line.substr(0, equalPos); std::string key = line.substr(0, equalPos);
std::string value = equalPos + 1 < line.length() ? std::string value = equalPos + 1 < line.length() ?
line.substr(equalPos + 1) : line.substr(equalPos + 1) :
""; "";
// TODO(black_desk): space after value is removed before. But I cannot
// find a spec about this behavior.
m_mainKeyMap[lastSection][key] = value; m_mainKeyMap[lastSection][key] = value;
} }