2009-11-13 13:45:49 +00:00
|
|
|
/*
|
2014-06-23 14:37:34 +02:00
|
|
|
* Copyright 2009-2014, Haiku, Inc.
|
2009-11-13 13:45:49 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 15:05:38 +00:00
|
|
|
#ifndef _PACKAGE__HPKG__DATA_READER_H_
|
|
|
|
#define _PACKAGE__HPKG__DATA_READER_H_
|
2009-11-13 13:45:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
2014-06-23 14:37:34 +02:00
|
|
|
class BDataIO;
|
2011-01-27 23:17:03 +00:00
|
|
|
|
2013-05-13 02:52:10 +02:00
|
|
|
|
2014-06-23 14:37:34 +02:00
|
|
|
namespace BPackageKit {
|
2013-05-13 02:52:10 +02:00
|
|
|
|
2014-06-23 14:37:34 +02:00
|
|
|
namespace BHPKG {
|
2014-06-18 21:42:40 +02:00
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
class BDataReader {
|
2009-11-13 13:45:49 +00:00
|
|
|
public:
|
2011-01-30 15:05:38 +00:00
|
|
|
virtual ~BDataReader();
|
2009-11-13 13:45:49 +00:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-13 02:52:10 +02: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-06-23 14:37:34 +02:00
|
|
|
BDataIO* output) = 0;
|
2013-05-13 02:52:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
class BFDDataReader : public BDataReader {
|
2009-11-13 13:45:49 +00:00
|
|
|
public:
|
2011-01-30 15:05:38 +00:00
|
|
|
BFDDataReader(int fd);
|
2009-11-13 13:45:49 +00:00
|
|
|
|
2013-05-18 03:55:39 +02:00
|
|
|
void SetFD(int fd);
|
|
|
|
|
2009-11-13 13:45:49 +00:00
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int fFD;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
class BAttributeDataReader : public BDataReader {
|
2009-11-15 08:39:45 +00:00
|
|
|
public:
|
2011-01-30 15:05:38 +00:00
|
|
|
BAttributeDataReader(int fd,
|
2009-11-15 08:39:45 +00: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 03:55:39 +02:00
|
|
|
class BBufferDataReader : public BAbstractBufferedDataReader {
|
2009-11-13 13:45:49 +00:00
|
|
|
public:
|
2011-01-30 15:05:38 +00:00
|
|
|
BBufferDataReader(const void* data, size_t size);
|
2009-11-13 13:45:49 +00:00
|
|
|
|
|
|
|
virtual status_t ReadData(off_t offset, void* buffer,
|
|
|
|
size_t size);
|
2013-05-18 03:55:39 +02:00
|
|
|
virtual status_t ReadDataToOutput(off_t offset, size_t size,
|
2014-06-23 14:37:34 +02:00
|
|
|
BDataIO* output);
|
2009-11-13 13:45:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const void* fData;
|
|
|
|
size_t fSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
} // namespace BHPKG
|
2011-01-27 23:17:03 +00:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 15:05:38 +00:00
|
|
|
#endif // _PACKAGE__HPKG__DATA_READER_H_
|