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 FRAT5ParserHelper {
40 const std::string lKey (iStr, iStrEnd);
63 const bool hasInsertBeenSuccessfull =
67 if (hasInsertBeenSuccessfull ==
false) {
68 std::ostringstream oStr;
70 <<
"') has probably been given twice";
71 STDAIR_LOG_ERROR (oStr.str());
72 throw stdair::KeyDuplicationException (oStr.str());
83 _bomRoot (ioBomRoot) {
117 : _bomRoot (ioBomRoot),
122 template<
typename ScannerT>
126 curve_list = *( not_to_be_parsed | curve )
130 bsc::lexeme_d[ bsc::comment_p(
"//") | bsc::comment_p(
"/*",
"*/")
134 curve = key >>
';' >> map
135 >> curve_end[
doEndCurve(
self._bomRoot,
self._frat5)]
138 curve_end = bsc::ch_p(
';')
146 value_pair >> *(
';' >> value_pair)
149 value_pair = bsc::uint_p[
storeDTD(
self._frat5)]
154 BOOST_SPIRIT_DEBUG_NODE (curve_list);
155 BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
156 BOOST_SPIRIT_DEBUG_NODE (key);
157 BOOST_SPIRIT_DEBUG_NODE (map);
158 BOOST_SPIRIT_DEBUG_NODE (value_pair);
162 template<
typename ScannerT>
163 bsc::rule<ScannerT>
const&
179 const stdair::Filename_T& iFilename)
180 : _filename (iFilename), _bomRoot (ioBomRoot) {
185 void FRAT5FileParser::init() {
190 if (!_startIterator) {
191 std::ostringstream oMessage;
192 oMessage <<
"The file " << _filename <<
" can not be open." << std::endl;
193 STDAIR_LOG_ERROR (oMessage.str());
198 _endIterator = _startIterator.make_end();
203 bool oResult =
false;
205 STDAIR_LOG_DEBUG (
"Parsing FRAT5 input file: " << _filename);
213 bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
215 bsc::space_p - bsc::eol_p);
220 const bool isFull = info.full;
222 const std::string hasBeenFullyReadStr = (isFull ==
true)?
"":
"not ";
223 if (oResult ==
true && isFull ==
true) {
224 STDAIR_LOG_DEBUG (
"Parsing of FRAT5 input file: " << _filename
225 <<
" succeeded: read " << info.length
226 <<
" characters. The input file has "
227 << hasBeenFullyReadStr
228 <<
"been fully read. Stop point: " << info.stop);
231 STDAIR_LOG_ERROR (
"Parsing of FRAT5 input file: " << _filename
232 <<
" failed: read " << info.length
233 <<
" characters. The input file has "
234 << hasBeenFullyReadStr
235 <<
"been fully read. Stop point: " << info.stop);
237 + _filename +
" failed.");