scuffed-code/icu4c/source/common/rbcache.h

82 lines
2.7 KiB
C
Raw Normal View History

1999-08-16 21:50:52 +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
*****************************************************************************************
*/
#include "hash.h"
#include "unicode/unistr.h"
/* Disable these warnings:
d:\icu\source\common\rbcache.h(31) : warning C4251: 'hash' : class 'Hashtable' needs to have dll-interface to be used by clients of class 'ResourceBundleCache'
d:\icu\source\common\rbcache.h(57) : warning C4251: 'hash' : class 'Hashtable' needs to have dll-interface to be used by clients of class 'VisitedFileCache'
*/
#ifdef _WIN32
#pragma warning( disable : 4251 )
#endif
1999-08-16 21:50:52 +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
*/
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();
inline ~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
};
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
/**
* 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
*/
class U_COMMON_API VisitedFileCache { // Not really external; just making the compiler happy
private:
Hashtable hash;
public:
inline VisitedFileCache() {}
inline ~VisitedFileCache() {}
inline bool_t wasVisited(const UnicodeString& filename) const;
inline void markAsVisited(const UnicodeString& filename);
1999-08-16 21:50:52 +00:00
};
inline bool_t VisitedFileCache::wasVisited(const UnicodeString& filename) const {
return (hash.get(filename) != 0);
1999-08-16 21:50:52 +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