2009-11-13 16:45:49 +03:00
|
|
|
/*
|
2011-01-30 18:15:33 +03:00
|
|
|
* Copyright 2009,2011, Haiku, Inc.
|
2009-11-13 16:45:49 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 18:05:38 +03:00
|
|
|
#ifndef _PACKAGE__HPKG__DATA_READER_H_
|
|
|
|
#define _PACKAGE__HPKG__DATA_READER_H_
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
2014-02-10 21:21:50 +04:00
|
|
|
class BDataIO;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
|
2014-02-10 21:21:50 +04:00
|
|
|
namespace BPackageKit {
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2014-02-10 21:21:50 +04:00
|
|
|
namespace BHPKG {
|
2013-05-13 04:52:10 +04:00
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BDataReader {
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
virtual ~BDataReader();
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-13 04:52:10 +04:00
|
|
|
class BAbstractBufferedDataReader : public BDataReader {
|
|
|
|
public:
|
|
|
|
virtual ~BAbstractBufferedDataReader();
|
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
virtual status_t ReadDataToOutput(off_t offset, size_t size,
|
2014-02-10 21:21:50 +04:00
|
|
|
BDataIO* output) = 0;
|
2013-05-13 04:52:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BFDDataReader : public BDataReader {
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
BFDDataReader(int fd);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
2013-05-18 05:55:39 +04:00
|
|
|
void SetFD(int fd);
|
|
|
|
|
2009-11-13 16:45:49 +03:00
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fFD;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BAttributeDataReader : public BDataReader {
|
2009-11-15 11:39:45 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
BAttributeDataReader(int fd,
|
2009-11-15 11:39:45 +03:00
|
|
|
const char* attribute, uint32 type);
|
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fFD;
|
|
|
|
uint32 fType;
|
|
|
|
const char* fAttribute;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-18 05:55:39 +04:00
|
|
|
class BBufferDataReader : public BAbstractBufferedDataReader {
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2011-01-30 18:05:38 +03:00
|
|
|
BBufferDataReader(const void* data, size_t size);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
2013-05-18 05:55:39 +04:00
|
|
|
virtual status_t ReadDataToOutput(off_t offset, size_t size,
|
2014-02-10 21:21:50 +04:00
|
|
|
BDataIO* output);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
const void* fData;
|
|
|
|
size_t fSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
} // namespace BHPKG
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
#endif // _PACKAGE__HPKG__DATA_READER_H_
|