15 #ifndef __MESSAGEPATTERN_H__
16 #define __MESSAGEPATTERN_H__
25 #if !UCONFIG_NO_FORMATTING
283 #define UMSGPAT_NO_NUMERIC_VALUE ((double)(-123456789))
287 class MessagePatternDoubleList;
288 class MessagePatternPartsList;
528 int32_t hashCode()
const;
564 return hasArgNumbers;
578 static int32_t validateArgumentName(
const UnicodeString &name);
622 return getPart(i).type;
633 return getPart(partIndex).index;
655 return 0==msg.compare(part.index, part.length, s);
664 double getNumericValue(
const Part &part)
const;
672 double getPluralOffset(int32_t pluralStart)
const;
683 int32_t limit=getPart(start).limitPartIndex;
800 return ((type*37+index)*37+length)*37+value;
806 static const int32_t MAX_LENGTH=0xffff;
807 static const int32_t MAX_VALUE=0x7fff;
815 int32_t limitPartIndex;
823 int32_t parseMessage(int32_t index, int32_t msgStartLength,
827 int32_t parseArg(int32_t index, int32_t argStartLength, int32_t nestingLevel,
846 static int32_t parseArgNumber(
const UnicodeString &s, int32_t start, int32_t limit);
848 int32_t parseArgNumber(int32_t start, int32_t limit) {
849 return parseArgNumber(msg, start, limit);
860 void parseDouble(int32_t start, int32_t limit,
UBool allowInfinity,
866 int32_t skipWhiteSpace(int32_t index);
868 int32_t skipIdentifier(int32_t index);
874 int32_t skipDouble(int32_t index);
878 UBool isChoice(int32_t index);
880 UBool isPlural(int32_t index);
882 UBool isSelect(int32_t index);
888 UBool inMessageFormatPattern(int32_t nestingLevel);
899 void addLimitPart(int32_t start,
903 void addArgDoublePart(
double numericValue, int32_t start, int32_t length,
UErrorCode &errorCode);
905 void setParseError(
UParseError *parseError, int32_t index);
916 MessagePatternPartsList *partsList;
920 MessagePatternDoubleList *numericValuesList;
921 double *numericValues;
922 int32_t numericValuesLength;
925 UBool needsAutoQuoting;
930 #endif // !UCONFIG_NO_FORMATTING
932 #endif // __MESSAGEPATTERN_H__
The argument is a SelectFormat with one or more (ARG_SELECTOR, message) pairs.
An integer value, for example the offset or an explicit selector value in a PluralFormat style...
MessagePattern & parseChoiceStyle(const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode)
Parses a ChoiceFormat pattern string.
A numeric value, for example the offset or an explicit selector value in a PluralFormat style...
int32_t getLength() const
Returns the length of the pattern substring associated with this Part.
A literal apostrophe is represented by either a single or a double apostrophe pattern character...
A message pattern "part", representing a pattern parsing event.
int32_t getIndex() const
Returns the pattern string index associated with this Part.
UBool partSubstringMatches(const Part &part, const UnicodeString &s) const
Compares the part's substring with the input string s.
UBool operator!=(const Part &other) const
The argument has no specified type.
static UBool hasNumericValue(UMessagePatternPartType type)
Indicates whether the Part type has a numeric value.
UBool hasNumberedArguments() const
Does the parsed pattern have numbered arguments like {2}?
UMessagePatternPartType
MessagePattern::Part type constants.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
The argument number, provided by the value.
UMessagePatternApostropheMode getApostropheMode() const
UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const
Create a temporary substring for the specified range.
The argument is a ChoiceFormat with one or more ((ARG_INT | ARG_DOUBLE), ARG_SELECTOR, message) tuples.
UMessagePatternArgType getArgType() const
Returns the argument type if this part is of type ARG_START or ARG_LIMIT, otherwise UMSGPAT_ARG_TYPE_...
UMessagePatternPartType getType() const
Returns the type of this part.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Return value from MessagePattern.validateArgumentName() for when the string is a valid "pattern ident...
A literal apostrophe must be represented by a double apostrophe pattern character.
UMessagePatternPartType getPartType(int32_t i) const
Returns the UMessagePatternPartType of the i-th pattern "part".
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
UBool operator!=(const MessagePattern &other) const
Indicates that a syntax character needs to be inserted for auto-quoting.
int32_t getLimit() const
Returns the pattern string limit (exclusive-end) index associated with this Part. ...
int32_t getPatternIndex(int32_t partIndex) const
Returns the pattern index of the specified pattern "part".
UMemory is the common ICU base class.
Return value from MessagePattern.validateArgumentName() for when the string is invalid.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Start of a message pattern (main or nested).
Parses and represents ICU MessageFormat patterns.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
UObject is the common ICU "boilerplate" class.
C API: Parse Error Information.
End of a message pattern (main or nested).
int32_t getValue() const
Returns a value associated with this part.
A selector substring in a "complex" argument style.
Indicates a substring of the pattern string which is to be skipped when formatting.
const Part & getPart(int32_t i) const
Gets the i-th pattern "part".
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Indicates a syntactic (non-escaped) # symbol in a plural variant.
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.
Part()
Default constructor, do not use.
UBool hasNamedArguments() const
Does the parsed pattern have named arguments like {first_name}?
UMessagePatternArgType
Argument type constants.
A UParseError struct is used to returned detailed information about parsing errors.
const UnicodeString & getPatternString() const
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
int32_t getLimitPartIndex(int32_t start) const
Returns the index of the ARG|MSG_LIMIT part corresponding to the ARG|MSG_START at start...
int32_t countParts() const
Returns the number of "parts" created by parsing the pattern string.
The argument has a "simple" type which is provided by the ARG_TYPE part.
UnicodeString getSubstring(const Part &part) const
Returns the substring of the pattern string indicated by the Part.
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
void clearPatternAndSetApostropheMode(UMessagePatternApostropheMode mode)
Clears this MessagePattern and sets the UMessagePatternApostropheMode.
UMessagePatternApostropheMode
Mode for when an apostrophe starts quoted literal text for MessageFormat output.
int8_t UBool
The ICU boolean type.