00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_BookingClass.hpp> 00009 #include <stdair/bom/CancellationStruct.hpp> 00010 00011 namespace stdair { 00012 // //////////////////////////////////////////////////////////////////// 00013 CancellationStruct::CancellationStruct (const SegmentPath_T& iSegPath, 00014 const ClassList_String_T& iList, 00015 const PartySize_T& iSize, 00016 const DateTime_T& iDateTime) 00017 : _segmentPath (iSegPath), _classList (iList), _partySize (iSize), 00018 _datetime (iDateTime) { 00019 } 00020 00021 // //////////////////////////////////////////////////////////////////// 00022 CancellationStruct::~CancellationStruct() { 00023 } 00024 00025 // //////////////////////////////////////////////////////////////////// 00026 void CancellationStruct::toStream (std::ostream& ioOut) const { 00027 ioOut << describe(); 00028 } 00029 00030 // //////////////////////////////////////////////////////////////////// 00031 void CancellationStruct::fromStream (std::istream& ioIn) { 00032 } 00033 00034 // //////////////////////////////////////////////////////////////////// 00035 const std::string CancellationStruct::describe() const { 00036 std::ostringstream oStr; 00037 00038 oStr << "Segment path: "; 00039 unsigned short idx = 0; 00040 for (SegmentPath_T::const_iterator lItSegmentPath = _segmentPath.begin(); 00041 lItSegmentPath != _segmentPath.end(); ++lItSegmentPath, ++idx) { 00042 if (idx != 0) { 00043 oStr << "-"; 00044 } 00045 const std::string& lSegmentKey = *lItSegmentPath; 00046 oStr << lSegmentKey; 00047 } 00048 00049 oStr << ";" << _classList << ";" << _partySize << ";" << _datetime; 00050 return oStr.str(); 00051 } 00052 00053 // //////////////////////////////////////////////////////////////////// 00054 const std::string CancellationStruct::display() const { 00055 std::ostringstream oStr; 00056 00057 // List of segment keys (one per segment) 00058 unsigned short idx = 0; 00059 for (SegmentPath_T::const_iterator itSegPath = _segmentPath.begin(); 00060 itSegPath != _segmentPath.end(); ++itSegPath, ++idx) { 00061 if (idx != 0) { 00062 oStr << " ; "; 00063 } 00064 const std::string& lSegmentKey = *itSegPath; 00065 oStr << "[" << idx << "] " << lSegmentKey; 00066 } 00067 00068 oStr << ";" << _classList << ";" << _partySize << ";" << _datetime; 00069 return oStr.str(); 00070 } 00071 }