17 #ifndef __MESSAGEPATTERN_H__ 18 #define __MESSAGEPATTERN_H__ 27 #if !UCONFIG_NO_FORMATTING 270 #define UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE(argType) \ 271 ((argType)==UMSGPAT_ARG_TYPE_PLURAL || (argType)==UMSGPAT_ARG_TYPE_SELECTORDINAL) 297 #define UMSGPAT_NO_NUMERIC_VALUE ((double)(-123456789)) 301 class MessagePatternDoubleList;
302 class MessagePatternPartsList;
542 int32_t hashCode()
const;
578 return hasArgNumbers;
592 static int32_t validateArgumentName(
const UnicodeString &name);
636 return getPart(i).type;
647 return getPart(partIndex).index;
669 return 0==msg.compare(part.index, part.length, s);
678 double getNumericValue(
const Part &part)
const;
686 double getPluralOffset(int32_t pluralStart)
const;
697 int32_t limit=getPart(start).limitPartIndex;
814 return ((type*37+index)*37+length)*37+value;
820 static const int32_t MAX_LENGTH=0xffff;
821 static const int32_t MAX_VALUE=0x7fff;
829 int32_t limitPartIndex;
837 int32_t parseMessage(int32_t index, int32_t msgStartLength,
841 int32_t parseArg(int32_t index, int32_t argStartLength, int32_t nestingLevel,
846 int32_t parseChoiceStyle(int32_t index, int32_t nestingLevel,
860 static int32_t parseArgNumber(
const UnicodeString &s, int32_t start, int32_t limit);
862 int32_t parseArgNumber(int32_t start, int32_t limit) {
863 return parseArgNumber(msg, start, limit);
874 void parseDouble(int32_t start, int32_t limit,
UBool allowInfinity,
880 int32_t skipWhiteSpace(int32_t index);
882 int32_t skipIdentifier(int32_t index);
888 int32_t skipDouble(int32_t index);
892 UBool isChoice(int32_t index);
894 UBool isPlural(int32_t index);
896 UBool isSelect(int32_t index);
898 UBool isOrdinal(int32_t index);
904 UBool inMessageFormatPattern(int32_t nestingLevel);
915 void addLimitPart(int32_t start,
919 void addArgDoublePart(
double numericValue, int32_t start, int32_t length,
UErrorCode &errorCode);
921 void setParseError(
UParseError *parseError, int32_t index);
929 MessagePatternPartsList *partsList;
933 MessagePatternDoubleList *numericValuesList;
934 double *numericValues;
935 int32_t numericValuesLength;
938 UBool needsAutoQuoting;
943 #endif // !UCONFIG_NO_FORMATTING 945 #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...
const UnicodeString & getPatternString() const
A numeric value, for example the offset or an explicit selector value in a PluralFormat style...
A literal apostrophe is represented by either a single or a double apostrophe pattern character...
const Part & getPart(int32_t i) const
Gets the i-th pattern "part".
UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const
Create a temporary substring for the specified range.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
The argument has no specified type.
static UBool hasNumericValue(UMessagePatternPartType type)
Indicates whether the Part type has a numeric value.
UMessagePatternPartType
MessagePattern::Part type constants.
The argument number, provided by the value.
int32_t getValue() const
Returns a value associated with this part.
The argument is an ordinal-number PluralFormat with the same style parts sequence and semantics as UM...
void clearPatternAndSetApostropheMode(UMessagePatternApostropheMode mode)
Clears this MessagePattern and sets the UMessagePatternApostropheMode.
Parses and represents ICU MessageFormat patterns.
The argument is a ChoiceFormat with one or more ((ARG_INT | ARG_DOUBLE), ARG_SELECTOR, message) tuples.
#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...
int32_t getPatternIndex(int32_t partIndex) const
Returns the pattern index of the specified pattern "part".
A literal apostrophe must be represented by a double apostrophe pattern character.
UMessagePatternArgType getArgType() const
Returns the argument type if this part is of type ARG_START or ARG_LIMIT, otherwise UMSGPAT_ARG_TYPE_...
UMessagePatternApostropheMode getApostropheMode() const
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
UBool partSubstringMatches(const Part &part, const UnicodeString &s) const
Compares the part's substring with the input string s.
Indicates that a syntax character needs to be inserted for auto-quoting.
int32_t countParts() const
Returns the number of "parts" created by parsing the pattern string.
int32_t getLimit() const
Returns the pattern string limit (exclusive-end) index associated with this Part. ...
Return value from MessagePattern.validateArgumentName() for when the string is invalid.
UBool operator!=(const Part &other) const
UBool operator!=(const MessagePattern &other) const
Start of a message pattern (main or nested).
UBool hasNumberedArguments() const
Does the parsed pattern have numbered arguments like {2}?
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
UMessagePatternPartType getType() const
Returns the type of this part.
C API: Parse Error Information.
End of a message pattern (main or nested).
A selector substring in a "complex" argument style.
Indicates a substring of the pattern string which is to be skipped when formatting.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Part()
Default constructor, do not use.
A message pattern "part", representing a pattern parsing event.
Indicates a syntactic (non-escaped) # symbol in a plural variant.
UMessagePatternPartType getPartType(int32_t i) const
Returns the UMessagePatternPartType of the i-th pattern "part".
The argument is a cardinal-number PluralFormat with an optional ARG_INT or ARG_DOUBLE offset (e...
int32_t getIndex() const
Returns the pattern string index associated with this Part.
UMessagePatternArgType
Argument type constants.
A UParseError struct is used to returned detailed information about parsing errors.
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...
UBool hasNamedArguments() const
Does the parsed pattern have named arguments like {first_name}?
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
int32_t getLength() const
Returns the length of the pattern substring associated with this Part.
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.
UObject is the common ICU "boilerplate" class.
UMemory is the common ICU base class.
UMessagePatternApostropheMode
Mode for when an apostrophe starts quoted literal text for MessageFormat output.
int8_t UBool
The ICU boolean type.