| 642 | using binary_stream_source = stream_source<uint8_t>; |
| 643 | |
| 644 | class bytes_source |
| 645 | { |
| 646 | public: |
| 647 | typedef uint8_t value_type; |
| 648 | private: |
| 649 | const value_type* data_{nullptr}; |
| 650 | const value_type* current_{nullptr}; |
| 651 | const value_type* end_{nullptr}; |
| 652 | public: |
| 653 | bytes_source() noexcept = default; |
| 654 | |
| 655 | // Noncopyable |
| 656 | bytes_source(const bytes_source&) = delete; |
| 657 | |
| 658 | bytes_source(bytes_source&&) = default; |
| 659 | |
| 660 | template <typename Sourceable> |
| 661 | bytes_source(const Sourceable& source, |
| 662 | typename std::enable_if<ext_traits::is_bytes_view_like<Sourceable>::value,int>::type = 0) |
| 663 | : data_(reinterpret_cast<const value_type*>(source.data())), |
| 664 | current_(data_), |
| 665 | end_(data_+source.size()) |
| 666 | { |
| 667 | } |
| 668 | |
| 669 | bytes_source& operator=(const bytes_source&) = delete; |
| 670 | bytes_source& operator=(bytes_source&&) = default; |
| 671 | |
| 672 | bool eof() const |
| 673 | { |
| 674 | return current_ == end_; |
| 675 | } |
| 676 | |
| 677 | bool is_error() const |
| 678 | { |
| 679 | return false; |
| 680 | } |
| 681 | |
| 682 | std::size_t position() const |
| 683 | { |
| 684 | return current_ - data_; |
| 685 | } |
| 686 | |
| 687 | void ignore(std::size_t count) |
| 688 | { |
| 689 | std::size_t len; |
| 690 | if (std::size_t(end_ - current_) < count) |
| 691 | { |
| 692 | len = end_ - current_; |
| 693 | } |
| 694 | else |
| 695 | { |
| 696 | len = count; |
| 697 | } |
| 698 | current_ += len; |
| 699 | } |
| 700 | |
| 701 | char_result<value_type> peek() |
no outgoing calls
no test coverage detected