9 #include <boost/date_time/posix_time/posix_time.hpp>
10 #include <boost/date_time/gregorian/gregorian.hpp>
12 #define BOOST_SPIRIT_DEBUG
13 #include <boost/spirit/home/classic/core.hpp>
14 #include <boost/spirit/home/classic/attribute.hpp>
15 #include <boost/spirit/home/classic/utility/functor_parser.hpp>
16 #include <boost/spirit/home/classic/utility/loops.hpp>
17 #include <boost/spirit/home/classic/utility/chset.hpp>
18 #include <boost/spirit/home/classic/utility/confix.hpp>
19 #include <boost/spirit/home/classic/iterator/file_iterator.hpp>
20 #include <boost/spirit/home/classic/actor/push_back_actor.hpp>
21 #include <boost/spirit/home/classic/actor/assign_actor.hpp>
23 #include <stdair/service/Logger.hpp>
31 typedef boost::spirit::classic::scanner<iterator_t>
scanner_t;
32 typedef boost::spirit::classic::rule<scanner_t>
rule_t;
44 std::string lPlace (iStr, iStrEnd);
99 std::string lAirlineCode (iStr, iStrEnd);
118 std::string lAirlineName (iStr, iStrEnd);
152 std::string lPassengerType (iStr, iStrEnd);
171 std::string lPassengerType (iStr, iStrEnd);
190 std::string lPassengerType (iStr, iStrEnd);
203 boost::spirit::classic::int_parser<unsigned int, 10, 1, 1>
int1_p;
205 boost::spirit::classic::uint_parser<unsigned int, 10, 1, 1>
uint1_p;
207 boost::spirit::classic::uint_parser<unsigned int, 10, 1, 2>
uint1_2_p;
209 boost::spirit::classic::uint_parser<int, 10, 2, 2>
uint2_p;
211 boost::spirit::classic::uint_parser<int, 10, 2, 4>
uint2_4_p;
213 boost::spirit::classic::uint_parser<int, 10, 4, 4>
uint4_p;
215 boost::spirit::classic::uint_parser<int, 10, 1, 4>
uint1_4_p;
248 using namespace boost::spirit::classic;
252 public boost::spirit::classic::grammar<SearchStringParser> {
255 : _searchString (ioSearchString) {
258 template <
typename ScannerT>
262 search_string = places
264 >> *( preferred_airlines )
283 >> boost::spirit::classic::chset_p(
"/-")
285 >> ! ( boost::spirit::classic::chset_p(
"/-")
290 lexeme_d[ limit_d(1u,31u)[
uint1_2_p][assign_a(
self._searchString._tmpDate._day)] ]
294 lexeme_d[ limit_d(1u,12u)[
uint1_2_p][assign_a(
self._searchString._tmpDate._month)] ]
298 lexeme_d[ limit_d(2000u,2099u)[
uint4_p][assign_a(
self._searchString._tmpDate._year)] ]
299 | lexeme_d[ limit_d(0u,99u)[
uint2_p][assign_a(
self._searchString._tmpDate._year)] ]
304 >> airline_code | airline_name
308 lexeme_d[ (repeat_p(2,3)[chset_p(
"0-9a-z")])[
store_airline_code(
self._searchString)] ]
312 lexeme_d[ (repeat_p(4,20)[chset_p(
"0-9a-z")])[
store_airline_name(
self._searchString)] ]
316 passenger_number >> passenger_type
329 passenger_adult_type =
330 lexeme_d[ as_lower_d [ str_p(
"adult") >> !ch_p(
's') ] ]
333 passenger_child_type =
334 lexeme_d[ as_lower_d [ str_p(
"child") >> !str_p(
"ren") ] ]
338 lexeme_d[ as_lower_d [ str_p(
"dog") | str_p(
"cat") >> !ch_p(
's') ] ]
341 BOOST_SPIRIT_DEBUG_NODE (search_string);
342 BOOST_SPIRIT_DEBUG_NODE (places);
343 BOOST_SPIRIT_DEBUG_NODE (place_element);
344 BOOST_SPIRIT_DEBUG_NODE (dates);
345 BOOST_SPIRIT_DEBUG_NODE (date);
346 BOOST_SPIRIT_DEBUG_NODE (day);
347 BOOST_SPIRIT_DEBUG_NODE (month);
348 BOOST_SPIRIT_DEBUG_NODE (year);
349 BOOST_SPIRIT_DEBUG_NODE (preferred_airlines);
350 BOOST_SPIRIT_DEBUG_NODE (airline_code);
351 BOOST_SPIRIT_DEBUG_NODE (airline_name);
352 BOOST_SPIRIT_DEBUG_NODE (passengers);
353 BOOST_SPIRIT_DEBUG_NODE (passenger_number);
354 BOOST_SPIRIT_DEBUG_NODE (passenger_type);
355 BOOST_SPIRIT_DEBUG_NODE (passenger_adult_type);
356 BOOST_SPIRIT_DEBUG_NODE (passenger_child_type);
357 BOOST_SPIRIT_DEBUG_NODE (passenger_pet_type);
360 boost::spirit::classic::rule<ScannerT> search_string, places, place_element,
361 dates, date, month, day,
year,
362 preferred_airlines, airline_code, airline_name,
363 passengers, passenger_number, passenger_type, passenger_adult_type,
364 passenger_child_type, passenger_pet_type;
366 boost::spirit::classic::rule<ScannerT>
const&
start()
const {
return search_string; }
377 iterator_t lStringIterator = iSearchString.c_str();
381 boost::spirit::classic::parse_info<iterator_t> info =
382 boost::spirit::classic::parse (lStringIterator, lSearchStringParser,
383 boost::spirit::classic::space_p);
385 STDAIR_LOG_DEBUG (
"-------------------------");
387 bool hasBeenParsingSuccessful = info.full;
388 if (hasBeenParsingSuccessful ==
true) {
389 STDAIR_LOG_DEBUG (
"Parsing succeeded");
392 STDAIR_LOG_DEBUG (
"Parsing failed");
394 STDAIR_LOG_DEBUG (
"-------------------------");
396 return oSearchStringStruct;