StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KeyAbstract.hpp
Go to the documentation of this file.
1 
7 #ifndef __STDAIR_BOM_KEYABSTRACT_HPP
8 #define __STDAIR_BOM_KEYABSTRACT_HPP
9 
10 // //////////////////////////////////////////////////////////////////////
11 // Import section
12 // //////////////////////////////////////////////////////////////////////
13 // STL
14 #include <iosfwd>
15 #include <string>
16 
17 namespace stdair {
18 
26  struct KeyAbstract {
27  public:
28 
29  // /////////// Display support methods /////////
34  virtual void toStream (std::ostream& ioOut) const {}
35 
40  virtual void fromStream (std::istream& ioIn) {}
41 
51  virtual const std::string toString() const { return std::string("Hello!"); }
52 
56  virtual ~KeyAbstract() {}
57  };
58 
59 }
60 
66 template <class charT, class traits>
67 inline
68 std::basic_ostream<charT, traits>&
69 operator<< (std::basic_ostream<charT, traits>& ioOut,
70  const stdair::KeyAbstract& iKey) {
76  std::basic_ostringstream<charT,traits> ostr;
77  ostr.copyfmt (ioOut);
78  ostr.width (0);
79 
80  // Fill string stream
81  iKey.toStream (ostr);
82 
83  // Print string stream
84  ioOut << ostr.str();
85 
86  return ioOut;
87 }
88 
94 template <class charT, class traits>
95 inline
96 std::basic_istream<charT, traits>&
97 operator>> (std::basic_istream<charT, traits>& ioIn,
98  stdair::KeyAbstract& ioKey) {
99  // Fill Key object with input stream
100  ioKey.fromStream (ioIn);
101  return ioIn;
102 }
103 
104 #endif // __STDAIR_BOM_KEYABSTRACT_HPP