root/win32/xsd-3.1.0-i686/libxsd/xsd/cxx/zc-istream.hxx @ 111

Revision 111, 2.0 kB (checked in by mido, 16 years ago)

pridana knihovna XSD (a jeji chlebodarkyne XERCES), v ramci Win32 zprovoznen priklad tests/test_xsd_hello.cxx

Line 
1// file      : xsd/cxx/zc-istream.hxx
2// author    : Boris Kolpackov <boris@codesynthesis.com>
3// copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC
4// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
5
6#ifndef XSD_CXX_ZC_ISTREAM_HXX
7#define XSD_CXX_ZC_ISTREAM_HXX
8
9#include <string>
10#include <istream>
11
12#include <xsd/cxx/ro-string.hxx>
13
14namespace xsd
15{
16  namespace cxx
17  {
18    // Input streambuffer that does not copy the underlying
19    // buffer (zero copy).
20    //
21    template <typename C>
22    class zc_streambuf: public std::basic_streambuf<C>
23    {
24    public:
25      typedef typename std::basic_streambuf<C>::int_type int_type;
26      typedef typename std::basic_streambuf<C>::traits_type traits_type;
27
28    public:
29      zc_streambuf (const ro_string<C>&);
30      zc_streambuf (const std::basic_string<C>&);
31
32    protected:
33      virtual std::streamsize
34      showmanyc ();
35
36      virtual int_type
37      underflow ();
38
39    private:
40      void
41      init ();
42
43    private:
44      zc_streambuf (const zc_streambuf&);
45
46      zc_streambuf&
47      operator= (const zc_streambuf&);
48
49    private:
50      ro_string<C> str_;
51    };
52
53
54    // Input string stream that does not copy the underlying string.
55    //
56    template <typename C>
57    class zc_istream_base
58    {
59    protected:
60      zc_istream_base (const ro_string<C>&);
61      zc_istream_base (const std::basic_string<C>&);
62
63    protected:
64      zc_streambuf<C> buf_;
65    };
66
67    template <typename C>
68    class zc_istream: protected zc_istream_base<C>,
69                      public std::basic_istream<C>
70    {
71    public:
72      zc_istream (const ro_string<C>&);
73      zc_istream (const std::basic_string<C>&);
74
75      bool
76      exhausted ()
77      {
78        return this->get () == std::basic_istream<C>::traits_type::eof ();
79      }
80
81    private:
82      zc_istream (const zc_istream&);
83
84      zc_istream&
85      operator= (const zc_istream&);
86    };
87  }
88}
89
90#include <xsd/cxx/zc-istream.txx>
91
92#endif  // XSD_CXX_ZC_ISTREAM_HXX
Note: See TracBrowser for help on using the browser.