Revision 111, 1.9 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
|
Rev | Line | |
---|
[111] | 1 | // file : xsd/cxx/zc-istream.txx |
---|
| 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 | namespace xsd |
---|
| 7 | { |
---|
| 8 | namespace cxx |
---|
| 9 | { |
---|
| 10 | // zc_streambuf |
---|
| 11 | // |
---|
| 12 | template <typename C> |
---|
| 13 | zc_streambuf<C>:: |
---|
| 14 | zc_streambuf (const ro_string<C>& str) |
---|
| 15 | : str_ (str.data (), str.size ()) |
---|
| 16 | { |
---|
| 17 | init (); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | template <typename C> |
---|
| 21 | zc_streambuf<C>:: |
---|
| 22 | zc_streambuf (const std::basic_string<C>& str) |
---|
| 23 | : str_ (str) |
---|
| 24 | { |
---|
| 25 | init (); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | template <typename C> |
---|
| 29 | void zc_streambuf<C>:: |
---|
| 30 | init () |
---|
| 31 | { |
---|
| 32 | C* b (const_cast<C*> (str_.data ())); |
---|
| 33 | C* e (b + str_.size ()); |
---|
| 34 | |
---|
| 35 | setg (b, b, e); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | template <typename C> |
---|
| 39 | std::streamsize zc_streambuf<C>:: |
---|
| 40 | showmanyc () |
---|
| 41 | { |
---|
| 42 | return static_cast<std::streamsize> ( |
---|
| 43 | this->egptr () - this->gptr ()); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | template <typename C> |
---|
| 47 | typename zc_streambuf<C>::int_type zc_streambuf<C>:: |
---|
| 48 | underflow () |
---|
| 49 | { |
---|
| 50 | int_type r = traits_type::eof (); |
---|
| 51 | |
---|
| 52 | if (this->gptr () < this->egptr ()) |
---|
| 53 | r = traits_type::to_int_type (*this->gptr ()); |
---|
| 54 | |
---|
| 55 | return r; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | // zc_istream_base |
---|
| 60 | // |
---|
| 61 | template <typename C> |
---|
| 62 | zc_istream_base<C>:: |
---|
| 63 | zc_istream_base (const ro_string<C>& str) |
---|
| 64 | : buf_ (str) |
---|
| 65 | { |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | template <typename C> |
---|
| 69 | zc_istream_base<C>:: |
---|
| 70 | zc_istream_base (const std::basic_string<C>& str) |
---|
| 71 | : buf_ (str) |
---|
| 72 | { |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | // zc_istream |
---|
| 77 | // |
---|
| 78 | template <typename C> |
---|
| 79 | zc_istream<C>:: |
---|
| 80 | zc_istream (const ro_string<C>& str) |
---|
| 81 | : zc_istream_base<C> (str), |
---|
| 82 | std::basic_istream<C> (&this->buf_) |
---|
| 83 | { |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | template <typename C> |
---|
| 87 | zc_istream<C>:: |
---|
| 88 | zc_istream (const std::basic_string<C>& str) |
---|
| 89 | : zc_istream_base<C> (str), |
---|
| 90 | std::basic_istream<C> (&this->buf_) |
---|
| 91 | { |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | } |
---|