StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
CancellationStruct.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
11 
12 namespace stdair {
13  // ////////////////////////////////////////////////////////////////////
15  const ClassList_String_T& iList,
16  const PartySize_T& iSize,
17  const DateTime_T& iDateTime)
18  : _segmentPath (iSegPath), _classList (iList), _partySize (iSize),
19  _datetime (iDateTime) {
20  }
21 
22  // ////////////////////////////////////////////////////////////////////
24  const BookingClassIDList_T& iIDList,
25  const PartySize_T& iSize,
26  const DateTime_T& iDateTime)
27  : _segmentPath (iSegPath), _classIDList (iIDList), _partySize (iSize),
28  _datetime (iDateTime) {
29  }
30 
31  // ////////////////////////////////////////////////////////////////////
33  }
34 
35  // ////////////////////////////////////////////////////////////////////
36  void CancellationStruct::toStream (std::ostream& ioOut) const {
37  ioOut << describe();
38  }
39 
40  // ////////////////////////////////////////////////////////////////////
41  void CancellationStruct::fromStream (std::istream& ioIn) {
42  }
43 
44  // ////////////////////////////////////////////////////////////////////
45  const std::string CancellationStruct::describe() const {
46  std::ostringstream oStr;
47 
48  oStr << "Segment path: ";
49  unsigned short idx = 0;
50  for (SegmentPath_T::const_iterator lItSegmentPath = _segmentPath.begin();
51  lItSegmentPath != _segmentPath.end(); ++lItSegmentPath, ++idx) {
52  if (idx != 0) {
53  oStr << "-";
54  }
55  const std::string& lSegmentKey = *lItSegmentPath;
56  oStr << lSegmentKey;
57  }
58  if (_classList == "") {
59  oStr << ";";
60  BookingClassIDList_T::const_iterator lItBookingClassIDList =
61  _classIDList.begin();
62  idx = 0;
63  for (; lItBookingClassIDList != _classIDList.end();
64  ++lItBookingClassIDList, ++idx) {
65  if (idx != 0) {
66  oStr << "-";
67  }
68  const BookingClassID_T& lBookingClassID = *lItBookingClassIDList;
69  const BookingClass& lBookingClass = lBookingClassID.getObject();
70  const ClassCode_T& lClassCode = lBookingClass.getClassCode();
71  oStr << lClassCode;
72  }
73  oStr << ";" << _partySize << ";" << _datetime;
74  } else {
75  oStr << ";" << _classList << ";" << _partySize << ";" << _datetime;
76  }
77  return oStr.str();
78  }
79 
80  // ////////////////////////////////////////////////////////////////////
81  const std::string CancellationStruct::display() const {
82  std::ostringstream oStr;
83 
84  // List of segment keys (one per segment)
85  unsigned short idx = 0;
86  for (SegmentPath_T::const_iterator itSegPath = _segmentPath.begin();
87  itSegPath != _segmentPath.end(); ++itSegPath, ++idx) {
88  if (idx != 0) {
89  oStr << " ; ";
90  }
91  const std::string& lSegmentKey = *itSegPath;
92  oStr << "[" << idx << "] " << lSegmentKey;
93  }
94  if (_classList == "") {
95  oStr << ";";
96  BookingClassIDList_T::const_iterator lItBookingClassIDList =
97  _classIDList.begin();
98  idx = 0;
99  for (; lItBookingClassIDList != _classIDList.end();
100  ++lItBookingClassIDList, ++idx) {
101  if (idx != 0) {
102  oStr << "-";
103  }
104  const BookingClassID_T& lBookingClassID = *lItBookingClassIDList;
105  const BookingClass& lBookingClass = lBookingClassID.getObject();
106  const ClassCode_T& lClassCode = lBookingClass.getClassCode();
107  oStr << lClassCode;
108  }
109  oStr << ";" << _partySize << ";" << _datetime;
110  } else {
111  oStr << ";" << _classList << ";" << _partySize << ";" << _datetime;
112  }
113  return oStr.str();
114  }
115 }
boost::posix_time::ptime DateTime_T
Handle on the StdAir library context.
void fromStream(std::istream &ioIn)
std::list< BookingClassID_T > BookingClassIDList_T
Definition: BomIDTypes.hpp:24
Class wrapper of bom ID (e.g. pointer to object).
Definition: BomID.hpp:17
BOM & getObject() const
Definition: BomID.hpp:68
const std::string display() const
const std::string describe() const
CancellationStruct(const SegmentPath_T &, const ClassList_String_T &, const PartySize_T &, const DateTime_T &)
std::string ClassList_String_T
const ClassCode_T & getClassCode() const
void toStream(std::ostream &ioOut) const
std::string ClassCode_T
KeyList_T SegmentPath_T