os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/parseerr.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
**********************************************************************
sl@0
     3
*   Copyright (C) 1999-2005, International Business Machines
sl@0
     4
*   Corporation and others.  All Rights Reserved.
sl@0
     5
**********************************************************************
sl@0
     6
*   Date        Name        Description
sl@0
     7
*   03/14/00    aliu        Creation.
sl@0
     8
*   06/27/00    aliu        Change from C++ class to C struct
sl@0
     9
**********************************************************************
sl@0
    10
*/
sl@0
    11
#ifndef PARSEERR_H
sl@0
    12
#define PARSEERR_H
sl@0
    13
sl@0
    14
#include "unicode/utypes.h"
sl@0
    15
sl@0
    16
sl@0
    17
/**
sl@0
    18
 * \file
sl@0
    19
 * \brief C API: Parse Error Information
sl@0
    20
 */
sl@0
    21
/**
sl@0
    22
 * The capacity of the context strings in UParseError.
sl@0
    23
 * @stable ICU 2.0
sl@0
    24
 */ 
sl@0
    25
enum { U_PARSE_CONTEXT_LEN = 16 };
sl@0
    26
sl@0
    27
/**
sl@0
    28
 * A UParseError struct is used to returned detailed information about
sl@0
    29
 * parsing errors.  It is used by ICU parsing engines that parse long
sl@0
    30
 * rules, patterns, or programs, where the text being parsed is long
sl@0
    31
 * enough that more information than a UErrorCode is needed to
sl@0
    32
 * localize the error.
sl@0
    33
 *
sl@0
    34
 * <p>The line, offset, and context fields are optional; parsing
sl@0
    35
 * engines may choose not to use to use them.
sl@0
    36
 *
sl@0
    37
 * <p>The preContext and postContext strings include some part of the
sl@0
    38
 * context surrounding the error.  If the source text is "let for=7"
sl@0
    39
 * and "for" is the error (e.g., because it is a reserved word), then
sl@0
    40
 * some examples of what a parser might produce are the following:
sl@0
    41
 *
sl@0
    42
 * <pre>
sl@0
    43
 * preContext   postContext
sl@0
    44
 * ""           ""            The parser does not support context
sl@0
    45
 * "let "       "=7"          Pre- and post-context only
sl@0
    46
 * "let "       "for=7"       Pre- and post-context and error text
sl@0
    47
 * ""           "for"         Error text only
sl@0
    48
 * </pre>
sl@0
    49
 *
sl@0
    50
 * <p>Examples of engines which use UParseError (or may use it in the
sl@0
    51
 * future) are Transliterator, RuleBasedBreakIterator, and
sl@0
    52
 * RegexPattern.
sl@0
    53
 * 
sl@0
    54
 * @stable ICU 2.0
sl@0
    55
 */
sl@0
    56
typedef struct UParseError {
sl@0
    57
sl@0
    58
    /**
sl@0
    59
     * The line on which the error occured.  If the parser uses this
sl@0
    60
     * field, it sets it to the line number of the source text line on
sl@0
    61
     * which the error appears, which will be be a value >= 1.  If the
sl@0
    62
     * parse does not support line numbers, the value will be <= 0.
sl@0
    63
     * @stable ICU 2.0
sl@0
    64
     */
sl@0
    65
    int32_t        line;
sl@0
    66
sl@0
    67
    /**
sl@0
    68
     * The character offset to the error.  If the line field is >= 1,
sl@0
    69
     * then this is the offset from the start of the line.  Otherwise,
sl@0
    70
     * this is the offset from the start of the text.  If the parser
sl@0
    71
     * does not support this field, it will have a value < 0.
sl@0
    72
     * @stable ICU 2.0
sl@0
    73
     */
sl@0
    74
    int32_t        offset;
sl@0
    75
sl@0
    76
    /**
sl@0
    77
     * Textual context before the error.  Null-terminated.  The empty
sl@0
    78
     * string if not supported by parser.
sl@0
    79
     * @stable ICU 2.0   
sl@0
    80
     */
sl@0
    81
    UChar          preContext[U_PARSE_CONTEXT_LEN];
sl@0
    82
sl@0
    83
    /**
sl@0
    84
     * The error itself and/or textual context after the error.
sl@0
    85
     * Null-terminated.  The empty string if not supported by parser.
sl@0
    86
     * @stable ICU 2.0   
sl@0
    87
     */
sl@0
    88
    UChar          postContext[U_PARSE_CONTEXT_LEN];
sl@0
    89
sl@0
    90
} UParseError;
sl@0
    91
sl@0
    92
#endif