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 12 class BEntry; 13 14 15 namespace BPackageKit { 16 17 18 class BPackageInfo; 19 class BRepositoryInfo; 20 21 22 namespace BHPKG { 23 24 25 namespace BPrivate { 26 class RepositoryWriterImpl; 27 } 28 using BPrivate::RepositoryWriterImpl; 29 30 31 class BRepositoryWriterListener : public BErrorOutput { 32 public: 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 53 class BRepositoryWriter { 54 public: 55 public: 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 66 private: 67 RepositoryWriterImpl* fImpl; 68 }; 69 70 71 } // namespace BHPKG 72 73 } // namespace BPackageKit 74 75 76 #endif // _PACKAGE__HPKG__REPOSITORY_WRITER_H_ 77