Main Page   Reference Manual   Namespace List   Compound List   Namespace Members   Compound Members   File Members  

private_bufferstream.h
Go to the documentation of this file.
1 // $Header$
2 //
3 // Copyright (C) 2003 - 2004, by
4 //
5 // Carlo Wood, Run on IRC <carlo@alinoe.com>
6 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
7 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
8 //
9 // This file may be distributed under the terms of the Q Public License
10 // version 1.0 as appearing in the file LICENSE.QPL included in the
11 // packaging of this file.
12 //
13 
18 #ifndef LIBCWD_PRIVATE_BUFFERSTREAM_H
19 #define LIBCWD_PRIVATE_BUFFERSTREAM_H
20 
21 #ifndef LIBCWD_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 namespace libcwd {
26  namespace _private_ {
27 
28  // This is a pseudo stringstream with auto_internal_allocator
29  // that allows to change the stringbuf on the fly.
30  class bufferstream_ct : public std::ostream
31  {
32  public:
33  typedef char char_type;
34  typedef std::char_traits<char> traits_type;
35 #if CWDEBUG_ALLOC
36  typedef auto_internal_allocator allocator_type;
37 #else
38  typedef ::std::allocator<char_type> allocator_type;
39 #endif
40  typedef traits_type::int_type int_type;
41  typedef traits_type::pos_type pos_type;
42  typedef traits_type::off_type off_type;
43  typedef std::basic_string<char_type, traits_type, allocator_type> string_type;
44  typedef std::basic_stringbuf<char_type, traits_type, allocator_type> stringbuf_type;
45 
46  public:
47  stringbuf_type* M_stringbuf;
48 
49  public:
50  explicit
51  bufferstream_ct(stringbuf_type* sb) : std::basic_ostream<char, std::char_traits<char> >(sb), M_stringbuf(sb) { }
52  ~bufferstream_ct() { }
53 
54  stringbuf_type* rdbuf() const { return M_stringbuf; }
55  string_type str() const { return M_stringbuf->str(); }
56  void str(string_type const& s) { M_stringbuf->str(s); }
57  };
58 
59  } // namespace _private_
60 } // namespace libcwd
61 
62 #endif // LIBCWD_PRIVATE_BUFFERSTREAM_H
namespace for libcwd.
Definition: debug.cc:87
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.