@@ -87,6 +87,22 @@ class U_COMMON_API CharString : public UMemory {
87
87
* The caller must uprv_free() the result.
88
88
*/
89
89
char *cloneData (UErrorCode &errorCode) const ;
90
+ /* *
91
+ * Copies the contents of the string into dest.
92
+ * Checks if there is enough space in dest, extracts the entire string if possible,
93
+ * and NUL-terminates dest if possible.
94
+ *
95
+ * If the string fits into dest but cannot be NUL-terminated (length()==capacity),
96
+ * then the error code is set to U_STRING_NOT_TERMINATED_WARNING.
97
+ * If the string itself does not fit into dest (length()>capacity),
98
+ * then the error code is set to U_BUFFER_OVERFLOW_ERROR.
99
+ *
100
+ * @param dest Destination string buffer.
101
+ * @param capacity Size of the dest buffer (number of chars).
102
+ * @param errorCode ICU error code.
103
+ * @return length()
104
+ */
105
+ int32_t extract (char *dest, int32_t capacity, UErrorCode &errorCode) const ;
90
106
91
107
bool operator ==(StringPiece other) const {
92
108
return len == other.length () && (len == 0 || uprv_memcmp (data (), other.data (), len) == 0 );
@@ -141,13 +157,13 @@ class U_COMMON_API CharString : public UMemory {
141
157
142
158
/* *
143
159
* Appends a filename/path part, e.g., a directory name.
144
- * First appends a U_FILE_SEP_CHAR if necessary.
160
+ * First appends a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR if necessary.
145
161
* Does nothing if s is empty.
146
162
*/
147
163
CharString &appendPathPart (StringPiece s, UErrorCode &errorCode);
148
164
149
165
/* *
150
- * Appends a U_FILE_SEP_CHAR if this string is not empty
166
+ * Appends a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR if this string is not empty
151
167
* and does not already end with a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR.
152
168
*/
153
169
CharString &ensureEndsWithFileSeparator (UErrorCode &errorCode);
@@ -160,6 +176,12 @@ class U_COMMON_API CharString : public UMemory {
160
176
161
177
CharString (const CharString &other); // forbid copying of this class
162
178
CharString &operator =(const CharString &other); // forbid copying of this class
179
+
180
+ /* *
181
+ * Returns U_FILE_ALT_SEP_CHAR if found in string, and U_FILE_SEP_CHAR is not found.
182
+ * Otherwise returns U_FILE_SEP_CHAR.
183
+ */
184
+ char getDirSepChar () const ;
163
185
};
164
186
165
187
U_NAMESPACE_END
0 commit comments