AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AByteBufferInputStream.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13#include "IInputStream.h"
14#include "AUI/Common/AByteBuffer.h"
15#include "AUI/Common/SharedPtr.h"
16
17
22class API_AUI_CORE AByteBufferInputStream final: public IInputStream
23{
24private:
25 const char* mCurrent;
26 const char* mEnd;
27
28
29public:
30 AByteBufferInputStream(AByteBufferView buffer)
31 : mCurrent(buffer.data()), mEnd(buffer.data() + buffer.size())
32 {
33 }
34
35 size_t read(char* dst, size_t size) override;
36
37 size_t available() const {
38 return mEnd - mCurrent;
39 }
40};
Acts like std::string_view but for AByteBuffer.
Definition AByteBufferView.h:24
Represents an input stream.
Definition IInputStream.h:26
virtual size_t read(char *dst, size_t size)=0
Reads up to size bytes from stream. Blocking (waiting for new data) is allowed.