ICU 4.8.1.1  4.8.1.1
Data Structures | Defines | Typedefs | Enumerations
messagepattern.h File Reference

C++ API: MessagePattern class: Parses and represents ICU MessageFormat patterns. More...

#include "unicode/utypes.h"
#include "unicode/parseerr.h"
#include "unicode/unistr.h"

Go to the source code of this file.

Data Structures

class  MessagePattern
 Parses and represents ICU MessageFormat patterns. More...
class  MessagePattern::Part
 A message pattern "part", representing a pattern parsing event. More...

Defines

#define UMSGPAT_NO_NUMERIC_VALUE   ((double)(-123456789))
 Special value that is returned by getNumericValue(Part) when no numeric value is defined for a part.

Typedefs

typedef enum
UMessagePatternApostropheMode 
UMessagePatternApostropheMode
typedef enum
UMessagePatternPartType 
UMessagePatternPartType
typedef enum UMessagePatternArgType UMessagePatternArgType

Enumerations

enum  UMessagePatternApostropheMode { UMSGPAT_APOS_DOUBLE_OPTIONAL, UMSGPAT_APOS_DOUBLE_REQUIRED }
 Mode for when an apostrophe starts quoted literal text for MessageFormat output. More...
enum  UMessagePatternPartType {
  UMSGPAT_PART_TYPE_MSG_START, UMSGPAT_PART_TYPE_MSG_LIMIT, UMSGPAT_PART_TYPE_SKIP_SYNTAX, UMSGPAT_PART_TYPE_INSERT_CHAR,
  UMSGPAT_PART_TYPE_REPLACE_NUMBER, UMSGPAT_PART_TYPE_ARG_START, UMSGPAT_PART_TYPE_ARG_LIMIT, UMSGPAT_PART_TYPE_ARG_NUMBER,
  UMSGPAT_PART_TYPE_ARG_NAME, UMSGPAT_PART_TYPE_ARG_TYPE, UMSGPAT_PART_TYPE_ARG_STYLE, UMSGPAT_PART_TYPE_ARG_SELECTOR,
  UMSGPAT_PART_TYPE_ARG_INT, UMSGPAT_PART_TYPE_ARG_DOUBLE
}
 MessagePattern::Part type constants. More...
enum  UMessagePatternArgType {
  UMSGPAT_ARG_TYPE_NONE, UMSGPAT_ARG_TYPE_SIMPLE, UMSGPAT_ARG_TYPE_CHOICE, UMSGPAT_ARG_TYPE_PLURAL,
  UMSGPAT_ARG_TYPE_SELECT
}
 Argument type constants. More...
enum  { UMSGPAT_ARG_NAME_NOT_NUMBER = -1, UMSGPAT_ARG_NAME_NOT_VALID = -2 }

Detailed Description

C++ API: MessagePattern class: Parses and represents ICU MessageFormat patterns.

Definition in file messagepattern.h.


Define Documentation

#define UMSGPAT_NO_NUMERIC_VALUE   ((double)(-123456789))

Special value that is returned by getNumericValue(Part) when no numeric value is defined for a part.

See also:
MessagePattern.getNumericValue()
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 283 of file messagepattern.h.


Typedef Documentation

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 92 of file messagepattern.h.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 254 of file messagepattern.h.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 207 of file messagepattern.h.


Enumeration Type Documentation

anonymous enum
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
Enumerator:
UMSGPAT_ARG_NAME_NOT_NUMBER 

Return value from MessagePattern.validateArgumentName() for when the string is a valid "pattern identifier" but not a number.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_ARG_NAME_NOT_VALID 

Return value from MessagePattern.validateArgumentName() for when the string is invalid.

It might not be a valid "pattern identifier", or it have only ASCII digits but there is a leading zero or the number is too large.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 259 of file messagepattern.h.

Mode for when an apostrophe starts quoted literal text for MessageFormat output.

The default is DOUBLE_OPTIONAL unless overridden via uconfig.h (UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE).

A pair of adjacent apostrophes always results in a single apostrophe in the output, even when the pair is between two single, text-quoting apostrophes.

The following table shows examples of desired MessageFormat.format() output with the pattern strings that yield that output.

Desired output DOUBLE_OPTIONAL DOUBLE_REQUIRED
I see {many} I see '{many}' (same)
I said {'Wow!'} I said '{''Wow!''}' (same)
I don't know I don't know OR
I don''t know
I don''t know
Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
See also:
UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE
Enumerator:
UMSGPAT_APOS_DOUBLE_OPTIONAL 

A literal apostrophe is represented by either a single or a double apostrophe pattern character.

Within a MessageFormat pattern, a single apostrophe only starts quoted literal text if it immediately precedes a curly brace {}, or a pipe symbol | if inside a choice format, or a pound symbol # if inside a plural format.

This is the default behavior starting with ICU 4.8.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_APOS_DOUBLE_REQUIRED 

A literal apostrophe must be represented by a double apostrophe pattern character.

A single apostrophe always starts quoted literal text.

This is the behavior of ICU 4.6 and earlier, and of the JDK.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 66 of file messagepattern.h.

Argument type constants.

Returned by Part.getArgType() for ARG_START and ARG_LIMIT parts.

Messages nested inside an argument are each delimited by MSG_START and MSG_LIMIT, with a nesting level one greater than the surrounding message.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
Enumerator:
UMSGPAT_ARG_TYPE_NONE 

The argument has no specified type.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_ARG_TYPE_SIMPLE 

The argument has a "simple" type which is provided by the ARG_TYPE part.

An ARG_STYLE part might follow that.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_ARG_TYPE_CHOICE 

The argument is a ChoiceFormat with one or more ((ARG_INT | ARG_DOUBLE), ARG_SELECTOR, message) tuples.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_ARG_TYPE_PLURAL 

The argument is a PluralFormat with an optional ARG_INT or ARG_DOUBLE offset (e.g., offset:1) and one or more (ARG_SELECTOR [explicit-value] message) tuples.

If the selector has an explicit value (e.g., =2), then that value is provided by the ARG_INT or ARG_DOUBLE part preceding the message. Otherwise the message immediately follows the ARG_SELECTOR.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_ARG_TYPE_SELECT 

The argument is a SelectFormat with one or more (ARG_SELECTOR, message) pairs.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 217 of file messagepattern.h.

MessagePattern::Part type constants.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
Enumerator:
UMSGPAT_PART_TYPE_MSG_START 

Start of a message pattern (main or nested).

The length is 0 for the top-level message and for a choice argument sub-message, otherwise 1 for the '{'. The value indicates the nesting level, starting with 0 for the main message.

There is always a later MSG_LIMIT part.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_MSG_LIMIT 

End of a message pattern (main or nested).

The length is 0 for the top-level message and the last sub-message of a choice argument, otherwise 1 for the '}' or (in a choice argument style) the '|'. The value indicates the nesting level, starting with 0 for the main message.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_SKIP_SYNTAX 

Indicates a substring of the pattern string which is to be skipped when formatting.

For example, an apostrophe that begins or ends quoted text would be indicated with such a part. The value is undefined and currently always 0.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_INSERT_CHAR 

Indicates that a syntax character needs to be inserted for auto-quoting.

The length is 0. The value is the character code of the insertion character. (U+0027=APOSTROPHE)

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_REPLACE_NUMBER 

Indicates a syntactic (non-escaped) # symbol in a plural variant.

When formatting, replace this part's substring with the (value-offset) for the plural argument value. The value is undefined and currently always 0.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_START 

Start of an argument.

The length is 1 for the '{'. The value is the ordinal value of the ArgType. Use getArgType().

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_LIMIT 

End of an argument.

The length is 1 for the '}'. The value is the ordinal value of the ArgType. Use getArgType().

This part is followed by either an ARG_NUMBER or ARG_NAME, followed by optional argument sub-parts (see UMessagePatternArgType constants) and finally an ARG_LIMIT part.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_NUMBER 

The argument number, provided by the value.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_NAME 

The argument name.

The value is undefined and currently always 0.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_TYPE 

The argument type.

The value is undefined and currently always 0.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_STYLE 

The argument style text.

The value is undefined and currently always 0.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_SELECTOR 

A selector substring in a "complex" argument style.

The value is undefined and currently always 0.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_INT 

An integer value, for example the offset or an explicit selector value in a PluralFormat style.

The part value is the integer value.

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8
UMSGPAT_PART_TYPE_ARG_DOUBLE 

A numeric value, for example the offset or an explicit selector value in a PluralFormat style.

The part value is an index into an internal array of numeric values; use getNumericValue().

Draft:
This API may be changed in the future versions and was introduced in ICU 4.8

Definition at line 98 of file messagepattern.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines