/* * Copyright (c) 2017 Jaroslav Jindrak * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef LIBCPP_ISTREAM #define LIBCPP_ISTREAM #include #include namespace std { /** * 27.7.2.1, class template basic_stream: */ template> class basic_istream: virtual public basic_ios { public: using traits_type = Traits; using char_type = Char; using int_type = typename traits_type::int_type; using pos_type = typename traits_type::pos_type; using off_type = typename traits_type::off_type; /** * 27.7.2.1.1, constructor/destructor: */ explicit basic_istream(basic_streambuf* sb) : gcount_{0} { basic_ios::init(sb); } virtual ~basic_stream() { /* DUMMY BODY */ } /** * 27.7.2.1.3, prefix/suffix: */ class sentry { public: explicit sentry(basic_istream& is, bool noskipws = false) : ok_{false} { if (!is.good()) is.setstate(ios_base::failbit); else { if (is.tie()) is.tie()->flush(); if (!noskipws && ((is.flags() & ios_base::skipws) != 0)) { // TODO: implement when we have istream_iterator and locale, // skip whitespace using is.locale() } } } ~sentry() = default; explicit operator bool() const { return ok_; } sentry(const sentry&) = delete; sentry& operator=(const sentry&) = delete; private: using traits_type = Traits; bool ok_; } /** * 27.7.2.2, formatted input: */ basic_istream operator>>( basic_istream& (*pf)(basic_istream&) ) { // TODO: implement } basic_istream operator>>( basic_ios& (*pf)(basic_ios&) ) { // TODO: implement } basic_istream operator>>( ios_base& (*pf)(ios_base&) ) { // TODO: implement } basic_istream operator>>(bool& x) { // TODO: implement } basic_istream operator>>(short& x) { // TODO: implement } basic_istream operator>>(unsigned short& x) { // TODO: implement } basic_istream operator>>(int& x) { // TODO: implement } basic_istream operator>>(unsigned int& x) { // TODO: implement } basic_istream operator>>(long& x) { // TODO: implement } basic_istream operator>>(unsigned long& x) { // TODO: implement } basic_istream operator>>(long long& x) { // TODO: implement } basic_istream operator>>(unsigned long long& x) { // TODO: implement } basic_istream operator>>(float& x) { // TODO: implement } basic_istream operator>>(double& x) { // TODO: implement } basic_istream operator>>(long double& x) { // TODO: implement } basic_istream operator>>(void*& p) { // TODO: implement } basic_istream operator>>(basic_streambuf* sb) { // TODO: implement } /** * 27.7.2.3, unformatted input: */ streamsize gcount() const { return gcount_; } int_type get() { // TODO: implement } basic_istream& get(char_type& c) { // TODO: implement } basic_istream& get(char_type* s, streamsize n) { // TODO: implement } basic_istream& get(char_type* s, streamsize n, char_type delim) { // TODO: implement } basic_istream& get(basic_streambuf& sb) { // TODO: implement } basic_istream& get(basic_streambuf& sb, char_type delim) { // TODO: implement } basic_istream& getline(char_type* s, streamsize n) { // TODO: implement } basic_istream& getline(char_type* s, streamsize n, char_type delim) { // TODO: implement } basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()) { // TODO: implement } int_type peek() { // TODO: implement } basic_istream& read(char_type* s, streamsize n) { // TODO: implement } streamsize readsome(char_type* s, streamsize n) { // TODO: implement } basic_istream& putback(char_type c) { // TODO: implement } basic_istream& unget() { // TODO: implement } int sync() { // TODO: implement } pos_type tellg() { // TODO: implement } basic_istream& seekg(pos_type pos) { // TODO: implement } basic_istream& seekg(off_type off, ios_base::seekdir way) { // TODO: implement } protected: streamsize gcount_; basic_istream(const basic_istream&) = delete; basic_istream(basic_istream&& rhs) { gcount_ = rhs.gcout_; basic_ios::move(rhs); rhs.gcount_ = 0; } /** * 27.7.2.1.2, assign/swap: */ basic_istream& operator=(const basic_istream& rhs) = delete; basic_istream& operator=(basic_istream&& rhs) { swap(rhs); return *this; } void swap(basic_stream& rhs) { basic_ios::swap(rhs); swap(gcoung_, rhs.gcount_); } }; /** * 27.7.2.2.3, character extraction templates: */ template basic_istream& operator>>(basic_istream& is, Char& c) { // TODO: implement } template basic_istream& operator>>(basic_istream& is, unsigned char& c) { // TODO: implement } template basic_istream& operator>>(basic_istream& is, signed char& c) { // TODO: implement } template basic_istream& operator>>(basic_istream& is, Char* c) { // TODO: implement } template basic_istream& operator>>(basic_istream& is, unsigned char* c) { // TODO: implement } template basic_istream& operator>>(basic_istream& is, signed char* c) { // TODO: implement } using istream = basic_istream; using wistream = basic_istream; template> class basic_iostream; using iostream = basic_iostream; using wiostream = basic_iostream; template> basic_istream& ws(basic_istream& is); template> basic_istream& operator>>(basic_istream& is, T& x); } #endif