Logo Search packages:      
Sourcecode: icu version File versions  Download package

void Format::syntaxError ( const UnicodeString pattern,
int32_t  pos,
UParseError parseError 
) [static, protected, inherited]

Simple function for initializing a UParseError from a UnicodeString.

Parameters:
pattern The pattern to copy into the parseError
pos The position in pattern where the error occured
parseError The UParseError object to fill in ICU 2.4
Simple function for initializing a UParseError from a UnicodeString.

Parameters:
pattern The pattern to copy into the parseError
pos The position in pattern where the error occured
parseError The UParseError object to fill in ICU 2.4

Definition at line 166 of file format.cpp.

References UnicodeString::extract(), UnicodeString::length(), UParseError::line, UParseError::offset, UParseError::postContext, and UParseError::preContext.

Referenced by MessageFormat::applyPattern(), and ChoiceFormat::applyPattern().

                                                  {
    parseError.offset = pos;
    parseError.line=0;  // we are not using line number

    // for pre-context
    int32_t start = (pos < U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1
                                                             /* subtract 1 so that we have room for null*/));
    int32_t stop  = pos;
    pattern.extract(start,stop-start,parseError.preContext,0);
    //null terminate the buffer
    parseError.preContext[stop-start] = 0;

    //for post-context
    start = pos+1;
    stop  = ((pos+U_PARSE_CONTEXT_LEN)<=pattern.length()) ? (pos+(U_PARSE_CONTEXT_LEN-1)) :
        pattern.length();
    pattern.extract(start,stop-start,parseError.postContext,0);
    //null terminate the buffer
    parseError.postContext[stop-start]= 0;
}


Generated by  Doxygen 1.6.0   Back to index