1999-08-16 21:50:52 +00:00
|
|
|
|
/*
|
1999-11-22 21:47:27 +00:00
|
|
|
|
* Copyright <EFBFBD> {1997-1999}, International Business Machines Corporation and others. All Rights Reserved.
|
1999-08-16 21:50:52 +00:00
|
|
|
|
*****************************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
//===============================================================================
|
|
|
|
|
//
|
|
|
|
|
// File tcoldata.h
|
|
|
|
|
//
|
|
|
|
|
// Internal file. Defines TableCollationData, an internal class which is shared
|
|
|
|
|
// by TableCollation objects, and which contains all the invariant (and large)
|
|
|
|
|
// pieces of data. Once created, TableCollationData objects do not change.
|
|
|
|
|
//
|
|
|
|
|
// Created by: Alan Liu
|
|
|
|
|
//
|
|
|
|
|
// Modification History:
|
|
|
|
|
//
|
|
|
|
|
// Date Name Description
|
|
|
|
|
// 2/5/97 aliu Creation.
|
|
|
|
|
// 3/5/97 aliu Don't stream rule table in or out. Added data members
|
|
|
|
|
// isRuleTableLoaded, desiredLocale, and realLocaleName,
|
|
|
|
|
// which are required for dynamic reloading of the rule
|
|
|
|
|
// string. We still keep rules in this object so that
|
|
|
|
|
// they can be held in the in-memory cache.
|
|
|
|
|
// 3/26/97 helena Updated with platform independent data types.
|
|
|
|
|
// 6/20/97 helena Java class name change.
|
|
|
|
|
// 8/18/97 helena Added internal API documentation.
|
|
|
|
|
//===============================================================================
|
|
|
|
|
|
|
|
|
|
#ifndef TCOLDATA_H
|
|
|
|
|
#define TCOLDATA_H
|
|
|
|
|
|
2000-12-14 01:11:11 +00:00
|
|
|
|
#include "ucolimp.h"
|
2000-11-29 00:16:15 +00:00
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
|
#include "ucmp32.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
|
#include "unicode/utypes.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
#include "colcache.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
|
#include "unicode/unistr.h"
|
|
|
|
|
#include "unicode/locid.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
#include "filestrm.h"
|
2000-05-22 19:49:10 +00:00
|
|
|
|
#include "umemstrm.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
|
|
class VectorOfPToContractTable;
|
|
|
|
|
class VectorOfPToExpandTable;
|
2000-01-18 19:57:46 +00:00
|
|
|
|
class RuleBasedCollator;
|
|
|
|
|
class CollationElementIterator;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
2000-11-07 00:00:17 +00:00
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TableCollationData is an internal class used by TableCollation. It
|
|
|
|
|
* encapsulates most of the data associated with a TableCollation.
|
|
|
|
|
* This includes the large collation tables, including the contract
|
|
|
|
|
* order and expand order tables, and some small pieces of data that
|
|
|
|
|
* don't change, such as the maximum secondary order. The general
|
|
|
|
|
* idea is that the TableCollation object should be a lightweight
|
|
|
|
|
* object. If there are two TableCollation objects, they will each be
|
|
|
|
|
* very small, and users can alter the strength of each object
|
|
|
|
|
* independently. However, both objects, if they are refering to the
|
|
|
|
|
* same underlying collation, will share pointers to the same
|
|
|
|
|
* TableCollationData object, which doesn't change. <P>
|
|
|
|
|
* TableCollationData objects are therefore good candidates for
|
|
|
|
|
* caching in memory and potentially for reference counting. */
|
|
|
|
|
class TableCollationData
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TableCollationData();
|
|
|
|
|
virtual ~TableCollationData();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cache interface. The cache uses UnicodeString objects as keys. These
|
|
|
|
|
* are completely arbitrary, but are usually something uniquely associated
|
|
|
|
|
* with each collation, while at the same time fairly small, such as a
|
|
|
|
|
* locale identifier string.
|
|
|
|
|
* <P> Adds the collation data object to the cache list.
|
|
|
|
|
* @param key the unique key of the associated collation data object.
|
|
|
|
|
* @param data the collation data object.
|
|
|
|
|
*/
|
|
|
|
|
static void addToCache(const UnicodeString& key, TableCollationData* data);
|
|
|
|
|
/**
|
|
|
|
|
* Finds and returns the cached collation data.
|
|
|
|
|
* @param key the unique key of the associated collation data object.
|
|
|
|
|
* @returns the found collation data object.
|
|
|
|
|
*/
|
|
|
|
|
static TableCollationData* findInCache(const UnicodeString& key);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The streamIn and streamOut methods read and write objects of this
|
|
|
|
|
* class as binary, platform-dependent data in the iostream. The stream
|
|
|
|
|
* must be in ios::binary mode for this to work. These methods are not
|
|
|
|
|
* intended for general public use; they are used by the framework to improve
|
|
|
|
|
* performance by storing certain objects in binary files.
|
|
|
|
|
*/
|
|
|
|
|
void streamIn(FileStream* is);
|
|
|
|
|
void streamOut(FileStream* os) const;
|
|
|
|
|
|
2000-05-22 19:49:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* For internal use only - streaming to memory
|
|
|
|
|
*/
|
2000-11-09 21:58:19 +00:00
|
|
|
|
void streamIn(UMemoryStream* is, UErrorCode& status);
|
2000-05-22 19:49:10 +00:00
|
|
|
|
void streamOut(UMemoryStream* os) const;
|
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* Checks if this object is valid.
|
|
|
|
|
* @return TRUE if the object is valid, FALSE otherwise.
|
|
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
|
UBool isBogus() const;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
private:
|
|
|
|
|
/**
|
|
|
|
|
* The following are disallowed operations: not implemented.
|
|
|
|
|
*/
|
|
|
|
|
TableCollationData(const TableCollationData&);
|
|
|
|
|
TableCollationData& operator=(const TableCollationData&);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Do not access the fgCache object directly; use addToCache and findInCache.
|
|
|
|
|
static CollationCache fgCache;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/**
|
|
|
|
|
* The TableCollation class freely manipulates the data members within a
|
|
|
|
|
* TableCollationData object. This is because TableCollationData is
|
|
|
|
|
* intended to be an internal, invisible implementation detail. If
|
|
|
|
|
* TableCollationData every becomes a more public API, then this will have
|
|
|
|
|
* to change, although this is not really advised.
|
|
|
|
|
*/
|
|
|
|
|
friend class RuleBasedCollator;
|
2000-01-18 19:57:46 +00:00
|
|
|
|
friend class CollationElementIterator;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
|
UBool isFrenchSec;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
int16_t maxSecOrder;
|
|
|
|
|
int16_t maxTerOrder;
|
|
|
|
|
CompactIntArray* mapping;
|
|
|
|
|
VectorOfPToContractTable* contractTable;
|
|
|
|
|
VectorOfPToExpandTable* expandTable;
|
2000-05-18 22:08:39 +00:00
|
|
|
|
UBool fBogus;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rule string data is generated dynamically when required by the TableCollation
|
|
|
|
|
* object. In particular, when a binary file is created, the rule data is
|
|
|
|
|
* not streamed out -- this keeps the binary file small. However, two pieces
|
|
|
|
|
* of data are kept around (the desiredLocale and the realLocaleName) which
|
|
|
|
|
* allow later loading of the rule string efficiently. By efficiently, we mean
|
|
|
|
|
* that the usual search procedure is shortened, and the final file which
|
|
|
|
|
* actually led to the successful loading of the collation elements is accessed
|
|
|
|
|
* directly. The boolean isRuleTableLoaded allows the collation object to
|
|
|
|
|
* know whether rules have been loaded (an alternative is to use an empty
|
|
|
|
|
* ruleTable to indicate this, but this then disallows the empty string as
|
|
|
|
|
* a valid rule string). Note that when a collation is constructed "from
|
|
|
|
|
* scratch" (not loaded from a binary file), the rule table is already in place,
|
|
|
|
|
* and isRuleTableLoaded is set to true.
|
|
|
|
|
*
|
|
|
|
|
* See RuleBasedCollator::getRules().
|
|
|
|
|
*/
|
|
|
|
|
UnicodeString ruleTable;
|
2000-05-18 22:08:39 +00:00
|
|
|
|
UBool isRuleTableLoaded;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
Locale desiredLocale;
|
|
|
|
|
UnicodeString realLocaleName;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //_TCOLDATA
|
|
|
|
|
//eof
|