/** * All possible stem literals have an entry in the StemEnum. The enum name is the kebab case stem * string literal written in upper snake case. * * @see StemToObject * @see #SERIALIZED_STEM_TRIE
*/ enum StemEnum {
// Section 1: Stems that do not require an option:
/** Default wildcard char, accepted on input and printed in output */
constexpr char16_t kWildcardChar = u'*';
/** Alternative wildcard char, accept on input but not printed in output */
constexpr char16_t kAltWildcardChar = u'+';
/** Checks whether the char is a wildcard on input */ inlinebool isWildcardChar(char16_t c) { return c == kWildcardChar || c == kAltWildcardChar;
}
/** * Creates a NumberFormatter corresponding to the given skeleton string. * * @param skeletonString * A number skeleton string, possibly not in its shortest form. * @return An UnlocalizedNumberFormatter with behavior defined by the given skeleton string.
*/
UnlocalizedNumberFormatter create( const UnicodeString& skeletonString, UParseError* perror, UErrorCode& status);
/** * Create a skeleton string corresponding to the given NumberFormatter. * * @param macros * The NumberFormatter options object. * @return A skeleton string in normalized form.
*/
UnicodeString generate(const MacroProps& macros, UErrorCode& status);
/** * Converts from a skeleton string to a MacroProps. This method contains the primary parse loop. * * Internal: use the create() endpoint instead of this function.
*/
MacroProps parseSkeleton(const UnicodeString& skeletonString, int32_t& errOffset, UErrorCode& status);
/** * Given that the current segment represents a stem, parse it and save the result. * * @return The next state after parsing this stem, corresponding to what subset of options to expect.
*/
ParseState parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, SeenMacroProps& seen,
MacroProps& macros, UErrorCode& status);
/** * Given that the current segment represents an option, parse it and save the result. * * @return The next state after parsing this option, corresponding to what subset of options to * expect next.
*/
ParseState
parseOption(ParseState stem, const StringSegment& segment, MacroProps& macros, UErrorCode& status);
} // namespace skeleton
/** * Namespace for utility methods that convert from StemEnum to corresponding objects or enums. This * applies to only the "Section 1" stems, those that are well-defined without an option.
*/ namespace stem_to_object {
/** * Namespace for utility methods that convert from enums to stem strings. More complex object conversions * take place in the object_to_stem_string namespace.
*/ namespace enum_to_stem_string {
// "measure-unit/" is deprecated in favour of "unit/". void parseMeasureUnitOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
// "per-measure-unit/" is deprecated in favour of "unit/". void parseMeasurePerUnitOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
/** * Parses unit identifiers like "meter-per-second" and "foot-and-inch", as * specified via a "unit/" concise skeleton.
*/ void parseIdentifierUnitOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
// Note: no generateIntegerStem since this syntax was added later in ICU 67
/** @return Whether we successfully found and parsed a frac-sig option. */ bool parseFracSigOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
/** @return Whether we successfully found and parsed a trailing zero option. */ bool parseTrailingZeroOption(const StringSegment& segment, MacroProps& macros, UErrorCode& status);
/** * Class for utility methods for generating a token corresponding to each macro-prop. Each method * returns whether or not a token was written to the string builder. * * This needs to be a class, not a namespace, so it can be friended.
*/ class GeneratorHelpers { public: /** * Main skeleton generator function. Appends the normalized skeleton for the MacroProps to the given * StringBuilder. * * Internal: use the create() endpoint instead of this function.
*/ staticvoid generateSkeleton(const MacroProps& macros, UnicodeString& sb, UErrorCode& status);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.