ICU-1099 Make some data a bit more const

X-SVN-Rev: 6203
This commit is contained in:
George Rhoten 2001-10-11 23:54:55 +00:00
parent 1c8591684a
commit efdb5a1f89
23 changed files with 66 additions and 68 deletions

View File

@ -18,7 +18,7 @@ U_NAMESPACE_BEGIN
/**
* ID for this transliterator.
*/
const char* HexToUnicodeTransliterator::_ID = "Hex-Any";
const char HexToUnicodeTransliterator::_ID[] = "Hex-Any";
/**
* This pattern encodes the following specs for the default constructor:
@ -29,15 +29,16 @@ const char* HexToUnicodeTransliterator::_ID = "Hex-Any";
* The multiple backslashes resolve to a single backslash
* in the effective prefix.
*/
static const UChar gDEFAULT_PATTERN[] = {
const UChar HexToUnicodeTransliterator::DEFAULT_PATTERN[] = {
0x5C, 0x5C, 0x75, 0x30, 0x30, 0x30, 0x30, 0x3B, /* "\\u0000;" */
0x5C, 0x5C, 0x55, 0x30, 0x30, 0x30, 0x30, 0x3B, /* "\\U0000;" */
0x75, 0x2B, 0x30, 0x30, 0x30, 0x30, 0x3B, /* "u+0000;" */
0x55, 0x2B, 0x30, 0x30, 0x30, 0x30, 0 /* "U+0000" */
}; /* "\\u0000;\\U0000;u+0000;U+0000" */
const UChar *HexToUnicodeTransliterator::DEFAULT_PATTERN = gDEFAULT_PATTERN;
// UNICODE_STRING("\\\\u0000;\\\\U0000;u+0000;U+0000", 29);
static const UChar gQuadA[] = {
0x41, 0x41, 0x41, 0x41, 0
}; /* "AAAA" */
/**
* Constructs a transliterator.
@ -206,7 +207,7 @@ void HexToUnicodeTransliterator::applyPattern(const UnicodeString& thePattern,
// header will not have been allocated yet. We need
// allocate the header now.
if (start == affixes.length()) {
affixes.append(UNICODE_STRING("AAAA", 4));
affixes.append(gQuadA);
}
// Fill in 4-character header
affixes.setCharAt(start++, (UChar) prefixLen);
@ -228,7 +229,7 @@ void HexToUnicodeTransliterator::applyPattern(const UnicodeString& thePattern,
// Make space for the header. Append any four
// characters as place holders for the header values.
// We fill these in when we parse the ';'.
affixes.append(UNICODE_STRING("AAAA", 4));
affixes.append(gQuadA);
}
affixes.append(c);
if (mode == 0) {
@ -337,10 +338,9 @@ void HexToUnicodeTransliterator::handleTransliterate(Replaceable& text, UTransPo
if (match) {
// This is a temporary one-character string
UnicodeString str = UNICODE_STRING("A", 1);
UnicodeString str(u);
// At this point, we have a match
str.setCharAt(0, u);
text.handleReplaceBetween(cursor, curs, str);
limit -= curs - cursor - 1;
// The following break statement leaves the

View File

@ -54,7 +54,7 @@ static const UChar g_umsg_choice[] = {
};
// MessageFormat Type List Number, Date, Time or Choice
static const UChar *g_umsgTypeList[] = {
static const UChar * const g_umsgTypeList[] = {
NULL, NULL, g_umsg_number,
NULL, g_umsg_date, NULL,
g_umsg_time, NULL, g_umsg_choice
@ -71,7 +71,7 @@ static const UChar g_umsg_integer[] = {
};
// NumberFormat modifier list, default, currency, percent or integer
static const UChar *g_umsgModifierList[] = {
static const UChar * const g_umsgModifierList[] = {
NULL, NULL, g_umsg_currency,
NULL, g_umsg_percent, NULL,
g_umsg_integer, NULL, NULL
@ -91,7 +91,7 @@ static const UChar g_umsg_full[] = {
};
// DateFormat modifier list, default, short, medium, long or full
static const UChar *g_umsgDateModifierList[] = {
static const UChar * const g_umsgDateModifierList[] = {
NULL, NULL, g_umsg_short,
NULL, g_umsg_medium, NULL,
g_umsg_long, NULL, g_umsg_full
@ -1310,7 +1310,7 @@ MessageFormat::makeFormat(/*int32_t position, */
// -------------------------------------
// Finds the string, s, in the string array, list.
int32_t MessageFormat::findKeyword(const UnicodeString& s,
const UChar **list)
const UChar * const *list)
{
if (s.length() == 0)
return 0;

View File

@ -15,7 +15,7 @@
U_NAMESPACE_BEGIN
char RuleBasedTransliterator::fgClassID = 0; // Value is irrelevant
const char RuleBasedTransliterator::fgClassID = 0; // Value is irrelevant
void RuleBasedTransliterator::_construct(const UnicodeString& rules,
UTransDirection direction,

View File

@ -631,8 +631,8 @@ const int32_t RuleBasedCollator::PRIMIGNORABLE = 0x0202;
/* unique file id for parity check */
const int16_t RuleBasedCollator::FILEID = 0x5443;
/* binary collation file extension */
const char* RuleBasedCollator::kFilenameSuffix = ".col";
const char RuleBasedCollator::kFilenameSuffix[] = ".col";
/* class id ? Value is irrelevant */
char RuleBasedCollator::fgClassID = 0;
const char RuleBasedCollator::fgClassID = 0;
U_NAMESPACE_END

View File

@ -16,7 +16,7 @@ U_NAMESPACE_BEGIN
/**
* ID for this transliterator.
*/
const char* TitlecaseTransliterator::_ID = "Any-Title";
const char TitlecaseTransliterator::_ID[] = "Any-Title";
TitlecaseTransliterator::TitlecaseTransliterator(UnicodeFilter* adoptedFilter) :
Transliterator(_ID, adoptedFilter) {

View File

@ -12,7 +12,7 @@
U_NAMESPACE_BEGIN
const char* LowercaseTransliterator::_ID = "Any-Lower";
const char LowercaseTransliterator::_ID[] = "Any-Lower";
/**
* Constructs a transliterator.

View File

@ -12,7 +12,7 @@
U_NAMESPACE_BEGIN
const char* UppercaseTransliterator::_ID = "Any-Upper";
const char UppercaseTransliterator::_ID[] = "Any-Upper";
/**
* Constructs a transliterator.

View File

@ -37,6 +37,8 @@
#include "unicode/unitohex.h"
#include "unicode/uscript.h"
U_NAMESPACE_BEGIN
// keep in sync with CompoundTransliterator
static const UChar ID_SEP = 0x002D; /*-*/
static const UChar ID_DELIM = 0x003B; /*;*/
@ -49,14 +51,14 @@ static const UChar CLOSE_PAREN = 41;
* transliterator. The ID is appended to this to form the key.
* The resource bundle value should be a String.
*/
static const char* RB_DISPLAY_NAME_PREFIX = "%Translit%%";
static const char RB_DISPLAY_NAME_PREFIX[] = "%Translit%%";
/**
* Prefix for resource bundle key for the display name for a
* transliterator SCRIPT. The ID is appended to this to form the key.
* The resource bundle value should be a String.
*/
static const char* RB_SCRIPT_DISPLAY_NAME_PREFIX = "%Translit%";
static const char RB_SCRIPT_DISPLAY_NAME_PREFIX[] = "%Translit%";
/**
* Resource bundle key for display name pattern.
@ -64,7 +66,7 @@ static const char* RB_SCRIPT_DISPLAY_NAME_PREFIX = "%Translit%";
* MessageFormat pattern, e.g.:
* "{0,choice,0#|1#{1} Transliterator|2#{1} to {2} Transliterator}".
*/
static const char* RB_DISPLAY_NAME_PATTERN = "TransliteratorNamePattern";
static const char RB_DISPLAY_NAME_PATTERN[] = "TransliteratorNamePattern";
/**
* Resource bundle key for the list of RuleBasedTransliterator IDs.
@ -72,9 +74,7 @@ static const char* RB_DISPLAY_NAME_PATTERN = "TransliteratorNamePattern";
* being a valid ID. The ID will be appended to RB_RULE_BASED_PREFIX
* to obtain the class name in which the RB_RULE key will be sought.
*/
static const char* RB_RULE_BASED_IDS = "RuleBasedTransliteratorIDs";
U_NAMESPACE_BEGIN
static const char RB_RULE_BASED_IDS[] = "RuleBasedTransliteratorIDs";
/**
* The mutex controlling access to registry object.
@ -90,7 +90,7 @@ static TransliteratorRegistry* registry = 0;
* Class identifier for subclasses of Transliterator that do not
* define their class (anonymous subclasses).
*/
char Transliterator::fgClassID = 0; // Value is irrelevant
const char Transliterator::fgClassID = 0; // Value is irrelevant
/**
* Default constructor.
@ -1442,11 +1442,10 @@ void Transliterator::initializeRegistry(void) {
*
* The extra blank field on "alias" lines is to make the array square.
*/
Locale indexLoc("translit_index");
static const char translit_index[] = "translit_index";
UResourceBundle *bundle, *transIDs, *colBund;
bundle = ures_openDirect(0, "translit_index", &status);
bundle = ures_openDirect(0, translit_index, &status);
transIDs = ures_getByKey(bundle, RB_RULE_BASED_IDS, 0, &status);
int32_t row, maxRows;

View File

@ -31,7 +31,7 @@ static const UChar ANY[] = { 65, 110, 121, 0 }; // Any
/**
* Resource bundle key for the RuleBasedTransliterator rule.
*/
static const char* RB_RULE = "Rule";
static const char RB_RULE[] = "Rule";
U_NAMESPACE_BEGIN

View File

@ -159,33 +159,33 @@ U_STRING_DECL(option_13, "hiraganaQ", 9);
U_STRING_DECL(option_14, "strength", 8);
ucolTokSuboption alternateSub[2] = {
static const ucolTokSuboption alternateSub[2] = {
{suboption_00, 13, UCOL_NON_IGNORABLE},
{suboption_01, 7, UCOL_SHIFTED}
};
ucolTokSuboption caseFirstSub[3] = {
static const ucolTokSuboption caseFirstSub[3] = {
{suboption_02, 5, UCOL_LOWER_FIRST},
{suboption_03, 5, UCOL_UPPER_FIRST},
{suboption_04, 3, UCOL_OFF},
};
ucolTokSuboption onOffSub[2] = {
static const ucolTokSuboption onOffSub[2] = {
{suboption_04, 3, UCOL_OFF},
{suboption_05, 2, UCOL_ON}
};
ucolTokSuboption frenchSub[1] = {
static const ucolTokSuboption frenchSub[1] = {
{suboption_07, 1, UCOL_ON}
};
ucolTokSuboption beforeSub[3] = {
static const ucolTokSuboption beforeSub[3] = {
{suboption_06, 1, UCOL_PRIMARY},
{suboption_07, 1, UCOL_SECONDARY},
{suboption_08, 1, UCOL_TERTIARY}
};
ucolTokSuboption strengthSub[5] = {
static const ucolTokSuboption strengthSub[5] = {
{suboption_06, 1, UCOL_PRIMARY},
{suboption_07, 1, UCOL_SECONDARY},
{suboption_08, 1, UCOL_TERTIARY},
@ -193,7 +193,7 @@ ucolTokSuboption strengthSub[5] = {
{suboption_10, 1, UCOL_IDENTICAL},
};
ucolTokOption rulesOptions[UTOK_OPTION_COUNT] = {
static const ucolTokOption rulesOptions[UTOK_OPTION_COUNT] = {
{option_02, 9, alternateSub, 2, UCOL_ALTERNATE_HANDLING}, /*"alternate" */
{option_03, 9, frenchSub, 1, UCOL_FRENCH_COLLATION}, /*"backwards" */
{option_07, 9, onOffSub, 2, UCOL_CASE_LEVEL}, /*"caseLevel" */

View File

@ -103,7 +103,7 @@ typedef struct {
typedef struct {
const UChar *optionName;
int32_t optionLen;
ucolTokSuboption *subopts;
const ucolTokSuboption *subopts;
int32_t subSize;
UColAttribute attr;
} ucolTokOption;

View File

@ -13,7 +13,7 @@
U_NAMESPACE_BEGIN
const char* UnicodeNameTransliterator::_ID = "Any-Name";
const char UnicodeNameTransliterator::_ID[] = "Any-Name";
/**
* Constructs a transliterator.

View File

@ -24,7 +24,7 @@ U_NAMESPACE_BEGIN
* <p>Copyright &copy; IBM Corporation 1999. All rights reserved.
*
* @author Alan Liu
* @version $RCSfile: hextouni.h,v $ $Revision: 1.10 $ $Date: 2001/10/08 23:25:22 $
* @version $RCSfile: hextouni.h,v $ $Revision: 1.11 $ $Date: 2001/10/11 23:54:55 $
* @draft
*/
class U_I18N_API HexToUnicodeTransliterator : public Transliterator {
@ -32,12 +32,12 @@ class U_I18N_API HexToUnicodeTransliterator : public Transliterator {
/**
* ID for this transliterator.
*/
static const char* _ID;
static const char _ID[];
/**
* The pattern used by the default constructor
*/
static const UChar *DEFAULT_PATTERN;
static const UChar DEFAULT_PATTERN[];
// Character constants defined here to avoid ASCII dependency
enum {

View File

@ -554,7 +554,7 @@ private:
* @return the index of the list which matches the keyword s.
*/
static int32_t findKeyword( const UnicodeString& s,
const UChar **list);
const UChar * const *list);
/**
* Formats the array of arguments and copies the result into the result buffer,

View File

@ -475,7 +475,7 @@ private:
/**
* Class identifier for RuleBasedTransliterator.
*/
static char fgClassID;
static const char fgClassID;
void _construct(const UnicodeString& rules,
UTransDirection direction,

View File

@ -370,7 +370,7 @@ public:
* @param status reporting a success or an error.
* @see Locale
*/
RuleBasedCollator(const UnicodeString& rules, UErrorCode& status);
RuleBasedCollator(const UnicodeString& rules, UErrorCode& status);
/**
* RuleBasedCollator constructor. This takes the table rules and builds a
@ -418,14 +418,14 @@ public:
* @param the RuleBasedCollator object to be copied
* @see Locale
*/
RuleBasedCollator(const RuleBasedCollator& other);
RuleBasedCollator(const RuleBasedCollator& other);
// destructor --------------------------------------------------------------
/**
* Destructor.
*/
virtual ~RuleBasedCollator();
virtual ~RuleBasedCollator();
// public methods ----------------------------------------------------------
@ -433,7 +433,7 @@ public:
* Assignment operator.
* @param other other RuleBasedCollator object to compare with.
*/
RuleBasedCollator& operator=(const RuleBasedCollator& other);
RuleBasedCollator& operator=(const RuleBasedCollator& other);
/**
* Returns true if argument is the same as this object.
@ -465,7 +465,7 @@ public:
* @return the collation element iterator of the source string using this as
* the based Collator.
*/
virtual CollationElementIterator* createCollationElementIterator(
virtual CollationElementIterator* createCollationElementIterator(
const UnicodeString& source) const;
/**
@ -598,7 +598,7 @@ public:
* any expansion sequence
* @see CollationElementIterator#getMaxExpansion
*/
int32_t getMaxExpansion(int32_t order) const;
int32_t getMaxExpansion(int32_t order) const;
/**
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
@ -638,13 +638,13 @@ public:
*/
uint8_t *cloneRuleData(int32_t &length, UErrorCode &status);
/**
* Returns current rules. Delta defines whether full rules are returned or
* just the tailoring.
* @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
* @return UnicodeString with rules
*/
UnicodeString getRules(UColRuleOption delta);
/**
* Returns current rules. Delta defines whether full rules are returned or
* just the tailoring.
* @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
* @return UnicodeString with rules
*/
UnicodeString getRules(UColRuleOption delta);
/**
* Universal attribute setter
@ -720,7 +720,7 @@ public:
* @return Number of bytes needed for storing the sort key
*/
virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result,
int32_t resultLength) const;
int32_t resultLength) const;
/**
* Get the sort key as an array of bytes from an UChar buffer.
@ -734,7 +734,7 @@ public:
* @return Number of bytes needed for storing the sort key
*/
virtual int32_t getSortKey(const UChar *source, int32_t sourceLength,
uint8_t *result, int32_t resultLength) const;
uint8_t *result, int32_t resultLength) const;
/**
* Determines the minimum strength that will be use in comparison or
@ -845,14 +845,14 @@ private:
static const int32_t PRIMIGNORABLE;
static const int16_t FILEID;
static const char *kFilenameSuffix;
static const char kFilenameSuffix[];
// private static variables -----------------------------------------------
/**
* static class id
*/
static char fgClassID;
static const char fgClassID;
// private data members ---------------------------------------------------

View File

@ -26,7 +26,7 @@ class U_I18N_API TitlecaseTransliterator : public Transliterator {
/**
* ID for this transliterator.
*/
static const char* _ID;
static const char _ID[];
public:

View File

@ -66,7 +66,7 @@ class U_I18N_API LowercaseTransliterator : public TransformTransliterator {
Locale loc;
static const char* _ID;
static const char _ID[];
};
U_NAMESPACE_END

View File

@ -66,7 +66,7 @@ class U_I18N_API UppercaseTransliterator : public TransformTransliterator {
Locale loc;
static const char* _ID;
static const char _ID[];
};
U_NAMESPACE_END

View File

@ -18,7 +18,6 @@ class Replaceable;
class UnicodeFilter;
class UnicodeSet;
class TransliterationRuleData;
class Hashtable;
class U_I18N_API UVector;
class CompoundTransliterator;
class TransliteratorParser;
@ -908,7 +907,7 @@ private:
* Class identifier for subclasses of Transliterator that do not
* define their class (anonymous subclasses).
*/
static char fgClassID;
static const char fgClassID;
protected:

View File

@ -68,7 +68,7 @@ class U_I18N_API UnicodeNameTransliterator : public Transliterator {
private:
static const char* _ID;
static const char _ID[];
};
U_NAMESPACE_END

View File

@ -52,7 +52,7 @@ private:
/**
* ID for this transliterator.
*/
static const char* _ID;
static const char _ID[];
/**
* The pattern set by applyPattern() and returned by toPattern().

View File

@ -16,7 +16,7 @@ U_NAMESPACE_BEGIN
/**
* ID for this transliterator.
*/
const char* UnicodeToHexTransliterator::_ID = "Any-Hex";
const char UnicodeToHexTransliterator::_ID[] = "Any-Hex";
const UChar UnicodeToHexTransliterator::HEX_DIGITS[32] = {
// Use Unicode hex values for EBCDIC compatibility