@@ -28,45 +28,35 @@ POFParser::POFParser(const std::string &filename, bool verbose):
2828POFParser::~POFParser ()
2929{}
3030
31- int POFParser::getMemSection (const std::string &name)
32- {
33- int i = 0 ;
34- for (auto it = mem_section.begin (); it != mem_section.end (); it++, i++) {
35- if ((*it).first == name)
36- return i;
37- }
38- return -1 ;
39- }
40-
4131uint8_t *POFParser::getData (const std::string §ion_name)
4232{
4333 if (section_name == " " )
4434 return (uint8_t *)_bit_data.data ();
45- int idx = getMemSection (section_name);
46- if (idx != -1 )
47- return mem_section[section_name].data ;
48- else
35+ auto section = mem_section.find (section_name);
36+ if (section == mem_section.end ())
4937 return NULL ;
38+ return (*section).second .data ;
5039}
5140
5241int POFParser::getLength (const std::string §ion_name)
5342{
5443 if (section_name == " " )
5544 return _bit_length;
56- int idx = getMemSection (section_name);
57- if (idx != -1 )
58- return mem_section[section_name].len ;
59- else
45+ auto section = mem_section.find (section_name);
46+ if (section == mem_section.end ())
6047 return -1 ;
48+ return (*section).second .len ;
6149}
6250
6351void POFParser::displayHeader ()
6452{
6553 ConfigBitstreamParser::displayHeader ();
54+ char mess[1024 ];
55+ snprintf (mess, 1024 , " Flag section offset len end" );
56+ printInfo (mess);
6657 for (auto it = mem_section.begin (); it != mem_section.end (); it++) {
6758 memory_section_t v = (*it).second ;
68- char mess[1024 ];
69- snprintf (mess, 1024 , " %02x %4s: " , v.flag , v.section .c_str ());
59+ snprintf (mess, 1024 , " %02x %4s: " , v.flag , v.section .c_str ());
7060 printInfo (mess, false );
7161 // start address + len (in bits) + end addr
7262 snprintf (mess, 1024 , " %08x %08x %08x" , v.offset , v.len , v.offset + ((v.len /8 )-1 ));
@@ -111,9 +101,9 @@ int POFParser::parse()
111101 /* update pointers to memory area */
112102 ptr = (uint8_t *)_bit_data.data ();
113103 mem_section[" CFM0" ].data = &ptr[mem_section[" CFM0" ].offset + 0x0C ];
114- if (getMemSection (" CFM1" ) != - 1 )
104+ if (mem_section. find (" CFM1" ) != mem_section. end () )
115105 mem_section[" CFM1" ].data = &ptr[mem_section[" CFM1" ].offset + 0x0C ];
116- if (getMemSection (" CFM2" ) != - 1 )
106+ if (mem_section. find (" CFM2" ) != mem_section. end () )
117107 mem_section[" CFM2" ].data = &ptr[mem_section[" CFM2" ].offset + 0x0C ];
118108 mem_section[" UFM" ].data = &ptr[mem_section[" UFM" ].offset + 0x0C ];
119109 mem_section[" ICB" ].data = &ptr[mem_section[" ICB" ].offset + 0x0C ];
0 commit comments