[12] | 1 | /* |
---|
| 2 | * |
---|
| 3 | * Copyright (c) 2003 Dr John Maddock |
---|
| 4 | * Use, modification and distribution is subject to the |
---|
| 5 | * Boost Software License, Version 1.0. (See accompanying file |
---|
| 6 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
| 7 | * |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include <boost/shared_ptr.hpp> |
---|
| 11 | #include <boost/filesystem/path.hpp> |
---|
| 12 | |
---|
| 13 | class fileview |
---|
| 14 | { |
---|
| 15 | public: |
---|
| 16 | // types: |
---|
| 17 | typedef const char& reference; |
---|
| 18 | typedef reference const_reference; |
---|
| 19 | typedef const char* iterator; // See _lib.container.requirements_ |
---|
| 20 | typedef iterator const_iterator; // See _lib.container.requirements_ |
---|
| 21 | typedef std::size_t size_type; |
---|
| 22 | typedef std::ptrdiff_t difference_type; |
---|
| 23 | typedef char value_type; |
---|
| 24 | typedef const char* pointer; |
---|
| 25 | typedef pointer const_pointer; |
---|
| 26 | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
---|
| 27 | typedef std::reverse_iterator<iterator> reverse_iterator; |
---|
| 28 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
---|
| 29 | #endif |
---|
| 30 | |
---|
| 31 | // construct: |
---|
| 32 | fileview(); |
---|
| 33 | fileview(const boost::filesystem::path& p); |
---|
| 34 | ~fileview(); |
---|
| 35 | fileview(const fileview& that); |
---|
| 36 | fileview& operator=(const fileview& that); |
---|
| 37 | void close(); |
---|
| 38 | void open(const boost::filesystem::path& p); |
---|
| 39 | |
---|
| 40 | // iterators: |
---|
| 41 | const_iterator begin() const; |
---|
| 42 | const_iterator end() const; |
---|
| 43 | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
---|
| 44 | const_reverse_iterator rbegin() const; |
---|
| 45 | const_reverse_iterator rend() const; |
---|
| 46 | #endif |
---|
| 47 | |
---|
| 48 | // capacity: |
---|
| 49 | size_type size() const; |
---|
| 50 | size_type max_size() const; |
---|
| 51 | bool empty() const; |
---|
| 52 | |
---|
| 53 | // element access: |
---|
| 54 | const_reference operator[](size_type n) const; |
---|
| 55 | const_reference at(size_type n) const; |
---|
| 56 | const_reference front() const; |
---|
| 57 | const_reference back() const; |
---|
| 58 | void swap(fileview& that); |
---|
| 59 | |
---|
| 60 | private: |
---|
| 61 | void cow(); |
---|
| 62 | struct implementation; |
---|
| 63 | boost::shared_ptr<implementation> pimpl; |
---|
| 64 | }; |
---|
| 65 | |
---|
| 66 | |
---|