Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
orstream.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file utility/io/orstream.hh
11 /// @brief Output stream wrapper abstract base class
12 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
13 
14 
15 #ifndef INCLUDED_utility_io_orstream_hh
16 #define INCLUDED_utility_io_orstream_hh
17 
18 
19 // Unit headers
21 
22 // C++ headers
23 #include <iosfwd>
24 #include <string>
25 #include <iostream>
26 
27 
28 namespace utility {
29 namespace io {
30 
31 
32 /// @brief orstream: Output stream wrapper base class
33 class orstream
34 {
35 
36 
37 protected: // Types
38 
39 
40  typedef std::ostream & (*manipulator)( std::ostream & );
41 
42 
43 public: // Creation
44 
45 
46  /// @brief Destructor
47  inline
48  virtual
50  {}
51 
52 
53 protected: // Creation
54 
55 
56  /// @brief Default constructor
57  inline
59  {}
60 
61 
62 private: // Creation
63 
64 
65  /// @brief Copy constructor: Undefined
66  orstream( orstream const & );
67 
68 
69 private: // Methods: assignment
70 
71 
72  /// @brief Copy assignment: Undefined
73  orstream &
74  operator =( orstream const & );
75 
76 
77 public: // Methods: conversion
78 
79 
80  /// @brief bool conversion
81  virtual
82  operator bool() const = 0;
83 
84 
85  /// @brief Stream conversion
86  virtual
87  operator std::ostream const &() const = 0;
88 
89 
90  /// @brief Stream conversion
91  virtual
92  operator std::ostream &() = 0;
93 
94 
95 public: // Methods: formatting
96 
97 
98  /// @brief Stream output
99  template< typename T >
100  inline
101  orstream &
102  operator <<( T const & t )
103  {
104  stream() << t;
105  return *this;
106  }
107 
108 
109  /// @brief Stream manipulator output
110  virtual
111  orstream &
112  operator <<( manipulator m ) = 0;
113 
114 
115 public: // Methods: i/o
116 
117 
118  /// @brief Flush the stream
119  virtual
120  orstream &
121  flush() = 0;
122 
123 
124  /// @brief Clear the stream
125  virtual
126  void
127  clear() = 0;
128 
129 
130  /// @brief Write a char
131  virtual
132  orstream &
133  put( char const c ) = 0;
134 
135 
136  /// @brief Write a string
137  virtual
138  orstream &
139  write( char const * str, std::streamsize const count ) = 0;
140 
141 
142  /// @brief Write a string
143  virtual
144  orstream &
145  write( std::string const & str, std::streamsize const count ) = 0;
146 
147 
148 public: // Properties
149 
150 
151  /// @brief Stream access
152  virtual
153  std::ostream const &
154  operator ()() const = 0;
155 
156 
157  /// @brief Stream access
158  virtual
159  std::ostream &
160  operator ()() = 0;
161 
162 
163  /// @brief Stream access
164  virtual
165  std::ostream const &
166  stream() const = 0;
167 
168 
169  /// @brief Stream access
170  virtual
171  std::ostream &
172  stream() = 0;
173 
174 
175  /// @brief Pointer to the stream buffer
176  virtual
177  std::streambuf *
178  rdbuf() const = 0;
179 
180 
181 public: // Properties: predicate
182 
183 
184  /// @brief Good?
185  virtual
186  bool
187  good() const = 0;
188 
189 
190  /// @brief End of file?
191  virtual
192  bool
193  eof() const = 0;
194 
195 
196  /// @brief Fail?
197  virtual
198  bool
199  fail() const = 0;
200 
201 
202  /// @brief Bad?
203  virtual
204  bool
205  bad() const = 0;
206 
207 
208  /// @brief Compressed?
209  virtual
210  bool
211  compressed() const = 0;
212 
213 
214  /// @brief Uncompressed?
215  virtual
216  bool
217  uncompressed() const = 0;
218 
219 
220  /// @brief gzipped?
221  virtual
222  bool
223  gzipped() const = 0;
224 
225 
226 }; // orstream
227 
228 
229 } // namespace io
230 } // namespace utility
231 
232 
233 #endif // INCLUDED_utility_io_orstream_HH
virtual orstream & put(char const c)=0
Write a char.
virtual orstream & flush()=0
Flush the stream.
virtual bool eof() const =0
End of file?
virtual bool uncompressed() const =0
Uncompressed?
orstream & operator<<(T const &t)
Stream output.
Definition: orstream.hh:102
virtual std::streambuf * rdbuf() const =0
Pointer to the stream buffer.
orstream()
Default constructor.
Definition: orstream.hh:58
std::ostream &(* manipulator)(std::ostream &)
Definition: orstream.hh:40
virtual std::ostream const & operator()() const =0
Stream access.
virtual bool compressed() const =0
Compressed?
orstream & operator=(orstream const &)
Copy assignment: Undefined.
virtual std::ostream const & stream() const =0
Stream access.
utility::io::orstream forward declarations
orstream: Output stream wrapper base class
Definition: orstream.hh:33
virtual bool gzipped() const =0
gzipped?
virtual orstream & write(char const *str, std::streamsize const count)=0
Write a string.
virtual void clear()=0
Clear the stream.
virtual bool bad() const =0
Bad?
virtual bool good() const =0
Good?
virtual ~orstream()
Destructor.
Definition: orstream.hh:49
virtual bool fail() const =0
Fail?