Make dictionary map function optional for cache_t::load

This commit is contained in:
Allan Odgaard
2013-08-15 21:05:19 +02:00
parent 7a12fd1c41
commit 36c5dbba6b
3 changed files with 5 additions and 5 deletions

View File

@@ -15,8 +15,6 @@
OAK_EXTERN_C_BEGIN
static plist::dictionary_t prune_dictionary (plist::dictionary_t const& plist) { return plist; }
static void initialize (CFBundleRef generatorBundle)
{
static dispatch_once_t onceToken;
@@ -35,7 +33,7 @@ static void initialize (CFBundleRef generatorBundle)
paths.push_back(path::join(path, "Bundles"));
plist::cache_t cache;
cache.load(path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.plist"), &prune_dictionary);
cache.load(path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.plist"));
auto index = create_bundle_index(paths, cache);
bundles::set_index(index.first, index.second);

View File

@@ -23,13 +23,15 @@ static std::string read_link (std::string const& path)
return NULL_STR;
}
static plist::dictionary_t dictionary_identity_function (plist::dictionary_t const& plist) { return plist; }
namespace plist
{
int32_t const cache_t::kPropertyCacheFormatVersion = 2;
void cache_t::load (std::string const& path, plist::dictionary_t (*prune_dictionary)(plist::dictionary_t const&))
{
_prune_dictionary = prune_dictionary;
_prune_dictionary = prune_dictionary ?: dictionary_identity_function;
int32_t version;
auto plist = plist::load(path);

View File

@@ -8,7 +8,7 @@ namespace plist
{
struct PUBLIC cache_t
{
void load (std::string const& path, plist::dictionary_t (*prune_dictionary)(plist::dictionary_t const&));
void load (std::string const& path, plist::dictionary_t (*prune_dictionary)(plist::dictionary_t const&) = NULL);
void save (std::string const& path) const;
bool dirty () const { return _dirty; }