| OLD | NEW |
| 1 /* | 1 /* |
| 2 ********************************************************************** | 2 ********************************************************************** |
| 3 * Copyright (c) 2001-2012, International Business Machines | 3 * Copyright (c) 2001-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ********************************************************************** | 5 ********************************************************************** |
| 6 * Date Name Description | 6 * Date Name Description |
| 7 * 11/19/2001 aliu Creation. | 7 * 11/19/2001 aliu Creation. |
| 8 * 05/19/2010 markus Rewritten from scratch | 8 * 05/19/2010 markus Rewritten from scratch |
| 9 ********************************************************************** | 9 ********************************************************************** |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 #ifndef CHARSTRING_H | 12 #ifndef CHARSTRING_H |
| 13 #define CHARSTRING_H | 13 #define CHARSTRING_H |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 CharString ©From(const CharString &other, UErrorCode &errorCode); | 62 CharString ©From(const CharString &other, UErrorCode &errorCode); |
| 63 | 63 |
| 64 UBool isEmpty() const { return len==0; } | 64 UBool isEmpty() const { return len==0; } |
| 65 int32_t length() const { return len; } | 65 int32_t length() const { return len; } |
| 66 char operator[](int32_t index) const { return buffer[index]; } | 66 char operator[](int32_t index) const { return buffer[index]; } |
| 67 StringPiece toStringPiece() const { return StringPiece(buffer.getAlias(), le
n); } | 67 StringPiece toStringPiece() const { return StringPiece(buffer.getAlias(), le
n); } |
| 68 | 68 |
| 69 const char *data() const { return buffer.getAlias(); } | 69 const char *data() const { return buffer.getAlias(); } |
| 70 char *data() { return buffer.getAlias(); } | 70 char *data() { return buffer.getAlias(); } |
| 71 | 71 |
| 72 /** @return last index of c, or -1 if c is not in this string */ |
| 73 int32_t lastIndexOf(char c) const; |
| 74 |
| 72 CharString &clear() { len=0; buffer[0]=0; return *this; } | 75 CharString &clear() { len=0; buffer[0]=0; return *this; } |
| 73 CharString &truncate(int32_t newLength); | 76 CharString &truncate(int32_t newLength); |
| 74 | 77 |
| 75 CharString &append(char c, UErrorCode &errorCode); | 78 CharString &append(char c, UErrorCode &errorCode); |
| 76 CharString &append(const StringPiece &s, UErrorCode &errorCode) { | 79 CharString &append(const StringPiece &s, UErrorCode &errorCode) { |
| 77 return append(s.data(), s.length(), errorCode); | 80 return append(s.data(), s.length(), errorCode); |
| 78 } | 81 } |
| 79 CharString &append(const CharString &s, UErrorCode &errorCode) { | 82 CharString &append(const CharString &s, UErrorCode &errorCode) { |
| 80 return append(s.data(), s.length(), errorCode); | 83 return append(s.data(), s.length(), errorCode); |
| 81 } | 84 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 107 | 110 |
| 108 CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCo
de); | 111 CharString &appendInvariantChars(const UnicodeString &s, UErrorCode &errorCo
de); |
| 109 | 112 |
| 110 /** | 113 /** |
| 111 * Appends a filename/path part, e.g., a directory name. | 114 * Appends a filename/path part, e.g., a directory name. |
| 112 * First appends a U_FILE_SEP_CHAR if necessary. | 115 * First appends a U_FILE_SEP_CHAR if necessary. |
| 113 * Does nothing if s is empty. | 116 * Does nothing if s is empty. |
| 114 */ | 117 */ |
| 115 CharString &appendPathPart(const StringPiece &s, UErrorCode &errorCode); | 118 CharString &appendPathPart(const StringPiece &s, UErrorCode &errorCode); |
| 116 | 119 |
| 120 /** |
| 121 * Appends a U_FILE_SEP_CHAR if this string is not empty |
| 122 * and does not already end with a U_FILE_SEP_CHAR or U_FILE_ALT_SEP_CHAR. |
| 123 */ |
| 124 CharString &ensureEndsWithFileSeparator(UErrorCode &errorCode); |
| 125 |
| 117 private: | 126 private: |
| 118 MaybeStackArray<char, 40> buffer; | 127 MaybeStackArray<char, 40> buffer; |
| 119 int32_t len; | 128 int32_t len; |
| 120 | 129 |
| 121 UBool ensureCapacity(int32_t capacity, int32_t desiredCapacityHint, UErrorCo
de &errorCode); | 130 UBool ensureCapacity(int32_t capacity, int32_t desiredCapacityHint, UErrorCo
de &errorCode); |
| 122 | 131 |
| 123 CharString(const CharString &other); // forbid copying of this class | 132 CharString(const CharString &other); // forbid copying of this class |
| 124 CharString &operator=(const CharString &other); // forbid copying of this cl
ass | 133 CharString &operator=(const CharString &other); // forbid copying of this cl
ass |
| 125 }; | 134 }; |
| 126 | 135 |
| 127 U_NAMESPACE_END | 136 U_NAMESPACE_END |
| 128 | 137 |
| 129 #endif | 138 #endif |
| 130 //eof | 139 //eof |
| OLD | NEW |