1/*
2 * Copyright 2011, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _PACKAGE__HPKG__REPOSITORY_WRITER_H_
6#define _PACKAGE__HPKG__REPOSITORY_WRITER_H_
7
8
9#include <package/hpkg/ErrorOutput.h>
10
11
12class BEntry;
13
14
15namespace BPackageKit {
16
17
18class BPackageInfo;
19class BRepositoryInfo;
20
21
22namespace BHPKG {
23
24
25namespace BPrivate {
26	class RepositoryWriterImpl;
27}
28using BPrivate::RepositoryWriterImpl;
29
30
31class BRepositoryWriterListener : public BErrorOutput {
32public:
33	virtual	void				PrintErrorVarArgs(const char* format,
34									va_list args) = 0;
35
36	virtual	void				OnPackageAdded(
37									const BPackageInfo& packageInfo) = 0;
38
39	virtual void				OnRepositoryInfoSectionDone(
40									uint32 uncompressedSize) = 0;
41	virtual void				OnPackageAttributesSectionDone(
42									uint32 stringCount,
43									uint32 uncompressedSize) = 0;
44	virtual void				OnRepositoryDone(uint32 headerSize,
45									uint32 repositoryInfoLength,
46									uint32 licenseCount,
47									uint32 packageCount,
48									uint32 packageAttributesSize,
49									uint64 totalSize) = 0;
50};
51
52
53class BRepositoryWriter {
54public:
55public:
56								BRepositoryWriter(
57									BRepositoryWriterListener* listener,
58									BRepositoryInfo* repositoryInfo);
59								~BRepositoryWriter();
60
61			status_t			Init(const char* fileName);
62			status_t			AddPackage(const BEntry& packageEntry);
63			status_t			AddPackageInfo(const BPackageInfo& packageInfo);
64			status_t			Finish();
65
66private:
67			RepositoryWriterImpl*	fImpl;
68};
69
70
71}	// namespace BHPKG
72
73}	// namespace BPackageKit
74
75
76#endif	// _PACKAGE__HPKG__REPOSITORY_WRITER_H_
77