summaryrefslogtreecommitdiff
path: root/libxsd/libxsd/cxx/zc-istream.txx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-12-18 18:48:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-01-13 22:32:43 +0300
commit2615896faa646e5830abf2c269150e1165c66515 (patch)
tree7d95978ec0a83094c9462ed4e1f59d42f4ff8ddb /libxsd/libxsd/cxx/zc-istream.txx
parent7420f85ea19b0562ffdd8123442f32bc8bac1267 (diff)
Switch to build2
Diffstat (limited to 'libxsd/libxsd/cxx/zc-istream.txx')
-rw-r--r--libxsd/libxsd/cxx/zc-istream.txx92
1 files changed, 92 insertions, 0 deletions
diff --git a/libxsd/libxsd/cxx/zc-istream.txx b/libxsd/libxsd/cxx/zc-istream.txx
new file mode 100644
index 0000000..aebb974
--- /dev/null
+++ b/libxsd/libxsd/cxx/zc-istream.txx
@@ -0,0 +1,92 @@
+// file : libxsd/cxx/zc-istream.txx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsd
+{
+ namespace cxx
+ {
+ // zc_streambuf
+ //
+ template <typename C>
+ zc_streambuf<C>::
+ zc_streambuf (const ro_string<C>& str)
+ : str_ (str.data (), str.size ())
+ {
+ init ();
+ }
+
+ template <typename C>
+ zc_streambuf<C>::
+ zc_streambuf (const std::basic_string<C>& str)
+ : str_ (str)
+ {
+ init ();
+ }
+
+ template <typename C>
+ void zc_streambuf<C>::
+ init ()
+ {
+ C* b (const_cast<C*> (str_.data ()));
+ C* e (b + str_.size ());
+
+ this->setg (b, b, e);
+ }
+
+ template <typename C>
+ std::streamsize zc_streambuf<C>::
+ showmanyc ()
+ {
+ return static_cast<std::streamsize> (
+ this->egptr () - this->gptr ());
+ }
+
+ template <typename C>
+ typename zc_streambuf<C>::int_type zc_streambuf<C>::
+ underflow ()
+ {
+ int_type r = traits_type::eof ();
+
+ if (this->gptr () < this->egptr ())
+ r = traits_type::to_int_type (*this->gptr ());
+
+ return r;
+ }
+
+
+ // zc_istream_base
+ //
+ template <typename C>
+ zc_istream_base<C>::
+ zc_istream_base (const ro_string<C>& str)
+ : buf_ (str)
+ {
+ }
+
+ template <typename C>
+ zc_istream_base<C>::
+ zc_istream_base (const std::basic_string<C>& str)
+ : buf_ (str)
+ {
+ }
+
+
+ // zc_istream
+ //
+ template <typename C>
+ zc_istream<C>::
+ zc_istream (const ro_string<C>& str)
+ : zc_istream_base<C> (str),
+ std::basic_istream<C> (&this->buf_)
+ {
+ }
+
+ template <typename C>
+ zc_istream<C>::
+ zc_istream (const std::basic_string<C>& str)
+ : zc_istream_base<C> (str),
+ std::basic_istream<C> (&this->buf_)
+ {
+ }
+ }
+}