OpenTREP Logo  0.07.18
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
LocationKey.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6// OpenTrep
9
10namespace OPENTREP {
11
12 // //////////////////////////////////////////////////////////////////////
14 const IATAType& iIataType,
15 const GeonamesID_T& iGeonamesID) :
16 _iataCode (iIataCode), _iataType (iIataType), _geonamesID (iGeonamesID) {
17 if (_geonamesID == 0) {
18 _isGeonames = false;
19 } else {
20 _isGeonames = true;
21 }
22 }
23
24 // //////////////////////////////////////////////////////////////////////
26 _iataCode (IATACode_T ("")), _iataType (IATAType::LAST_VALUE),
27 _geonamesID (0), _isGeonames (false) {
28 assert (false);
29 }
30
31 // //////////////////////////////////////////////////////////////////////
32 LocationKey::LocationKey (const LocationKey& iLocationKey) :
33 _iataCode (iLocationKey._iataCode), _iataType (iLocationKey._iataType),
34 _geonamesID (iLocationKey._geonamesID),
35 _isGeonames (iLocationKey._isGeonames) {
36 }
37
38 // //////////////////////////////////////////////////////////////////////
41
42 // //////////////////////////////////////////////////////////////////////
43 bool LocationKey::operator== (const LocationKey& iLocationKey) const {
44 const bool areEqual = (_iataCode == iLocationKey._iataCode
45 && _iataType == iLocationKey._iataType
46 && _geonamesID == iLocationKey._geonamesID);
47 return areEqual;
48 }
49
50 // //////////////////////////////////////////////////////////////////////
51 std::string LocationKey::describe() const {
52 std::ostringstream oStr;
53 oStr << _iataCode << "-" << _iataType.getTypeAsString()
54 << "-" << _geonamesID;
55
56 return oStr.str();
57 }
58
59 // //////////////////////////////////////////////////////////////////////
60 std::string LocationKey::toString() const {
61 std::ostringstream oStr;
62 oStr << describe();
63 return oStr.str();
64 }
65
66 // //////////////////////////////////////////////////////////////////////
67 void LocationKey::toStream (std::ostream& ioOut) const {
68 ioOut << toString();
69 }
70
71 // //////////////////////////////////////////////////////////////////////
72 void LocationKey::fromStream (std::istream& ioIn) {
73 }
74
75}
unsigned int GeonamesID_T
Enumeration of place/location types with respect to their use for transportation purposes.
Definition IATAType.hpp:42
void toStream(std::ostream &) const
std::string describe() const
LocationKey(const IATACode_T &, const IATAType &, const GeonamesID_T &)
std::string toString() const
bool operator==(const LocationKey &) const
void fromStream(std::istream &)