1999-08-16 21:50:52 +00:00
|
|
|
/*
|
|
|
|
*****************************************************************************************
|
1999-12-13 22:28:37 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1997-1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
1999-08-16 21:50:52 +00:00
|
|
|
*****************************************************************************************
|
|
|
|
*
|
|
|
|
* File rbcache.h
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 03/20/97 aliu Creation.
|
|
|
|
* 04/29/97 aliu Convert to use new Hashtable protocol.
|
|
|
|
* 04/15/99 damiba plugged in new C hashtable
|
|
|
|
*****************************************************************************************
|
|
|
|
*/
|
|
|
|
|
2000-03-29 18:47:02 +00:00
|
|
|
#include "hash.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/unistr.h"
|
2000-03-29 18:47:02 +00:00
|
|
|
struct UHashtable;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/**
|
2000-03-29 18:47:02 +00:00
|
|
|
* A class that maps UnicodeString keys to UHashtable objects. It
|
|
|
|
* owns the UHashtable objects passed to put() and will eventually
|
|
|
|
* close and delete them.
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
2000-03-29 18:47:02 +00:00
|
|
|
class U_COMMON_API ResourceBundleCache { // Not really external; just making the compiler happy
|
|
|
|
private:
|
|
|
|
Hashtable* hash;
|
|
|
|
static void U_CALLCONV deleteUHashtable(void* value);
|
|
|
|
public:
|
|
|
|
ResourceBundleCache();
|
|
|
|
~ResourceBundleCache();
|
|
|
|
inline void put(const UnicodeString& key, UHashtable* adoptedValue);
|
|
|
|
inline const UHashtable* get(const UnicodeString& key) const;
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
2000-03-29 18:47:02 +00:00
|
|
|
inline void ResourceBundleCache::put(const UnicodeString& key, UHashtable* adoptedValue) {
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
hash->put(key, adoptedValue, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const UHashtable* ResourceBundleCache::get(const UnicodeString& key) const {
|
|
|
|
return (const UHashtable*) hash->get(key);
|
|
|
|
}
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
2000-03-29 18:47:02 +00:00
|
|
|
* A class that records whether a filename has been seen before or
|
|
|
|
* not. Call markAsVisited() to mark a filename as seen. Call
|
|
|
|
* wasVisited() to see if markAsVisited() has been called with that
|
|
|
|
* filename or not.
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
2000-03-29 18:47:02 +00:00
|
|
|
class U_COMMON_API VisitedFileCache { // Not really external; just making the compiler happy
|
|
|
|
private:
|
|
|
|
Hashtable* hash;
|
|
|
|
public:
|
|
|
|
VisitedFileCache();
|
|
|
|
~VisitedFileCache();
|
|
|
|
inline bool_t wasVisited(const UnicodeString& filename) const;
|
|
|
|
inline void markAsVisited(const UnicodeString& filename);
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
2000-03-29 18:47:02 +00:00
|
|
|
inline bool_t VisitedFileCache::wasVisited(const UnicodeString& filename) const {
|
|
|
|
return (hash->get(filename) != 0);
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-03-29 18:47:02 +00:00
|
|
|
inline void VisitedFileCache::markAsVisited(const UnicodeString& filename) {
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
hash->put(filename, (void*)1, status);
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//eof
|