OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ServiceAbstract.hpp
Go to the documentation of this file.
1 #ifndef __OPENTREP_SVC_SERVICEABSTRACT_HPP
2 #define __OPENTREP_SVC_SERVICEABSTRACT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iostream>
9 #include <sstream>
10 
11 namespace OPENTREP {
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 OPENTREP::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  OPENTREP::ServiceAbstract& ioService) {
72  // Fill Service object with input stream
73  ioService.fromStream (ioIn);
74  return ioIn;
75 }
76 
77 #endif // __OPENTREP_SVC_SERVICEABSTRACT_HPP
virtual void toStream(std::ostream &ioOut) const
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &ioIn, OPENTREP::ServiceAbstract &ioService)
virtual void fromStream(std::istream &ioIn)