pofParser: getData/getLength: check if section exists: return data/length or null/-1

This commit is contained in:
Gwenhael Goavec-Merou 2025-02-01 08:06:59 +01:00
parent 5847ec2666
commit 65afd7da0b
1 changed files with 8 additions and 2 deletions

View File

@ -32,14 +32,20 @@ uint8_t *POFParser::getData(const std::string &section_name)
{ {
if (section_name == "") if (section_name == "")
return (uint8_t*)_bit_data.data(); return (uint8_t*)_bit_data.data();
return mem_section[section_name].data; auto section = mem_section.find(section_name);
if (section == mem_section.end())
return NULL;
return (*section).second.data;
} }
int POFParser::getLength(const std::string &section_name) int POFParser::getLength(const std::string &section_name)
{ {
if (section_name == "") if (section_name == "")
return _bit_length; return _bit_length;
return mem_section[section_name].len; auto section = mem_section.find(section_name);
if (section == mem_section.end())
return -1;
return (*section).second.len;
} }
void POFParser::displayHeader() void POFParser::displayHeader()