From: <qua...@us...> - 2010-12-02 15:46:43
|
Revision: 29 http://simfqt.svn.sourceforge.net/simfqt/?rev=29&view=rev Author: quannaus Date: 2010-12-02 15:46:37 +0000 (Thu, 02 Dec 2010) Log Message: ----------- [dev] Adapted to the new stdair with the change in the exceptions. Modified Paths: -------------- trunk/simfqt/simfqt/basic/sources.mk trunk/simfqt/simfqt/bom/FareRuleStruct.hpp trunk/simfqt/simfqt/command/FareParserHelper.cpp trunk/simfqt/simfqt/command/FareParserHelper.hpp Removed Paths: ------------- trunk/simfqt/simfqt/basic/BasParserTypes.hpp Deleted: trunk/simfqt/simfqt/basic/BasParserTypes.hpp =================================================================== --- trunk/simfqt/simfqt/basic/BasParserTypes.hpp 2010-12-02 10:44:31 UTC (rev 28) +++ trunk/simfqt/simfqt/basic/BasParserTypes.hpp 2010-12-02 15:46:37 UTC (rev 29) @@ -1,90 +0,0 @@ -#ifndef __SIMFQT_BAS_BASCOMPARSERTYPES_HPP -#define __SIMFQT_BAS_BASCOMPARSERTYPES_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <string> -#include <limits> -// Boost Spirit (Parsing) -#include <boost/spirit/include/qi.hpp> -#include <boost/spirit/include/phoenix_core.hpp> -#include <boost/spirit/include/phoenix_operator.hpp> -#include <boost/spirit/include/support_multi_pass.hpp> - -namespace SIMFQT { - - // /////////////////////////////////////////////////////////////////////// - // - // Definition of Basic Types - // - // /////////////////////////////////////////////////////////////////////// - - // The types of iterator, scanner and rule are then derived from - // the parsing unit. - typedef std::istreambuf_iterator<char> base_iterator_t; - typedef boost::spirit::multi_pass<base_iterator_t> iterator_t; - - - // /////////////////////////////////////////////////////////////////////// - // - // Parser related types - // - // /////////////////////////////////////////////////////////////////////// - /** 1-digit-integer parser */ - typedef boost::spirit::qi::int_parser<unsigned int, 10, 1, 1> int1_p_t; - - /** 2-digit-integer parser */ - typedef boost::spirit::qi::uint_parser<int, 10, 2, 2> uint2_p_t; - - /** 4-digit-integer parser */ - typedef boost::spirit::qi::uint_parser<int, 10, 4, 4> uint4_p_t; - - /** Up-to-4-digit-integer parser */ - typedef boost::spirit::qi::uint_parser<int, 10, 1, 4> uint1_4_p_t; - - /** Time parser. */ - template <int MIN = 0, int MAX = 0> - struct date_time_element { - unsigned int _value; - - // Constructors. - date_time_element () { } - date_time_element (const date_time_element& t) - : _value (t._value) { } - date_time_element (int i) : _value (i) { } - void check () const { - if (_value < MIN || _value > MAX) { - STDAIR_LOG_ERROR ("The value: " << _value - << " is out of range (" - << MIN << ", " << MAX << ")"); - throw stdair::ParserException (); - } - } - }; - - typedef date_time_element<0, 23> hour_t; - typedef date_time_element<0, 59> minute_t; - typedef date_time_element<0, 59> second_t; - typedef date_time_element<1900, 2100> year_t; - typedef date_time_element<1, 12> month_t; - typedef date_time_element<1, 31> day_t; - typedef boost::spirit::qi::uint_parser<hour_t, 10, 2, 2> hour_p_t; - typedef boost::spirit::qi::uint_parser<minute_t, 10, 2, 2> minute_p_t; - typedef boost::spirit::qi::uint_parser<second_t, 10, 2, 2> second_p_t; - typedef boost::spirit::qi::uint_parser<year_t, 10, 4, 4> year_p_t; - typedef boost::spirit::qi::uint_parser<month_t, 10, 2, 2> month_p_t; - typedef boost::spirit::qi::uint_parser<day_t, 10, 2, 2> day_p_t; - - - template <int MIN, int MAX> - inline date_time_element<MIN, MAX> operator* (const date_time_element<MIN, MAX>& h1, const date_time_element<MIN, MAX>& h2) { - return date_time_element<MIN, MAX> (h1._value * h2._value); - } - template <int MIN, int MAX> - inline date_time_element<MIN, MAX> operator+ (const date_time_element<MIN, MAX>& h1, const date_time_element<MIN, MAX>& h2) { - return date_time_element<MIN, MAX> (h1._value + h2._value); - } -} -#endif // __SIMFQT_BAS_BASCOMPARSERTYPES_HPP Modified: trunk/simfqt/simfqt/basic/sources.mk =================================================================== --- trunk/simfqt/simfqt/basic/sources.mk 2010-12-02 10:44:31 UTC (rev 28) +++ trunk/simfqt/simfqt/basic/sources.mk 2010-12-02 15:46:37 UTC (rev 29) @@ -1,6 +1,5 @@ simfqt_bas_h_sources = \ $(top_srcdir)/simfqt/basic/BasConst_General.hpp \ - $(top_srcdir)/simfqt/basic/BasConst_SIMFQT_Service.hpp \ - $(top_srcdir)/simfqt/basic/BasParserTypes.hpp + $(top_srcdir)/simfqt/basic/BasConst_SIMFQT_Service.hpp simfqt_bas_cc_sources = \ $(top_srcdir)/simfqt/basic/BasConst.cpp Modified: trunk/simfqt/simfqt/bom/FareRuleStruct.hpp =================================================================== --- trunk/simfqt/simfqt/bom/FareRuleStruct.hpp 2010-12-02 10:44:31 UTC (rev 28) +++ trunk/simfqt/simfqt/bom/FareRuleStruct.hpp 2010-12-02 15:46:37 UTC (rev 29) @@ -10,9 +10,9 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/StructAbstract.hpp> +#include <stdair/basic/BasParserTypes.hpp> // SIMFQT #include <simfqt/SIMFQT_Types.hpp> -#include <simfqt/basic/BasParserTypes.hpp> namespace SIMFQT { @@ -34,15 +34,15 @@ // ////////////////// Attributes ///////////////// /** Staging Date. */ - year_t _itYear; - month_t _itMonth; - day_t _itDay; + stdair::year_t _itYear; + stdair::month_t _itMonth; + stdair::day_t _itDay; /** Staging Time. */ //long _itHours; - hour_t _itHours; - minute_t _itMinutes; - second_t _itSeconds; + stdair::hour_t _itHours; + stdair::minute_t _itMinutes; + stdair::second_t _itSeconds; unsigned long int _nbOfAirlines; Modified: trunk/simfqt/simfqt/command/FareParserHelper.cpp =================================================================== --- trunk/simfqt/simfqt/command/FareParserHelper.cpp 2010-12-02 10:44:31 UTC (rev 28) +++ trunk/simfqt/simfqt/command/FareParserHelper.cpp 2010-12-02 15:46:37 UTC (rev 29) @@ -377,26 +377,26 @@ namespace bsa = boost::spirit::ascii; /** 1-digit-integer parser */ - int1_p_t int1_p; + stdair::int1_p_t int1_p; /** 2-digit-integer parser */ - uint2_p_t uint2_p; + stdair::uint2_p_t uint2_p; /** 4-digit-integer parser */ - uint4_p_t uint4_p; + stdair::uint4_p_t uint4_p; /** Up-to-4-digit-integer parser */ - uint1_4_p_t uint1_4_p; + stdair::uint1_4_p_t uint1_4_p; /** Time element parsers. */ - hour_p_t hour_p; - minute_p_t minute_p; - second_p_t second_p; + stdair::hour_p_t hour_p; + stdair::minute_p_t minute_p; + stdair::second_p_t second_p; /** Date element parsers. */ - year_p_t year_p; - month_p_t month_p; - day_p_t day_p; + stdair::year_p_t year_p; + stdair::month_p_t month_p; + stdair::day_p_t day_p; // ////////////////////////////////////////////////////////////////// // (Boost Spirit) Grammar Definition @@ -504,12 +504,7 @@ BOOST_SPIRIT_DEBUG_NODE (minimumStay); BOOST_SPIRIT_DEBUG_NODE (fare); BOOST_SPIRIT_DEBUG_NODE (segment); - - hour_t h1 (2); - hour_t h2 (3); - h1 = h1 * h2; } - } ///////////////////////////////////////////////////////////////////////// @@ -559,11 +554,12 @@ } // Create an input iterator - base_iterator_t inputBegin (fileToBeParsed); - + stdair::base_iterator_t inputBegin (fileToBeParsed); + // Convert input iterator to an iterator usable by spirit parser - iterator_t start (boost::spirit::make_default_multi_pass (inputBegin)); - iterator_t end; + stdair::iterator_t + start (boost::spirit::make_default_multi_pass (inputBegin)); + stdair::iterator_t end; // Initialise the parser (grammar) with the helper/staging structure. FareParserHelper::FareRuleParser lFPParser(_bomRoot, _fareRule); @@ -579,7 +575,6 @@ // TODO: decide whether to throw an exceqption STDAIR_LOG_ERROR ("Parsing of fare input file: " << _filename << " failed"); - } if (start != end) { // TODO: decide whether to throw an exception Modified: trunk/simfqt/simfqt/command/FareParserHelper.hpp =================================================================== --- trunk/simfqt/simfqt/command/FareParserHelper.hpp 2010-12-02 10:44:31 UTC (rev 28) +++ trunk/simfqt/simfqt/command/FareParserHelper.hpp 2010-12-02 15:46:37 UTC (rev 29) @@ -8,10 +8,10 @@ #include <string> //#define BOOST_SPIRIT_DEBUG // StdAir +#include <stdair/basic/BasParserTypes.hpp> #include <stdair/command/CmdAbstract.hpp> // Simfqt #include <simfqt/SIMFQT_Types.hpp> -#include <simfqt/basic/BasParserTypes.hpp> #include <simfqt/bom/FareRuleStruct.hpp> // Forward declarations @@ -292,12 +292,14 @@ /** Grammar for the Fare-Rule parser. */ struct FareRuleParser : - public boost::spirit::qi::grammar<iterator_t, boost::spirit::ascii::space_type> { + public boost::spirit::qi::grammar<stdair::iterator_t, + boost::spirit::ascii::space_type> { FareRuleParser (stdair::BomRoot&, FareRuleStruct&); // Instantiation of rules - boost::spirit::qi::rule<iterator_t, boost::spirit::ascii::space_type> + boost::spirit::qi::rule<stdair::iterator_t, + boost::spirit::ascii::space_type> start, comments, fare_rule, fare_rule_end, fare_key, fare_id, origin, destination, dateRangeStart, dateRangeEnd, date, timeRangeStart, timeRangeEnd, time, position, channel, advancePurchase, saturdayStay, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |