Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: source/common/simplepatternformatter.h

Issue 1621943002: ICU 56 step 4: Apply post-56 fixes for measure/date format (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@56goog
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/resource.cpp ('k') | source/common/simplepatternformatter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ****************************************************************************** 2 ******************************************************************************
3 * Copyright (C) 2014, International Business Machines 3 * Copyright (C) 2014-2015, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ****************************************************************************** 5 ******************************************************************************
6 * simplepatternformatter.h 6 * simplepatternformatter.h
7 */ 7 */
8 8
9 #ifndef __SIMPLEPATTERNFORMATTER_H__ 9 #ifndef __SIMPLEPATTERNFORMATTER_H__
10 #define __SIMPLEPATTERNFORMATTER_H__ 10 #define __SIMPLEPATTERNFORMATTER_H__
11 11
12 #define EXPECTED_PLACEHOLDER_COUNT 3 12 #define EXPECTED_PLACEHOLDER_COUNT 3
13 13
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 * </pre> 45 * </pre>
46 */ 46 */
47 class U_COMMON_API SimplePatternFormatter : public UMemory { 47 class U_COMMON_API SimplePatternFormatter : public UMemory {
48 public: 48 public:
49 /** 49 /**
50 * Default constructor 50 * Default constructor
51 */ 51 */
52 SimplePatternFormatter(); 52 SimplePatternFormatter();
53 53
54 /** 54 /**
55 * Construct from a pattern. Will never fail if pattern has three or 55 * Constructs from a pattern. Will never fail if pattern has three or
56 * fewer placeholders in it. 56 * fewer placeholders in it.
57 */ 57 */
58 explicit SimplePatternFormatter(const UnicodeString& pattern); 58 explicit SimplePatternFormatter(const UnicodeString& pattern);
59 59
60 /** 60 /**
61 * Constructs from a pattern. Will never fail if pattern has three or
62 * fewer placeholders in it.
63 *
64 * @param min The pattern must have at least this many placeholders.
65 * @param max The pattern must have at most this many placeholders.
66 */
67 SimplePatternFormatter(const UnicodeString& pattern, int32_t min, int32_t ma x,
68 UErrorCode &errorCode);
69
70 /**
61 * Copy constructor. 71 * Copy constructor.
62 */ 72 */
63 SimplePatternFormatter(const SimplePatternFormatter& other); 73 SimplePatternFormatter(const SimplePatternFormatter& other);
64 74
65 /** 75 /**
66 * Assignment operator 76 * Assignment operator
67 */ 77 */
68 SimplePatternFormatter &operator=(const SimplePatternFormatter& other); 78 SimplePatternFormatter &operator=(const SimplePatternFormatter& other);
69 79
70 /** 80 /**
71 * Destructor. 81 * Destructor.
72 */ 82 */
73 ~SimplePatternFormatter(); 83 ~SimplePatternFormatter();
74 84
75 /** 85 /**
76 * Compiles pattern and makes this object represent pattern. 86 * Compiles pattern and makes this object represent pattern.
77 * 87 *
78 * Returns TRUE on success; FALSE on failure. Will not fail if 88 * Returns TRUE on success; FALSE on failure. Will not fail if
79 * there are three or fewer placeholders in pattern. May fail with 89 * there are three or fewer placeholders in pattern. May fail with
80 * U_MEMORY_ALLOCATION_ERROR if there are more than three placeholders. 90 * U_MEMORY_ALLOCATION_ERROR if there are more than three placeholders.
81 */ 91 */
82 UBool compile(const UnicodeString &pattern, UErrorCode &status); 92 UBool compile(const UnicodeString &pattern, UErrorCode &status) {
93 return compileMinMaxPlaceholders(pattern, 0, INT32_MAX, status);
94 }
95
96 /**
97 * Compiles pattern and makes this object represent pattern.
98 *
99 * Returns TRUE on success; FALSE on failure. Will not fail if
100 * there are three or fewer placeholders in pattern. May fail with
101 * U_MEMORY_ALLOCATION_ERROR if there are more than three placeholders.
102 *
103 * @param min The pattern must have at least this many placeholders.
104 * @param max The pattern must have at most this many placeholders.
105 */
106 UBool compileMinMaxPlaceholders(const UnicodeString &pattern,
107 int32_t min, int32_t max, UErrorCode &status );
83 108
84 /** 109 /**
85 * Returns (maxPlaceholderId + 1). For example 110 * Returns (maxPlaceholderId + 1). For example
86 * <code>SimplePatternFormatter("{0} {2}").getPlaceholderCount() 111 * <code>SimplePatternFormatter("{0} {2}").getPlaceholderCount()
87 * evaluates to 3. 112 * evaluates to 3.
88 * Callers use this function to find out how many values this object 113 * Callers use this function to find out how many values this object
89 * expects when formatting. 114 * expects when formatting.
90 */ 115 */
91 int32_t getPlaceholderCount() const { 116 int32_t getPlaceholderCount() const {
92 return placeholderCount; 117 return placeholderCount;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 int32_t ensureCapacity(int32_t desiredCapacity, int32_t allocationSize=0); 254 int32_t ensureCapacity(int32_t desiredCapacity, int32_t allocationSize=0);
230 255
231 // Records the offset of an individual placeholder in the noPlaceholders 256 // Records the offset of an individual placeholder in the noPlaceholders
232 // string. 257 // string.
233 UBool addPlaceholder(int32_t id, int32_t offset); 258 UBool addPlaceholder(int32_t id, int32_t offset);
234 }; 259 };
235 260
236 U_NAMESPACE_END 261 U_NAMESPACE_END
237 262
238 #endif 263 #endif
OLDNEW
« no previous file with comments | « source/common/resource.cpp ('k') | source/common/simplepatternformatter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698