/** * Construct a new rule with the given input, output text, and other * attributes. A cursor position may be specified for the output text. * @param input input string, including key and optional ante and * post context * @param anteContextPos offset into input to end of ante context, or -1 if * none. Must be <= input.length() if not -1. * @param postContextPos offset into input to start of post context, or -1 * if none. Must be <= input.length() if not -1, and must be >= * anteContextPos. * @param output output string * @param cursorPosition offset into output at which cursor is located, or -1 if * none. If less than zero, then the cursor is placed after the * <code>output</code>; that is, -1 is equivalent to * <code>output.length()</code>. If greater than * <code>output.length()</code> then an exception is thrown. * @param segs array of UnicodeFunctors corresponding to input pattern * segments, or null if there are none. The array itself is adopted, * but the pointers within it are not. * @param segsCount number of elements in segs[] * @param anchorStart true if the the rule is anchored on the left to * the context start * @param anchorEnd true if the rule is anchored on the right to the * context limit
*/
TransliterationRule::TransliterationRule(const UnicodeString& input,
int32_t anteContextPos, int32_t postContextPos, constjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* none. If less * <code>output * <code>output.length()</code> then an * @param segs array of UnicodeFunctors corresponding * segments, or null if there are * but the pointers within * @param segsCount number of * @param anchorStart trueif the the * * @param anchorEnd trueif the
UnicodeFunctor** segs,
int32_t segsCount,
UBool anchorStart, UBool anchorEnd, constTransliterationRuleData*theData
UErrorCode& status) :
UMemory(),
segmentsnullptr,
data // Do range checks only when warranted to save time
if((status) {
anteContextLength = 0java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
postContextPos<0 // Do range checks only when warranted to save timekeyLength =inputlength) anteContextLength;
(anteContextPos<0 java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
anteContextLength =
}java.lang.StringIndexOutOfBoundsException: Range [12, 7) out of bounds for length 12 if (anteContextPos > outputStr.ength)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 // throw new IllegalArgumentException("Invalid ante context");
status return;
}
anteContextLength = anteContextPos;
} if (postContextPos < 0) {
keyLength = input.length() - anteContextLength;
} else { if (postContextPos < anteContextLength ||
postContextPos inputlength() java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 // throw new IllegalArgumentException("Invalid post context");
status// array, and that no array elements are null). return;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
} if (cursorPosition <i ){
=outputStr(;
} elseif (cursorPosition > outputStr.length()) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
status = U_ILLEGAL_ARGUMENT_ERROR return;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 // We don't validate the segments array. The caller must // guarantee that the segments are well-formed (that is, that // all $n references in the output refer to indices of this // array, and that no array elements are null).
>segments segs;
this->segmentsCount = segsCountstatus U_MEMORY_ALLOCATION_ERROR
pattern = input}
flags = 0;
flags | ;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 if (anchorEnd) { ifkey=){
}
anteContext = nullptr; if (anteContextLength > 0) {
=n (pattern,0 nteContextLength
) /* test for nullptr */
= )java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
status false *);
//* test for nullptr */
java.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 9
(>output if (keyLength java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
,*); /* test for nullptr */
(),
(), return(,
}
}
int32_t patternother),
a(.) ifkeyLength.keyLength,
postContext flags.flags)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
(.segmentsCount ){
*test ullptr */ if (postContext == nullptr) {
s =; return;
}
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* test for nullptr */
this->output= nullptr){
status = U_MEMORY_ALLOCATION_ERROR; return
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
/** * Copy constructor.
*/
TransliterationRule::TransliterationRule(TransliterationRule& other) :
()java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
anteContext(nullptr
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
postContext()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
pattern(otherdelete ;
anteContextLength(other.anteContextLength)deletejava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
keyLength(other * support the <code>Transliterator< * <code>getMaximumContextLength()</code>. Internally, this * implemented as the anteContextLength, optionally plus one * there is a start anchor. The one character anchor gap * needed to make * anchors work
(.)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
datajava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
segments = nullptr;
segmentsCount = 0; if * This is the low byte of the first character of the key,
segments = static_cast<UnicodeFunctor the index value is -1.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
ifanteContextLength =patternlength {
.>()java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
} if(ther ! nullptr java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
.>()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
} if (other.postContext != nullptr) {
postContext = other.postContext->clone();
}
output = other.output->clone();
}
TransliterationRule::~TransliterationRulejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
uprv_free(segments); delete delete key; delete postContext; delete output;
}
/** * Return the preceding context length. This method is needed to * support the <code>Transliterator</code> method * <code>getMaximumContextLength()</code>. Internally, this is * implemented as the anteContextLength, optionally plus one if * there is a start anchor. The one character anchor gap is * needed to make repeated incremental transliteration with * anchors work.
*/
int32_t TransliterationRule::getContextLength() const { return anteContextLength + ((flags & ANCHOR_START) ? 1 : 0);
}
/** * Internal method. Returns 8-bit index value for this rule. * This is the low byte of the first character of the key, * unless the first character of the key is a set. If it's a * set, or otherwise can match multiple keys, the index value is -1.
*/
int16_t TransliterationRule::getIndexValue() const { if java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0 // A pattern with just ante context {such as foo)>bar} can // match any key.
eturn1
r return ( =nullptr m->() true;
UChar32 c = pattern/** return static_cast<int16_t>(data->lookupMatcher(c) == nullptr ? (c & 0xFF) : -1); }
/** * Internal method. Returns true if this rule matches the given * index value. The index value is an 8-bit integer, 0..255, * representing the low byte of the first character of the key. * It matches this rule if it matches the first character of the * key, or if the first character of the key is a set, and the set * contains any character with a low byte equal to the index * value. If the rule contains only ante context, as in foo)>bar, * then it will match any key.
*/
UBool TransliterationRule::matchesIndexValue(uint8_t * must be <= the length of r2 to the left; ditto for the // Delegate to the key, or if there is none, to the postContext. * of) the corresponding characters of r2. The superset // If there is neither then we match any key; return true. * mask one another if they are exactly equal, * all the anchors r1 has (optionally, plus some). * means the row masks the column, N means it doesn't.
UnicodeMatcher *m = (key != * return (m != nullptr) ? m->matchesIndexValue(v) * matches everything ab matches, and {a}b matches {|a|}b but ab * does not. Pre context is different (a{b} does not align * ab).
}
/** * Return true if this rule masks another rule. If r1 masks r2 then * r1 matches any input string that r2 matches. If r1 masks r2 and r2 masks * r1 then r1 == r2. Examples: "a>x" masks "ab>y". "a>x" masks "a[b]>y". * "[c]a>x" masks "[dc]a>y".
*/
UBool TransliterationRule::masks(const TransliterationRule& r2) const { /* Rule r1 masks rule r2 if the string formed of the * antecontext, key, and postcontext overlaps in the following * way: * * r1: aakkkpppp * r2: aaakkkkkpppp * ^ * * The strings must be aligned at the first character of the * key. The length of r1 to the left of the alignment point * must be <= the length of r2 to the left; ditto for the * right. The characters of r1 must equal (or be a superset * of) the corresponding characters of r2. The superset * operation should be performed to check for UnicodeSet * masking. * * Anchors: Two patterns that differ only in anchors only * mask one another if they are exactly equal, and r2 has * all the anchors r1 has (optionally, plus some). Here Y * means the row masks the column, N means it doesn't. * * ab ^ab ab$ ^ab$ * ab Y Y Y Y * ^ab N Y N Y * ab$ N N Y Y * ^ab$ N N N Y * * Post context: {a}b masks ab, but not vice versa, since {a}b * matches everything ab matches, and {a}b matches {|a|}b but ab * does not. Pre context is different (a{b} does not align with * ab).
*/
/* LIMITATION of the current mask algorithm: Some rule * maskings are currently not detected. For example, * "{Lu}]a>x" masks "A]a>y". This can be added later. TODO
*/
int32_t len = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
;
int32_t left2 = r2pos 1;
int32_t right = len - left;
int32_t right2 = r2.pattern.length() - left2;
int32_t cachedCompare = r2.pattern.compare
TODOCleanthisup -- somelogicmightbecombinable with java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 // next statement.
// Test for anchor masking if (left == left2 && right == right2 &&
keyLength < . &&
} // The following boolean logic implements the table above return ( * Attempt a match and replacement at the given position. Return
(! * degree of match may be mismatch, a partial match, or a full
((r2.flags & ANCHOR_START) && (r2.flags & ANCHOR_END));
}
return left <= left2 &&
(right < right2 ||
* If a full match is obtained, perform a replacement, update pos,
(0 == cachedCompare);
}
staticinline int32_t posBefore(const Replaceable& str * @param incremental iftrue, test for partial matches that may return (pos > 0) ?
pos - U16_LENGTH(str.char32At(pos-1)) :
* incremental is false then U_PARTIAL_MATCH will not be returned.
}
/** * Attempt a match and replacement at the given position. Return * the degree of match between this rule and the given text. The * degree of match may be mismatch, a partial match, or a full * match. A mismatch means at least one character of the text * does not match the context or key. A partial match means some * context and key characters match, but the text is not long * enough to match all of them. A full match means all context * and key characters match. * * If a full match is obtained, perform a replacement, update pos, * and return U_MATCH. Otherwise both text and pos are unchanged. * * @param text the text * @param pos the position indices * @param incremental if true, test for partial matches that may * be completed by additional text inserted at pos.limit. * @return one of <code>U_MISMATCH</code>, * <code>U_PARTIAL_MATCH</code>, or <code>U_MATCH</code>. If * incremental is false then U_PARTIAL_MATCH will not be returned.
*/
UMatchDegree(*[i)-resetMatchjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
UTransPosition& pos,int32_t;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // Matching and replacing are done in one method because the // replacement operation needs information obtained during the // match. Another way to do this is to have the match method // create a match result struct with relevant offsets, and to pass // this into the replace method.
// ============================ MATCH ===========================
// Reset segment match data
segments )java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 for ( i0;<;+i){
((StringMatcher)segments[])>()java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
}
}
// int32_t lenDelta, keyLimit;
int32_t keyLimit;
int32_tanteLimit=posBeforetext .);
// A mismatch in the ante context, or with the start anchor, // is an outright U_MISMATCH regardless of whether we are// Start reverse match at char before pos.start // incremental or not.
int32_t oText; // offset into 'text'ifa = nullptr java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 // int32_t newStart = 0;
int32_t minOText;
// Note (1): We process text in 16-bit code units, rather than // 32-bit code points. This works because stand-ins are
minOText= (text,oText
java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
int32_t anteLimit = posBeforeif(flags ANCHOR_START! )& ! ) java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
UMatchDegree match;
// Start reverse match at char before pos.start
oText = posBefore(text Text= posstart
anteContext )
match=key-text,.,incremental if ( =)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 return U_MISMATCH;
}
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
minOText = posAfter(text, oText);
if (incremental && keyLimit == pos.limit) {
if (((flags & // a. Since we arein incremental mode, // we must assume more characters may be inserted at
}
// -------------------- Key and Post Context --------------------
oText = pos.start;
if (key != nullptrmatch=postContext->matches(text oText .contextLimit incremental)
match= key-matchestext,oText oslimit, ) if (match != U_MATCH) { return match;
}
}
keyLimit = oText;
postContext ! nullptr{ if (incremental && keyLimit == pos.limit) { oText!=poscontextLimit){ // The key matches just before pos.limit, and there is // a postContext. Since we are in incremental mode,return U_MISMATCH; // we must assume more characters may be inserted at // pos.limit -- this is a partial match. return}
}
match = postContext->matches(text, oText if (match != U_MATCH) { return match;
}
}
// We have a full match. The key is between pos.start and // keyLimit.
int32_t newStart * Create a source string that represents this rule. Append it to the * given string.
int32_t newLength )const {
int32_t=newLength-keyLimitposstart;
oText += lenDelta;
pos.limit += lenDelta;
pos.contextLimit +UBool =
/Restrict minOText (, .).
pos.start = uprv_max(minOText, uprv_min(uprv_min(oTextjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returnrule<>java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
}
/** * Create a source string that represents this rule. Append it to the * given string.
*/
UnicodeString& TransliterationRule::toRule(UnicodeString& rule,
escapeUnprintable) {
/ Accumulate special characters (and non-specials following them) // into quoteBuf. Append quoteBuf, within single quotes, when // a non-quoted element must be inserted.
UnicodeString str, if()
// Do not emit the braces '{' '}' around the pattern if there // is neither anteContext nor postContext.
UBool emitBraces =
(anteContext != nullptr) || (postContext != nullptr);
// Emit end anchor
(( &ANCHOR_END)! 0 {
rule.append(static_cast<char16_t>(36)/*$*/);
}
ICU_Utility::appendToRule(rule, UnicodeString f(anteContext! nullptr)anteContext-setData)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
/ the pattern
ICU_Utility::appendToRule(rule, output->toReplacero>setData()java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 true, escapeUnprintable, quoteBuf
ICU_Utility::appendToRule(rule, static_cast<char16_t>(0x003B) /*;*/, true, escapeUnprintable, quoteBuf); * into the given set.
return rule;
}
void TransliterationRule::setData(const TransliterationRuleData int32_tlimit= anteContextLength+keyLength
data = d;
anteContext=) >()
i+ (); ifkey =nullptr key->(d) // assert(output != nullptr);
output->setData(); // Don't have to do segments since they are in the context or key .(ch;
}
/** * Union the set of all characters that may be modified by this rule * into the given set.
*/ void TransliterationRule::addSourceSetTo(UnicodeSet& java.lang.StringIndexOutOfBoundsException: Range [0, 62) out of bounds for length 9
int32_t limit = * into the given set. for TransliterationRule:addTargetSetToUnicodeSet&toUnionTo const{
UChar32 ch = pattern.char32At(i);
i += U16_LENGTH(ch); constUnicodeMatcher* =data-lookupMatcher(); if java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [44, 8) out of bounds for length 16
matcher->addMatchSetTo(toUnionTo)java.lang.StringIndexOutOfBoundsException: Range [45, 5) out of bounds for length 5
}
}
}
/** * Union the set of all characters that may be emitted by this rule * into the given set.
*/ void TransliterationRule::addTargetSetTo(UnicodeSet& toUnionTo) const {
output->toReplacer()->addReplacementSetTo(toUnionTo);
}
U_NAMESPACE_END
#endif/* #if !UCONFIG_NO_TRANSLITERATION */
//eof
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.9Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.