StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
BomKeyManager.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // Boost
8 #include <boost/tokenizer.hpp>
9 #include <boost/lexical_cast.hpp>
10 #include <boost/date_time/gregorian/parsers.hpp>
11 // StdAir
18 #include <stdair/bom/ParsedKey.hpp>
21 
22 namespace stdair {
23 
24  // ////////////// Tokenising support ///////////////
28  typedef boost::tokenizer<boost::char_separator<char> > Tokeniser_T;
29 
30  // ////////////////////////////////////////////////////////////////////
31  ParsedKey BomKeyManager::extractKeys (const std::string& iFullKeyStr) {
32  ParsedKey oParsedKey;
33  oParsedKey._fullKey = iFullKeyStr;
34 
35  // Token-ise the full key string
36  Tokeniser_T lTokens (iFullKeyStr, DEFAULT_KEY_TOKEN_DELIMITER);
37  Tokeniser_T::iterator itToken = lTokens.begin();
38 
39  // Airline code
40  if (itToken != lTokens.end()) {
41  oParsedKey._airlineCode = *itToken;
42 
43  // Flight number
44  ++itToken;
45  if (itToken != lTokens.end()) {
46  oParsedKey._flightNumber = *itToken;
47 
48  // Departure date
49  ++itToken;
50  if (itToken != lTokens.end()) {
51  oParsedKey._departureDate = *itToken;
52 
53  // Origin
54  ++itToken;
55  if (itToken != lTokens.end()) {
56  oParsedKey._boardingPoint = *itToken;
57 
58  // Destination
59  ++itToken;
60  if (itToken != lTokens.end()) {
61  oParsedKey._offPoint = *itToken;
62 
63  // Boarding time
64  ++itToken;
65  if (itToken != lTokens.end()) {
66  oParsedKey._boardingTime = *itToken;
67  }
68  }
69  }
70  }
71  }
72  }
73 
74  return oParsedKey;
75  }
76 
77  // ////////////////////////////////////////////////////////////////////
79  extractInventoryKey (const std::string& iFullKeyStr) {
80  ParsedKey lParsedKey = extractKeys (iFullKeyStr);
81 
82  return lParsedKey.getInventoryKey();
83  }
84 
85  // ////////////////////////////////////////////////////////////////////
87  extractFlightDateKey (const std::string& iFullKeyStr) {
88  ParsedKey lParsedKey = extractKeys (iFullKeyStr);
89 
90  return lParsedKey.getFlightDateKey();
91  }
92 
93  // ////////////////////////////////////////////////////////////////////
95  extractSegmentDateKey (const std::string& iFullKeyStr) {
96  ParsedKey lParsedKey = extractKeys (iFullKeyStr);
97 
98  return lParsedKey.getSegmentKey();
99  }
100 
101  // ////////////////////////////////////////////////////////////////////
103  extractLegDateKey (const std::string& iFullKeyStr) {
104  ParsedKey lParsedKey = extractKeys (iFullKeyStr);
105 
106  return lParsedKey.getLegKey();
107  }
108 }
std::string _offPoint
Definition: ParsedKey.hpp:81
std::string _flightNumber
Definition: ParsedKey.hpp:78
Handle on the StdAir library context.
std::string _departureDate
Definition: ParsedKey.hpp:79
SegmentDateKey getSegmentKey() const
Definition: ParsedKey.cpp:98
static InventoryKey extractInventoryKey(const std::string &iFullKeyStr)
std::string _fullKey
Definition: ParsedKey.hpp:76
static ParsedKey extractKeys(const std::string &iFullKeyStr)
LegDateKey getLegKey() const
Definition: ParsedKey.cpp:84
std::string _airlineCode
Definition: ParsedKey.hpp:77
Key of a given inventory, made of the airline code.
FlightDateKey getFlightDateKey() const
Definition: ParsedKey.cpp:62
std::string _boardingTime
Definition: ParsedKey.hpp:82
InventoryKey getInventoryKey() const
Definition: ParsedKey.cpp:51
Key of a given flight-date, made of a flight number and a departure date.
std::string _boardingPoint
Definition: ParsedKey.hpp:80
const boost::char_separator< char > DEFAULT_KEY_TOKEN_DELIMITER
static FlightDateKey extractFlightDateKey(const std::string &iFullKeyStr)
Key of a given segment-date, made of an origin and a destination airports.
boost::tokenizer< boost::char_separator< char > > Tokeniser_T
static LegDateKey extractLegDateKey(const std::string &iFullKeyStr)
static SegmentDateKey extractSegmentDateKey(const std::string &iFullKeyStr)