StdAir Logo  1.00.0
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
27  struct KeyAbstract {
28  public:
29 
30  // /////////// Display support methods /////////
36  virtual void toStream (std::ostream& ioOut) const {}
37 
43  virtual void fromStream (std::istream& ioIn) {}
44 
56  virtual const std::string toString() const { return std::string("Hello!"); }
57 
61  virtual ~KeyAbstract() {}
62  };
63 
64 }
65 
71 template <class charT, class traits>
72 inline
73 std::basic_ostream<charT, traits>&
74 operator<< (std::basic_ostream<charT, traits>& ioOut,
75  const stdair::KeyAbstract& iKey) {
81  std::basic_ostringstream<charT,traits> ostr;
82  ostr.copyfmt (ioOut);
83  ostr.width (0);
84 
85  // Fill string stream
86  iKey.toStream (ostr);
87 
88  // Print string stream
89  ioOut << ostr.str();
90 
91  return ioOut;
92 }
93 
99 template <class charT, class traits>
100 inline
101 std::basic_istream<charT, traits>&
102 operator>> (std::basic_istream<charT, traits>& ioIn,
103  stdair::KeyAbstract& ioKey) {
104  // Fill Key object with input stream
105  ioKey.fromStream (ioIn);
106  return ioIn;
107 }
108 
109 #endif // __STDAIR_BOM_KEYABSTRACT_HPP