Repository file format: group attributes of a package
* Introduce new package attribute B_HPKG_ATTRIBUTE_ID_PACKAGE (valid
only in a repository file) to group the attributes belonging to a
package.
* BRepositoryContentHandler:
- No longer derive from BPackageContentHandler.
- Add hooks HandlePackage() and HandlePackageDone() that bracket the
attributes for a package. This is more explicit and robust than
handlers having to guess when one package ended and the next began.
* BRepositoryCache: Make use of BPackageInfoContentHandler. No need to
duplicate the code for reading a package info from package info
attributes.
This commit is contained in:
@@ -81,3 +81,4 @@ B_DEFINE_HPKG_ATTRIBUTE(52, STRING, "package:post-install-script",
|
||||
PACKAGE_POST_INSTALL_SCRIPT)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(53, UINT, "package:is-writable-directory",
|
||||
PACKAGE_IS_WRITABLE_DIRECTORY)
|
||||
B_DEFINE_HPKG_ATTRIBUTE(54, STRING, "package", PACKAGE)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <package/hpkg/PackageContentHandler.h>
|
||||
#include <package/hpkg/HPKGDefs.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
@@ -20,10 +20,24 @@ class BRepositoryInfo;
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BRepositoryContentHandler : public BPackageContentHandler {
|
||||
class BPackageInfoAttributeValue;
|
||||
|
||||
|
||||
class BRepositoryContentHandler {
|
||||
public:
|
||||
virtual ~BRepositoryContentHandler();
|
||||
|
||||
virtual status_t HandleRepositoryInfo(
|
||||
const BRepositoryInfo& info) = 0;
|
||||
|
||||
virtual status_t HandlePackage(const char* packageName) = 0;
|
||||
virtual status_t HandlePackageAttribute(
|
||||
const BPackageInfoAttributeValue& value)
|
||||
= 0;
|
||||
virtual status_t HandlePackageDone(const char* packageName) = 0;
|
||||
|
||||
virtual void HandleErrorOccurred() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
BRepositoryContentHandler* contentHandler);
|
||||
|
||||
private:
|
||||
struct RootAttributeHandler;
|
||||
class PackagesAttributeHandler;
|
||||
class PackageContentHandlerAdapter;
|
||||
|
||||
private:
|
||||
BRepositoryInfo fRepositoryInfo;
|
||||
|
||||
@@ -117,6 +117,10 @@ protected:
|
||||
BPackageResolvableExpression>& list,
|
||||
uint8 id);
|
||||
|
||||
PackageAttribute* AddStringAttribute(BHPKGAttributeID id,
|
||||
const BString& value,
|
||||
DoublyLinkedList<PackageAttribute>& list);
|
||||
|
||||
int32 WriteCachedStrings(const StringCache& cache,
|
||||
uint32 minUsageCount);
|
||||
|
||||
@@ -163,9 +167,6 @@ private:
|
||||
= B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_MAJOR;
|
||||
|
||||
private:
|
||||
PackageAttribute* _AddStringAttribute(BHPKGAttributeID id,
|
||||
const BString& value,
|
||||
DoublyLinkedList<PackageAttribute>& list);
|
||||
inline PackageAttribute* _AddStringAttributeIfNotEmpty(
|
||||
BHPKGAttributeID id, const BString& value,
|
||||
DoublyLinkedList<PackageAttribute>& list);
|
||||
@@ -267,7 +268,7 @@ WriterImplBase::_AddStringAttributeIfNotEmpty(BHPKGAttributeID id,
|
||||
{
|
||||
if (value.IsEmpty())
|
||||
return NULL;
|
||||
return _AddStringAttribute(id, value, list);
|
||||
return AddStringAttribute(id, value, list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user