2001-10-17 21:17:16 +00:00
|
|
|
/*
|
2001-11-27 01:05:31 +00:00
|
|
|
*******************************************************************************
|
2001-10-17 21:17:16 +00:00
|
|
|
*
|
2001-11-27 01:05:31 +00:00
|
|
|
* Copyright (C) 1999-2001, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2001-10-17 21:17:16 +00:00
|
|
|
*
|
2001-11-27 01:05:31 +00:00
|
|
|
*******************************************************************************
|
|
|
|
* file name: scrptrun.h
|
|
|
|
*
|
|
|
|
* created on: 10/17/2001
|
|
|
|
* created by: Eric R. Mader
|
2001-10-17 21:17:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SCRPTRUN_H
|
|
|
|
#define __SCRPTRUN_H
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
#include "unicode/utypes.h"
|
2002-06-27 01:19:20 +00:00
|
|
|
#include "unicode/uobject.h"
|
2001-11-27 01:05:31 +00:00
|
|
|
#include "unicode/uscript.h"
|
2001-10-17 21:17:16 +00:00
|
|
|
|
|
|
|
struct ScriptRecord
|
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
UChar32 startChar;
|
|
|
|
UChar32 endChar;
|
|
|
|
UScriptCode scriptCode;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ParenStackEntry
|
|
|
|
{
|
|
|
|
int32_t pairIndex;
|
|
|
|
UScriptCode scriptCode;
|
2001-10-17 21:17:16 +00:00
|
|
|
};
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
class ScriptRun : public UObject {
|
2001-10-17 21:17:16 +00:00
|
|
|
public:
|
2001-11-27 01:05:31 +00:00
|
|
|
ScriptRun();
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
ScriptRun(const UChar chars[], int32_t length);
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
ScriptRun(const UChar chars[], int32_t start, int32_t length);
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
void reset();
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
void reset(int32_t start, int32_t count);
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
void reset(const UChar chars[], int32_t start, int32_t length);
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
int32_t getScriptStart();
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
int32_t getScriptEnd();
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
UScriptCode getScriptCode();
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
UBool next();
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
|
|
|
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
|
|
|
*
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
|
|
|
|
2001-10-17 21:17:16 +00:00
|
|
|
private:
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
static UBool sameScript(int32_t scriptOne, int32_t scriptTwo);
|
|
|
|
|
|
|
|
int32_t charStart;
|
|
|
|
int32_t charLimit;
|
|
|
|
const UChar *charArray;
|
|
|
|
|
|
|
|
int32_t scriptStart;
|
|
|
|
int32_t scriptEnd;
|
|
|
|
UScriptCode scriptCode;
|
|
|
|
|
|
|
|
ParenStackEntry parenStack[128];
|
|
|
|
int32_t parenSP;
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
static int8_t highBit(int32_t value);
|
|
|
|
static int32_t getPairIndex(UChar32 ch);
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
static UChar32 pairedChars[];
|
|
|
|
static const int32_t pairedCharCount;
|
|
|
|
static const int32_t pairedCharPower;
|
|
|
|
static const int32_t pairedCharExtra;
|
2002-06-29 00:04:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The address of this static class variable serves as this class's ID
|
|
|
|
* for ICU "poor man's RTTI".
|
|
|
|
*/
|
|
|
|
static const char fgClassID;
|
2001-10-17 21:17:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline ScriptRun::ScriptRun()
|
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
reset(NULL, 0, 0);
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
reset(chars, 0, length);
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
reset(chars, start, length);
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline int32_t ScriptRun::getScriptStart()
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
return scriptStart;
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline int32_t ScriptRun::getScriptEnd()
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
return scriptEnd;
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline UScriptCode ScriptRun::getScriptCode()
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
return scriptCode;
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void ScriptRun::reset()
|
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
scriptStart = charStart;
|
|
|
|
scriptEnd = charStart;
|
|
|
|
scriptCode = USCRIPT_INVALID_CODE;
|
|
|
|
parenSP = -1;
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline void ScriptRun::reset(int32_t start, int32_t length)
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
charStart = start;
|
|
|
|
charLimit = start + length;
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
reset();
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
|
2001-10-17 21:17:16 +00:00
|
|
|
{
|
2001-11-27 01:05:31 +00:00
|
|
|
charArray = chars;
|
2001-10-17 21:17:16 +00:00
|
|
|
|
2001-11-27 01:05:31 +00:00
|
|
|
reset(start, length);
|
2001-10-17 21:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|