qTbot 0.89.ee6949a
qTbot is base back end library for your c++ Qt projects.
virtualfile.cpp
Go to the documentation of this file.
1//#
2//# Copyright (C) 2023-2024 QuasarApp.
3//# Distributed under the GPLv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8#include "virtualfile.h"
9
10namespace qTbot {
11
12
13VirtualFile::VirtualFile(const QSharedPointer<QNetworkReply> &replay): iFile(replay) {
14}
15
16const QByteArray& VirtualFile::array() const {
17 return _array;
18}
19
21 return Type::Ram;
22}
23
25
26 _array.append(replay()->readAll());
27
28}
29
34
35void VirtualFile::handleError(QNetworkReply::NetworkError error) {
37 _array.clear();
38
39}
40
41void VirtualFile::setArray(const QByteArray &newArray) {
42 _array = newArray;
43}
44
45
46}
void handleFinished() override
VirtualFile(const QSharedPointer< QNetworkReply > &replay=nullptr)
void setArray(const QByteArray &newArray)
const QByteArray & array() const
Type type() const override
type This is type of the file object.
void handleError(QNetworkReply::NetworkError error) override
void handleReadReady() override
The iFile class This is main interface for all implementations of the files.
Definition ifile.h:21
Type
The Type enum is type of the file object.
Definition ifile.h:28
@ Ram
This is memory saved file. All received bytes will be saved into QByteArray object.
Definition ifile.h:32
const QSharedPointer< QNetworkReply > & replay() const
Get the shared pointer to the associated QNetworkReply.
Definition ifile.cpp:51
virtual void handleError(QNetworkReply::NetworkError error)
Slot to handle errors in the network operation.
Definition ifile.cpp:59
int error() const
Get the error code associated with this file.
Definition ifile.cpp:40
virtual void handleFinished()
Slot to handle when the network operation is finished.
Definition ifile.cpp:122