StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
AirlineClassListKey.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // Boost.Serialization
8 #include <boost/archive/text_iarchive.hpp>
9 #include <boost/archive/text_oarchive.hpp>
10 #include <boost/serialization/access.hpp>
11 // StdAir
14 
15 namespace stdair {
16 
17  // ////////////////////////////////////////////////////////////////////
18  AirlineClassListKey::AirlineClassListKey() {
19  assert (false);
20  }
21 
22  // ////////////////////////////////////////////////////////////////////
23  AirlineClassListKey::
24  AirlineClassListKey (const AirlineCodeList_T& iAirlineCodeList,
25  const ClassList_StringList_T& iClassCodeList)
26  : _airlineCodeList (iAirlineCodeList), _classCodeList (iClassCodeList) {
27  }
28 
29  // ////////////////////////////////////////////////////////////////////
30  AirlineClassListKey::AirlineClassListKey (const AirlineClassListKey& iKey)
31  : _airlineCodeList (iKey._airlineCodeList),
32  _classCodeList (iKey._classCodeList) {
33  }
34 
35  // ////////////////////////////////////////////////////////////////////
37  }
38 
39  // ////////////////////////////////////////////////////////////////////
40  void AirlineClassListKey::toStream (std::ostream& ioOut) const {
41  ioOut << "AirlineClassListKey: " << toString() << std::endl;
42  }
43 
44  // ////////////////////////////////////////////////////////////////////
45  void AirlineClassListKey::fromStream (std::istream& ioIn) {
46  }
47 
48  // ////////////////////////////////////////////////////////////////////
49  const std::string AirlineClassListKey::toString() const {
50  std::ostringstream oStr;
51  assert (_airlineCodeList.size() == _classCodeList.size());
52 
53  unsigned short idx = 0;
54  AirlineCodeList_T::const_iterator itAirlineCode = _airlineCodeList.begin();
55  for (ClassList_StringList_T::const_iterator itClassCode =
56  _classCodeList.begin(); itClassCode != _classCodeList.end();
57  ++itClassCode, ++itAirlineCode, ++idx) {
58  if (idx != 0) {
59  oStr << DEFAULT_KEY_SUB_FLD_DELIMITER << " ";
60  }
61 
62  const AirlineCode_T& lAirlineCode = *itAirlineCode;
63  const ClassCode_T& lClassCode = *itClassCode;
64  oStr << lAirlineCode << " " << lClassCode;
65  }
66 
67  return oStr.str();
68  }
69 
70  // ////////////////////////////////////////////////////////////////////
71  void AirlineClassListKey::serialisationImplementationExport() const {
72  std::ostringstream oStr;
73  boost::archive::text_oarchive oa (oStr);
74  oa << *this;
75  }
76 
77  // ////////////////////////////////////////////////////////////////////
78  void AirlineClassListKey::serialisationImplementationImport() {
79  std::istringstream iStr;
80  boost::archive::text_iarchive ia (iStr);
81  ia >> *this;
82  }
83 
84  // ////////////////////////////////////////////////////////////////////
85  template<class Archive>
86  void AirlineClassListKey::serialize (Archive& ioArchive,
87  const unsigned int iFileVersion) {
96  AirlineCodeList_T::const_iterator itAirlineCode = _airlineCodeList.begin();
97  for (ClassList_StringList_T::const_iterator itClassCode =
98  _classCodeList.begin(); itClassCode != _classCodeList.end();
99  ++itClassCode, ++itAirlineCode) {
100  AirlineCode_T lAirlineCode = *itAirlineCode;
101  ClassCode_T lClassCode = *itClassCode;
102 
103  ioArchive & lAirlineCode & lClassCode;
104  }
105  }
106 
107  // ////////////////////////////////////////////////////////////////////
108  // Explicit template instantiation
109  namespace ba = boost::archive;
110  template void AirlineClassListKey::
111  serialize<ba::text_oarchive> (ba::text_oarchive&, unsigned int);
112  template void AirlineClassListKey::
113  serialize<ba::text_iarchive> (ba::text_iarchive&, unsigned int);
114  // ////////////////////////////////////////////////////////////////////
115 
116 }
const std::string DEFAULT_KEY_SUB_FLD_DELIMITER
std::vector< ClassList_String_T > ClassList_StringList_T
Handle on the StdAir library context.
const std::string toString() const
std::string AirlineCode_T
void fromStream(std::istream &ioIn)
std::vector< AirlineCode_T > AirlineCodeList_T
void toStream(std::ostream &ioOut) const
void serialize(Archive &ar, const unsigned int iFileVersion)
std::string ClassCode_T