OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KeyAbstract.hpp
Go to the documentation of this file.
1 #ifndef __OPENTREP_KEY_KEYABSTRACT_HPP
2 #define __OPENTREP_KEY_KEYABSTRACT_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <iosfwd>
9 #include <sstream>
10 #include <string>
11 
12 namespace OPENTREP {
13 
17  class KeyAbstract {
18  public:
19  // /////////// Display support methods /////////
25  virtual void toStream (std::ostream&) const = 0;
26 
32  virtual void fromStream (std::istream&) = 0;
33 
37  virtual std::string toString() const = 0;
38 
43  virtual std::string describe() const = 0;
44 
45 
46  protected:
52 
56  virtual ~KeyAbstract() {}
57  };
58 }
59 
65 template <class charT, class traits>
66 inline
67 std::basic_ostream<charT, traits>&
68 operator<< (std::basic_ostream<charT, traits>& ioOut,
69  const OPENTREP::KeyAbstract& iKey) {
75  std::basic_ostringstream<charT,traits> ostr;
76  ostr.copyfmt (ioOut);
77  ostr.width (0);
78 
79  // Fill string stream
80  iKey.toStream (ostr);
81 
82  // Print string stream
83  ioOut << ostr.str();
84 
85  return ioOut;
86 }
87 
93 template <class charT, class traits>
94 inline
95 std::basic_istream<charT, traits>&
96 operator>> (std::basic_istream<charT, traits>& ioIn,
97  OPENTREP::KeyAbstract& ioKey) {
98  // Fill Key object with input stream
99  ioKey.fromStream (ioIn);
100  return ioIn;
101 }
102 
103 #endif // __OPENTREP_KEY_KEYABSTRACT_HPP
virtual std::string toString() const =0
Base class for the Business Object Model (KEY) layer.
Definition: KeyAbstract.hpp:17
virtual std::string describe() const =0
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &ioIn, OPENTREP::KeyAbstract &ioKey)
Definition: KeyAbstract.hpp:96
virtual void fromStream(std::istream &)=0
KeyAbstract(const KeyAbstract &)
Definition: KeyAbstract.hpp:51
virtual void toStream(std::ostream &) const =0