mirror of
https://review.haiku-os.org/haiku
synced 2025-02-02 19:57:42 +01:00
0d6b3b20e1
* added class BPackageInfo, which contains packaging attributes of a package (the values relevant for package management) * implemented parser (mostly) for reading a BPackageInfo from a config file (.PackageInfo) in order to pass them on to the PackageWriter when creating a package * pulled hpkg-related stuff from bin/package into the package kit * adjusted packagefs-Volume to skip .PackageInfo files when populating the mountpoint, as those files shouldn't appear as part of an activated package git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40301 a95241bf-73f2-0310-859d-f6bbb57e9c96
97 lines
1.4 KiB
C++
97 lines
1.4 KiB
C++
/*
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef STRINGS_H
|
|
#define STRINGS_H
|
|
|
|
|
|
#include <util/OpenHashTable.h>
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
namespace BHaikuPackage {
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
uint32 hash_string(const char* string);
|
|
|
|
|
|
struct CachedString {
|
|
char* string;
|
|
int32 index;
|
|
uint32 usageCount;
|
|
CachedString* next; // hash table link
|
|
|
|
CachedString()
|
|
:
|
|
string(NULL),
|
|
index(-1),
|
|
usageCount(1)
|
|
{
|
|
}
|
|
|
|
~CachedString()
|
|
{
|
|
free(string);
|
|
}
|
|
|
|
bool Init(const char* string)
|
|
{
|
|
this->string = strdup(string);
|
|
if (this->string == NULL)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
|
|
struct CachedStringHashDefinition {
|
|
typedef const char* KeyType;
|
|
typedef CachedString ValueType;
|
|
|
|
size_t HashKey(const char* key) const
|
|
{
|
|
return hash_string(key);
|
|
}
|
|
|
|
size_t Hash(const CachedString* value) const
|
|
{
|
|
return HashKey(value->string);
|
|
}
|
|
|
|
bool Compare(const char* key, const CachedString* value) const
|
|
{
|
|
return strcmp(value->string, key) == 0;
|
|
}
|
|
|
|
CachedString*& GetLink(CachedString* value) const
|
|
{
|
|
return value->next;
|
|
}
|
|
};
|
|
|
|
|
|
typedef BOpenHashTable<CachedStringHashDefinition> CachedStringTable;
|
|
|
|
|
|
struct CachedStringUsageGreater {
|
|
bool operator()(const CachedString* a, const CachedString* b)
|
|
{
|
|
return a->usageCount > b->usageCount;
|
|
}
|
|
};
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
} // namespace BHaikuPackage
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // STRINGS_H
|