24 |
|
*/ |
25 |
|
|
26 |
|
#include "io/SectionParserManager.hpp" |
27 |
+ |
#include "utils/Trim.hpp" |
28 |
|
|
29 |
|
namespace oopse { |
30 |
|
|
50 |
|
//scan through the input stream and find section names |
51 |
|
while(input.getline(buffer, bufferSize)) { |
52 |
|
++lineNo; |
53 |
< |
/**@todo implement trimLeft() */ |
54 |
< |
//std::string line = LeftTrim(buffer); |
54 |
< |
std::string line= buffer; |
53 |
> |
|
54 |
> |
std::string line = trimLeftCopy(buffer); |
55 |
|
//a line begins with "//" is comment |
56 |
|
if ( line.empty() || (line.size() >= 2 && line[0] == '/' && line[1] == '/')) { |
57 |
|
continue; |
68 |
|
|
69 |
|
std::string section = tokenizer.nextToken(); |
70 |
|
|
71 |
< |
i = std::find_if(sectionParsers_.begin(), sectionParsers_.end(), predict); |
71 |
> |
i = std::find_if(sectionParsers_.begin(), sectionParsers_.end(), SameSectionParserFunctor(section)); |
72 |
|
if (i == sectionParsers_.end()){ |
73 |
|
//can not find corresponding section parser |
74 |
|
std::cerr << "Can not find corresponding section parser for section: " << section << std::endl; |
115 |
|
context.offset = 0; |
116 |
|
context.isActive = false; |
117 |
|
|
118 |
+ |
sectionParsers_.push_front(context); |
119 |
|
} |
120 |
|
|
121 |
|
void SectionParserManager::push_back(SectionParser* sp) { |
138 |
|
context.offset = 0; |
139 |
|
context.isActive = false; |
140 |
|
|
141 |
+ |
sectionParsers_.push_back(context); |
142 |
+ |
|
143 |
|
} |
144 |
|
|
145 |
|
void SectionParserManager::insert(SectionParser* sp, int priority) { |