2121
2222U_NAMESPACE_BEGIN
2323
24- // Windows needs us to DLL-export the MaybeStackArray template specialization,
25- // but MacOS X cannot handle it. Same as in digitlst.h.
26- #if !U_PLATFORM_IS_DARWIN_BASED
27- template class U_COMMON_API MaybeStackArray<char , 40 >;
28- #endif
29-
3024/* *
3125 * ICU-internal char * string class.
3226 * This class does not assume or enforce any particular character encoding.
@@ -38,56 +32,56 @@ template class U_COMMON_API MaybeStackArray<char, 40>;
3832 * For example:
3933 * cs.data()[5]='a'; // no need for setCharAt(5, 'a')
4034 */
41- class U_COMMON_API CharString : public UMemory {
35+ class U_COMMON_API_CLASS CharString : public UMemory {
4236public:
43- CharString () : len(0 ) { buffer[0 ]=0 ; }
44- CharString (StringPiece s, UErrorCode &errorCode) : len(0 ) {
37+ U_COMMON_API CharString () : len(0 ) { buffer[0 ]=0 ; }
38+ U_COMMON_API CharString (StringPiece s, UErrorCode &errorCode) : len(0 ) {
4539 buffer[0 ]=0 ;
4640 append (s, errorCode);
4741 }
48- CharString (const CharString &s, UErrorCode &errorCode) : len(0 ) {
42+ U_COMMON_API CharString (const CharString &s, UErrorCode &errorCode) : len(0 ) {
4943 buffer[0 ]=0 ;
5044 append (s, errorCode);
5145 }
52- CharString (const char *s, int32_t sLength , UErrorCode &errorCode) : len(0 ) {
46+ U_COMMON_API CharString (const char *s, int32_t sLength , UErrorCode &errorCode) : len(0 ) {
5347 buffer[0 ]=0 ;
5448 append (s, sLength , errorCode);
5549 }
56- ~CharString () {}
50+ U_COMMON_API ~CharString () {}
5751
5852 /* *
5953 * Move constructor; might leave src in an undefined state.
6054 * This string will have the same contents and state that the source string had.
6155 */
62- CharString (CharString &&src) noexcept ;
56+ U_COMMON_API CharString (CharString &&src) noexcept ;
6357 /* *
6458 * Move assignment operator; might leave src in an undefined state.
6559 * This string will have the same contents and state that the source string had.
6660 * The behavior is undefined if *this and src are the same object.
6761 */
68- CharString &operator =(CharString &&src) noexcept ;
62+ U_COMMON_API CharString &operator =(CharString &&src) noexcept ;
6963
7064 /* *
7165 * Replaces this string's contents with the other string's contents.
7266 * CharString does not support the standard copy constructor nor
7367 * the assignment operator, to make copies explicit and to
7468 * use a UErrorCode where memory allocations might be needed.
7569 */
76- CharString ©From (const CharString &other, UErrorCode &errorCode);
77- CharString ©From (StringPiece s, UErrorCode &errorCode);
70+ U_COMMON_API CharString ©From (const CharString &other, UErrorCode &errorCode);
71+ U_COMMON_API CharString ©From (StringPiece s, UErrorCode &errorCode);
7872
79- UBool isEmpty () const { return len==0 ; }
80- int32_t length () const { return len; }
81- char operator [](int32_t index) const { return buffer[index]; }
82- StringPiece toStringPiece () const { return StringPiece (buffer.getAlias (), len); }
73+ U_COMMON_API UBool isEmpty () const { return len==0 ; }
74+ U_COMMON_API int32_t length () const { return len; }
75+ U_COMMON_API char operator [](int32_t index) const { return buffer[index]; }
76+ U_COMMON_API StringPiece toStringPiece () const { return StringPiece (buffer.getAlias (), len); }
8377
84- const char *data () const { return buffer.getAlias (); }
85- char *data () { return buffer.getAlias (); }
78+ U_COMMON_API const char *data () const { return buffer.getAlias (); }
79+ U_COMMON_API char *data () { return buffer.getAlias (); }
8680 /* *
8781 * Allocates length()+1 chars and copies the NUL-terminated data().
8882 * The caller must uprv_free() the result.
8983 */
90- char *cloneData (UErrorCode &errorCode) const ;
84+ U_COMMON_API char *cloneData (UErrorCode &errorCode) const ;
9185 /* *
9286 * Copies the contents of the string into dest.
9387 * Checks if there is enough space in dest, extracts the entire string if possible,
@@ -103,40 +97,40 @@ class U_COMMON_API CharString : public UMemory {
10397 * @param errorCode ICU error code.
10498 * @return length()
10599 */
106- int32_t extract (char *dest, int32_t capacity, UErrorCode &errorCode) const ;
100+ U_COMMON_API int32_t extract (char *dest, int32_t capacity, UErrorCode &errorCode) const ;
107101
108- bool operator ==(const CharString& other) const {
102+ U_COMMON_API bool operator ==(const CharString& other) const {
109103 return len == other.length () && (len == 0 || uprv_memcmp (data (), other.data (), len) == 0 );
110104 }
111- bool operator !=(const CharString& other) const {
105+ U_COMMON_API bool operator !=(const CharString& other) const {
112106 return !operator ==(other);
113107 }
114108
115- bool operator ==(StringPiece other) const {
109+ U_COMMON_API bool operator ==(StringPiece other) const {
116110 return len == other.length () && (len == 0 || uprv_memcmp (data (), other.data (), len) == 0 );
117111 }
118- bool operator !=(StringPiece other) const {
112+ U_COMMON_API bool operator !=(StringPiece other) const {
119113 return !operator ==(other);
120114 }
121115
122116 /* * @return last index of c, or -1 if c is not in this string */
123- int32_t lastIndexOf (char c) const ;
117+ U_COMMON_API int32_t lastIndexOf (char c) const ;
124118
125- bool contains (StringPiece s) const ;
119+ U_COMMON_API bool contains (StringPiece s) const ;
126120
127- CharString &clear () { len=0 ; buffer[0 ]=0 ; return *this ; }
128- CharString &truncate (int32_t newLength);
121+ U_COMMON_API CharString &clear () { len=0 ; buffer[0 ]=0 ; return *this ; }
122+ U_COMMON_API CharString &truncate (int32_t newLength);
129123
130- CharString &append (char c, UErrorCode &errorCode);
131- CharString &append (StringPiece s, UErrorCode &errorCode) {
124+ U_COMMON_API CharString &append (char c, UErrorCode &errorCode);
125+ U_COMMON_API CharString &append (StringPiece s, UErrorCode &errorCode) {
132126 return append (s.data (), s.length (), errorCode);
133127 }
134- CharString &append (const CharString &s, UErrorCode &errorCode) {
128+ U_COMMON_API CharString &append (const CharString &s, UErrorCode &errorCode) {
135129 return append (s.data (), s.length (), errorCode);
136130 }
137- CharString &append (const char *s, int32_t sLength , UErrorCode &status);
131+ U_COMMON_API CharString &append (const char *s, int32_t sLength , UErrorCode &status);
138132
139- CharString &appendNumber (int64_t number, UErrorCode &status);
133+ U_COMMON_API CharString &appendNumber (int64_t number, UErrorCode &status);
140134
141135 /* *
142136 * Returns a writable buffer for appending and writes the buffer's capacity to
@@ -158,26 +152,28 @@ class U_COMMON_API CharString : public UMemory {
158152 * @param errorCode in/out error code
159153 * @return a buffer with resultCapacity>=min_capacity
160154 */
161- char *getAppendBuffer (int32_t minCapacity,
162- int32_t desiredCapacityHint,
163- int32_t &resultCapacity,
164- UErrorCode &errorCode);
155+ U_COMMON_API char *getAppendBuffer (int32_t minCapacity,
156+ int32_t desiredCapacityHint,
157+ int32_t &resultCapacity,
158+ UErrorCode &errorCode);
165159
166- CharString &appendInvariantChars (const UnicodeString &s, UErrorCode &errorCode);
167- CharString &appendInvariantChars (const char16_t * uchars, int32_t ucharsLen, UErrorCode& errorCode);
160+ U_COMMON_API CharString &appendInvariantChars (const UnicodeString &s, UErrorCode &errorCode);
161+ U_COMMON_API CharString &appendInvariantChars (const char16_t * uchars,
162+ int32_t ucharsLen,
163+ UErrorCode& errorCode);
168164
169165 /* *
170166 * Appends a filename/path part, e.g., a directory name.
171167 * First appends a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR if necessary.
172168 * Does nothing if s is empty.
173169 */
174- CharString &appendPathPart (StringPiece s, UErrorCode &errorCode);
170+ U_COMMON_API CharString &appendPathPart (StringPiece s, UErrorCode &errorCode);
175171
176172 /* *
177173 * Appends a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR if this string is not empty
178174 * and does not already end with a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR.
179175 */
180- CharString &ensureEndsWithFileSeparator (UErrorCode &errorCode);
176+ U_COMMON_API CharString &ensureEndsWithFileSeparator (UErrorCode &errorCode);
181177
182178private:
183179 MaybeStackArray<char , 40 > buffer;
0 commit comments