Logo Search packages:      
Sourcecode: icu version File versions

Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

MessagePattern Class Reference

#include <messagepattern.h>

Inheritance diagram for MessagePattern:
Inheritance graph
[legend]
Collaboration diagram for MessagePattern:
Collaboration graph
[legend]

List of all members.

Classes

class  Part

Public Member Functions

UnicodeString autoQuoteApostropheDeep () const
void clear ()
void clearPatternAndSetApostropheMode (UMessagePatternApostropheMode mode)
int32_t countParts () const
UMessagePatternApostropheMode getApostropheMode () const
int32_t getLimitPartIndex (int32_t start) const
double getNumericValue (const Part &part) const
const PartgetPart (int32_t i) const
UMessagePatternPartType getPartType (int32_t i) const
int32_t getPatternIndex (int32_t partIndex) const
const UnicodeStringgetPatternString () const
double getPluralOffset (int32_t pluralStart) const
UnicodeString getSubstring (const Part &part) const
int32_t hashCode () const
UBool hasNamedArguments () const
UBool hasNumberedArguments () const
 MessagePattern (UErrorCode &errorCode)
 MessagePattern (const MessagePattern &other)
 MessagePattern (UMessagePatternApostropheMode mode, UErrorCode &errorCode)
 MessagePattern (const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
UBool operator!= (const MessagePattern &other) const
MessagePatternoperator= (const MessagePattern &other)
UBool operator== (const MessagePattern &other) const
MessagePatternparse (const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
MessagePatternparseChoiceStyle (const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
MessagePatternparsePluralStyle (const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
MessagePatternparseSelectStyle (const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
UBool partSubstringMatches (const Part &part, const UnicodeString &s) const
virtual ~MessagePattern ()

Static Public Member Functions

static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW
static int32_t validateArgumentName (const UnicodeString &name)

Private Member Functions

void addArgDoublePart (double numericValue, int32_t start, int32_t length, UErrorCode &errorCode)
void addLimitPart (int32_t start, UMessagePatternPartType type, int32_t index, int32_t length, int32_t value, UErrorCode &errorCode)
void addPart (UMessagePatternPartType type, int32_t index, int32_t length, int32_t value, UErrorCode &errorCode)
UBool copyStorage (const MessagePattern &other, UErrorCode &errorCode)
virtual UClassID getDynamicClassID () const
UBool init (UErrorCode &errorCode)
UBool inMessageFormatPattern (int32_t nestingLevel)
UBool inTopLevelChoiceMessage (int32_t nestingLevel, UMessagePatternArgType parentType)
UBool isChoice (int32_t index)
UBool isPlural (int32_t index)
UBool isSelect (int32_t index)
int32_t parseArg (int32_t index, int32_t argStartLength, int32_t nestingLevel, UParseError *parseError, UErrorCode &errorCode)
int32_t parseArgNumber (int32_t start, int32_t limit)
int32_t parseChoiceStyle (int32_t index, int32_t nestingLevel, UParseError *parseError, UErrorCode &errorCode)
void parseDouble (int32_t start, int32_t limit, UBool allowInfinity, UParseError *parseError, UErrorCode &errorCode)
int32_t parseMessage (int32_t index, int32_t msgStartLength, int32_t nestingLevel, UMessagePatternArgType parentType, UParseError *parseError, UErrorCode &errorCode)
int32_t parsePluralOrSelectStyle (UMessagePatternArgType argType, int32_t index, int32_t nestingLevel, UParseError *parseError, UErrorCode &errorCode)
int32_t parseSimpleStyle (int32_t index, UParseError *parseError, UErrorCode &errorCode)
void postParse ()
void preParse (const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
void setParseError (UParseError *parseError, int32_t index)
int32_t skipDouble (int32_t index)
int32_t skipIdentifier (int32_t index)
int32_t skipWhiteSpace (int32_t index)

Static Private Member Functions

static UBool isArgTypeChar (UChar32 c)
static int32_t parseArgNumber (const UnicodeString &s, int32_t start, int32_t limit)

Private Attributes

UMessagePatternApostropheMode aposMode
UBool hasArgNames
UBool hasArgNumbers
UnicodeString msg
UBool needsAutoQuoting
double * numericValues
int32_t numericValuesLength
MessagePatternDoubleListnumericValuesList
Partparts
int32_t partsLength
MessagePatternPartsListpartsList

Detailed Description

Parses and represents ICU MessageFormat patterns. Also handles patterns for ChoiceFormat, PluralFormat and SelectFormat. Used in the implementations of those classes as well as in tools for message validation, translation and format conversion.

The parser handles all syntax relevant for identifying message arguments. This includes "complex" arguments whose style strings contain nested MessageFormat pattern substrings. For "simple" arguments (with no nested MessageFormat pattern substrings), the argument style is not parsed any further.

The parser handles named and numbered message arguments and allows both in one message.

Once a pattern has been parsed successfully, iterate through the parsed data with countParts(), getPart() and related methods.

The data logically represents a parse tree, but is stored and accessed as a list of "parts" for fast and simple parsing and to minimize object allocations. Arguments and nested messages are best handled via recursion. For every _START "part", MessagePattern.getLimitPartIndex() efficiently returns the index of the corresponding _LIMIT "part".

List of "parts":

 message = MSG_START (SKIP_SYNTAX | INSERT_CHAR | REPLACE_NUMBER | argument)* MSG_LIMIT
 argument = noneArg | simpleArg | complexArg
 complexArg = choiceArg | pluralArg | selectArg
 noneArg = ARG_START.NONE (ARG_NAME | ARG_NUMBER) ARG_LIMIT.NONE
 simpleArg = ARG_START.SIMPLE (ARG_NAME | ARG_NUMBER) ARG_TYPE [ARG_STYLE] ARG_LIMIT.SIMPLE
 choiceArg = ARG_START.CHOICE (ARG_NAME | ARG_NUMBER) choiceStyle ARG_LIMIT.CHOICE
 pluralArg = ARG_START.PLURAL (ARG_NAME | ARG_NUMBER) pluralStyle ARG_LIMIT.PLURAL
 selectArg = ARG_START.SELECT (ARG_NAME | ARG_NUMBER) selectStyle ARG_LIMIT.SELECT
 choiceStyle = ((ARG_INT | ARG_DOUBLE) ARG_SELECTOR message)+
 pluralStyle = [ARG_INT | ARG_DOUBLE] (ARG_SELECTOR [ARG_INT | ARG_DOUBLE] message)+
 selectStyle = (ARG_SELECTOR message)+
 

This class is not intended for public subclassing.

ICU 4.8

Definition at line 346 of file messagepattern.h.


The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index