Changeset a9caea1 in mainline


Ignore:
Timestamp:
2018-07-05T21:41:18Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a3067af
Parents:
51a3eef
git-author:
Jaroslav Jindrak <dzejrou@…> (2017-11-05 21:07:14)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:18)
Message:

cpp: added some basic implementations to std::basic_istream, but for more locale and numeric_limits is needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/istream.hpp

    r51a3eef ra9caea1  
    3131
    3232#include <iosfwd>
     33#include <utility>
    3334
    3435namespace std
     
    5455
    5556            explicit basic_istream(basic_streambuf<Char, Traits>* sb)
    56             {
    57                 // TODO: implement
     57                : gcount_{0}
     58            {
     59                basic_ios::init(sb);
    5860            }
    5961
    6062            virtual ~basic_stream()
    61             {
    62                 // TODO: implement
    63             }
     63            { /* DUMMY BODY */ }
    6464
    6565            /**
     
    6767             */
    6868
    69             class sentry;
     69            class sentry
     70            {
     71                public:
     72                    explicit sentry(basic_istream<Char, Traits>& is, bool noskipws = false)
     73                        : ok_{false}
     74                    {
     75                        if (!is.good())
     76                            is.setstate(ios_base::failbit);
     77                        else
     78                        {
     79                            if (is.tie())
     80                                is.tie()->flush();
     81
     82                            if (!noskipws && ((is.flags() & ios_base::skipws) != 0))
     83                            {
     84                                // TODO: implement when we have istream_iterator and locale,
     85                                //       skip whitespace using is.locale()
     86                            }
     87                        }
     88                    }
     89
     90                    ~sentry() = default;
     91
     92                    explicit operator bool() const
     93                    {
     94                        return ok_;
     95                    }
     96
     97                    sentry(const sentry&) = delete;
     98                    sentry& operator=(const sentry&) = delete;
     99
     100                private:
     101                    using traits_type = Traits;
     102                    bool ok_;
     103            }
    70104
    71105            /**
     
    170204            streamsize gcount() const
    171205            {
    172                 // TODO: implement
     206                return gcount_;
    173207            }
    174208
     
    264298
    265299        protected:
     300            streamsize gcount_;
     301
    266302            basic_istream(const basic_istream&) = delete;
    267303
    268304            basic_istream(basic_istream&& rhs)
    269305            {
    270                 // TODO: implement
     306                gcount_ = rhs.gcout_;
     307
     308                basic_ios::move(rhs);
     309
     310                rhs.gcount_ = 0;
    271311            }
    272312
     
    279319            basic_istream& operator=(basic_istream&& rhs)
    280320            {
    281                 // TODO: implement
     321                swap(rhs);
     322
     323                return *this;
    282324            }
    283325
    284326            void swap(basic_stream& rhs)
    285327            {
    286                 // TODO: implement
     328                basic_ios::swap(rhs);
     329                swap(gcoung_, rhs.gcount_);
    287330            }
    288331    };
Note: See TracChangeset for help on using the changeset viewer.