154aa6d63Sopenharmony_ci/*
254aa6d63Sopenharmony_ci * Copyright (c) 2024-2024 Huawei Device Co., Ltd.
354aa6d63Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
454aa6d63Sopenharmony_ci * you may not use this file except in compliance with the License.
554aa6d63Sopenharmony_ci * You may obtain a copy of the License at
654aa6d63Sopenharmony_ci *
754aa6d63Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
854aa6d63Sopenharmony_ci *
954aa6d63Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1054aa6d63Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1154aa6d63Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1254aa6d63Sopenharmony_ci * See the License for the specific language governing permissions and
1354aa6d63Sopenharmony_ci * limitations under the License.
1454aa6d63Sopenharmony_ci */
1554aa6d63Sopenharmony_ci
1654aa6d63Sopenharmony_ci#ifndef SIGNATRUETOOLS_ZIP_DATA_INPUT_H
1754aa6d63Sopenharmony_ci#define SIGNATRUETOOLS_ZIP_DATA_INPUT_H
1854aa6d63Sopenharmony_ci
1954aa6d63Sopenharmony_ci#include <memory>
2054aa6d63Sopenharmony_ci
2154aa6d63Sopenharmony_ci#include "byte_buffer.h"
2254aa6d63Sopenharmony_ci#include "data_source.h"
2354aa6d63Sopenharmony_ci#include "random_access_file_output.h"
2454aa6d63Sopenharmony_ci
2554aa6d63Sopenharmony_cinamespace OHOS {
2654aa6d63Sopenharmony_cinamespace SignatureTools {
2754aa6d63Sopenharmony_ci
2854aa6d63Sopenharmony_ciclass ZipDataInput {
2954aa6d63Sopenharmony_cipublic:
3054aa6d63Sopenharmony_ci    virtual ~ZipDataInput()
3154aa6d63Sopenharmony_ci    {
3254aa6d63Sopenharmony_ci    }
3354aa6d63Sopenharmony_ci
3454aa6d63Sopenharmony_ci    /**
3554aa6d63Sopenharmony_ci     * Get how many bytes are contained in this data input.
3654aa6d63Sopenharmony_ci     *
3754aa6d63Sopenharmony_ci     * @return this data input size
3854aa6d63Sopenharmony_ci     */
3954aa6d63Sopenharmony_ci    virtual int64_t Size() = 0;
4054aa6d63Sopenharmony_ci
4154aa6d63Sopenharmony_ci    /**
4254aa6d63Sopenharmony_ci     * Copy the specified data block into the destination ZipDataOutput
4354aa6d63Sopenharmony_ci     *
4454aa6d63Sopenharmony_ci     * @param offset offset index at the ZipDataInput
4554aa6d63Sopenharmony_ci     * @param size size of the data block
4654aa6d63Sopenharmony_ci     * @param buffer the destination ZipDataOutput
4754aa6d63Sopenharmony_ci     * @throws IOException when IO error occurred
4854aa6d63Sopenharmony_ci     */
4954aa6d63Sopenharmony_ci    virtual bool CopyTo(int64_t offset, int size, ByteBuffer& buffer) = 0;
5054aa6d63Sopenharmony_ci
5154aa6d63Sopenharmony_ci    /**
5254aa6d63Sopenharmony_ci     * Create a ByteBuffer which contain the specified data block from this ZipDataInput
5354aa6d63Sopenharmony_ci     *
5454aa6d63Sopenharmony_ci     * @param offset offset index at the ZipDataInput
5554aa6d63Sopenharmony_ci     * @param size size of the data block
5654aa6d63Sopenharmony_ci     * @return a ByteBuffer
5754aa6d63Sopenharmony_ci     * @throws IOException when IO error occurred
5854aa6d63Sopenharmony_ci     */
5954aa6d63Sopenharmony_ci    virtual ByteBuffer CreateByteBuffer(int64_t offset, int size) = 0;
6054aa6d63Sopenharmony_ci
6154aa6d63Sopenharmony_ci    /**
6254aa6d63Sopenharmony_ci     * Create a new DataSource whose content is shared by this DataSource
6354aa6d63Sopenharmony_ci     *
6454aa6d63Sopenharmony_ci     * @param offset offset index at the DataSource
6554aa6d63Sopenharmony_ci     * @param size size of the data block
6654aa6d63Sopenharmony_ci     * @return new DataSource
6754aa6d63Sopenharmony_ci     */
6854aa6d63Sopenharmony_ci    virtual DataSource* Slice(int64_t offset, int64_t size) = 0;
6954aa6d63Sopenharmony_ci};
7054aa6d63Sopenharmony_ci} // namespace SignatureTools
7154aa6d63Sopenharmony_ci} // namespace OHOS
7254aa6d63Sopenharmony_ci#endif // SIGNATRUETOOLS_ZIP_DATA_INPUT_H