intl/icu/source/common/unicode/parseerr.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unicode/parseerr.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 1999-2005, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*   Date        Name        Description
    1.10 +*   03/14/00    aliu        Creation.
    1.11 +*   06/27/00    aliu        Change from C++ class to C struct
    1.12 +**********************************************************************
    1.13 +*/
    1.14 +#ifndef PARSEERR_H
    1.15 +#define PARSEERR_H
    1.16 +
    1.17 +#include "unicode/utypes.h"
    1.18 +
    1.19 +
    1.20 +/**
    1.21 + * \file
    1.22 + * \brief C API: Parse Error Information
    1.23 + */
    1.24 +/**
    1.25 + * The capacity of the context strings in UParseError.
    1.26 + * @stable ICU 2.0
    1.27 + */ 
    1.28 +enum { U_PARSE_CONTEXT_LEN = 16 };
    1.29 +
    1.30 +/**
    1.31 + * A UParseError struct is used to returned detailed information about
    1.32 + * parsing errors.  It is used by ICU parsing engines that parse long
    1.33 + * rules, patterns, or programs, where the text being parsed is long
    1.34 + * enough that more information than a UErrorCode is needed to
    1.35 + * localize the error.
    1.36 + *
    1.37 + * <p>The line, offset, and context fields are optional; parsing
    1.38 + * engines may choose not to use to use them.
    1.39 + *
    1.40 + * <p>The preContext and postContext strings include some part of the
    1.41 + * context surrounding the error.  If the source text is "let for=7"
    1.42 + * and "for" is the error (e.g., because it is a reserved word), then
    1.43 + * some examples of what a parser might produce are the following:
    1.44 + *
    1.45 + * <pre>
    1.46 + * preContext   postContext
    1.47 + * ""           ""            The parser does not support context
    1.48 + * "let "       "=7"          Pre- and post-context only
    1.49 + * "let "       "for=7"       Pre- and post-context and error text
    1.50 + * ""           "for"         Error text only
    1.51 + * </pre>
    1.52 + *
    1.53 + * <p>Examples of engines which use UParseError (or may use it in the
    1.54 + * future) are Transliterator, RuleBasedBreakIterator, and
    1.55 + * RegexPattern.
    1.56 + * 
    1.57 + * @stable ICU 2.0
    1.58 + */
    1.59 +typedef struct UParseError {
    1.60 +
    1.61 +    /**
    1.62 +     * The line on which the error occured.  If the parser uses this
    1.63 +     * field, it sets it to the line number of the source text line on
    1.64 +     * which the error appears, which will be be a value >= 1.  If the
    1.65 +     * parse does not support line numbers, the value will be <= 0.
    1.66 +     * @stable ICU 2.0
    1.67 +     */
    1.68 +    int32_t        line;
    1.69 +
    1.70 +    /**
    1.71 +     * The character offset to the error.  If the line field is >= 1,
    1.72 +     * then this is the offset from the start of the line.  Otherwise,
    1.73 +     * this is the offset from the start of the text.  If the parser
    1.74 +     * does not support this field, it will have a value < 0.
    1.75 +     * @stable ICU 2.0
    1.76 +     */
    1.77 +    int32_t        offset;
    1.78 +
    1.79 +    /**
    1.80 +     * Textual context before the error.  Null-terminated.  The empty
    1.81 +     * string if not supported by parser.
    1.82 +     * @stable ICU 2.0   
    1.83 +     */
    1.84 +    UChar          preContext[U_PARSE_CONTEXT_LEN];
    1.85 +
    1.86 +    /**
    1.87 +     * The error itself and/or textual context after the error.
    1.88 +     * Null-terminated.  The empty string if not supported by parser.
    1.89 +     * @stable ICU 2.0   
    1.90 +     */
    1.91 +    UChar          postContext[U_PARSE_CONTEXT_LEN];
    1.92 +
    1.93 +} UParseError;
    1.94 +
    1.95 +#endif

mercurial