AirInv Logo  1.00.0
C++ Simulated Airline Inventory Management System library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ServiceAbstract.hpp
Go to the documentation of this file.
1 #ifndef __AIRINV_SVC_SERVICEABSTRACT_HPP
2 #define __AIRINV_SVC_SERVICEABSTRACT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iosfwd>
9 //#include <sstream>
10 
11 namespace AIRINV {
12 
15  public:
16 
18  virtual ~ServiceAbstract() {}
19 
22  virtual void toStream (std::ostream& ioOut) const {}
23 
26  virtual void fromStream (std::istream& ioIn) {}
27 
28  protected:
31  };
32 }
33 
39 template <class charT, class traits>
40 inline
41 std::basic_ostream<charT, traits>&
42 operator<< (std::basic_ostream<charT, traits>& ioOut,
43  const AIRINV::ServiceAbstract& iService) {
49  std::basic_ostringstream<charT,traits> ostr;
50  ostr.copyfmt (ioOut);
51  ostr.width (0);
52 
53  // Fill string stream
54  iService.toStream (ostr);
55 
56  // Print string stream
57  ioOut << ostr.str();
58 
59  return ioOut;
60 }
61 
67 template <class charT, class traits>
68 inline
69 std::basic_istream<charT, traits>&
70 operator>> (std::basic_istream<charT, traits>& ioIn,
71  AIRINV::ServiceAbstract& ioService) {
72  // Fill Service object with input stream
73  ioService.fromStream (ioIn);
74  return ioIn;
75 }
76 
77 #endif // __AIRINV_SVC_SERVICEABSTRACT_HPP