8 #include <stdair/stdair_exceptions.hpp>
9 #include <stdair/stdair_types.hpp>
10 #include <stdair/bom/BomRoot.hpp>
11 #include <stdair/service/Logger.hpp>
16 namespace bsc = boost::spirit::classic;
20 namespace FFDisutilityParserHelper {
28 : _ffDisutility (ioFFDisutility) {
40 const std::string lKey (iStr, iStrEnd);
62 const bool hasInsertBeenSuccessfull =
64 insert (stdair::FFDisutilityCurve_T::
66 if (hasInsertBeenSuccessfull ==
false) {
67 std::ostringstream oStr;
69 <<
"') has probably been given twice";
70 STDAIR_LOG_ERROR (oStr.str());
71 throw stdair::KeyDuplicationException (oStr.str());
82 _bomRoot (ioBomRoot) {
116 : _bomRoot (ioBomRoot),
117 _ffDisutility (ioFFDisutility) {
121 template<
typename ScannerT>
125 curve_list = *( not_to_be_parsed | curve )
129 bsc::lexeme_d[ bsc::comment_p(
"//") | bsc::comment_p(
"/*",
"*/")
133 curve = key >>
';' >> map
134 >> curve_end[
doEndCurve(
self._bomRoot,
self._ffDisutility)]
137 curve_end = bsc::ch_p(
';')
145 value_pair >> *(
';' >> value_pair)
148 value_pair = bsc::uint_p[
storeDTD(
self._ffDisutility)]
153 BOOST_SPIRIT_DEBUG_NODE (curve_list);
154 BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
155 BOOST_SPIRIT_DEBUG_NODE (key);
156 BOOST_SPIRIT_DEBUG_NODE (map);
157 BOOST_SPIRIT_DEBUG_NODE (value_pair);
161 template<
typename ScannerT>
162 bsc::rule<ScannerT>
const&
178 const stdair::Filename_T& iFilename)
179 : _filename (iFilename), _bomRoot (ioBomRoot) {
184 void FFDisutilityFileParser::init() {
189 if (!_startIterator) {
190 std::ostringstream oMessage;
191 oMessage <<
"The file " << _filename <<
" can not be open." << std::endl;
192 STDAIR_LOG_ERROR (oMessage.str());
197 _endIterator = _startIterator.make_end();
202 bool oResult =
false;
204 STDAIR_LOG_DEBUG (
"Parsing FFDisutility input file: " << _filename);
212 bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
214 bsc::space_p - bsc::eol_p);
219 const bool isFull = info.full;
221 const std::string hasBeenFullyReadStr = (isFull ==
true)?
"":
"not ";
222 if (oResult ==
true && isFull ==
true) {
223 STDAIR_LOG_DEBUG (
"Parsing of FFDisutility input file: " << _filename
224 <<
" succeeded: read " << info.length
225 <<
" characters. The input file has "
226 << hasBeenFullyReadStr
227 <<
"been fully read. Stop point: " << info.stop);
230 STDAIR_LOG_ERROR (
"Parsing of FFDisutility input file: " << _filename
231 <<
" failed: read " << info.length
232 <<
" characters. The input file has "
233 << hasBeenFullyReadStr
234 <<
"been fully read. Stop point: " << info.stop);